Clonezilla Live USB - a really handy imaging/recovery tool Source
Markdown source
1---2title: 'Clonezilla Live USB - a really handy imaging/recovery tool'3date: '2009-11-03'4published_at: '2009-11-03T16:31:00.006+11:00'5tags: ['clonezilla linux backup sysadmin']6author: 'Gavin Jackson'7excerpt: 'Recently we have been deploying a lot of laptops to business development managers across Australia and Asia. We have also found that we often need to rebuild these laptops - and it''s starting to becom...'8updated_at: '2009-11-03T16:54:50.391+11:00'9legacy_url: 'http://www.gavinj.net/2009/11/clonezilla-live-usb-really-handy.html'10---1112Recently we have been deploying a lot of laptops to business development managers across Australia and Asia. We have also found that we often need to rebuild these laptops - and it's starting to become a bit of a chore.1314We decided to have a go at using the Open Source Clonezilla imaging program. It is very similar to Norton Ghost - it allows us to boot up the computer to be imaged off a bootable CD (or USB key) and perform the backup onto a network connected Samba share (or connected USB drive).1516I wanted to build a restore system that our users can use in the field - by using a 32GB Sandisk thumb drive with a boot partition and a storage partition (for the restore image), I used the following howto to create an (almost) unattended install that a normal user could perform.1718I used the following instructions to build the Clonezilla Live image that I placed on the bootable USB partition:19[http://clonezilla.org/clonezilla-live/customized-clonezilla-live.php ](http://clonezilla.org/clonezilla-live/customized-clonezilla-live.php) I modified the sample custom-ocs file to mount the second partition and only provide the restore option (code below):2021```22#!/bin/bash2324# When this script is ready, you can run25# /opt/drbl/sbin/ocs-iso -g en_US.UTF-8 -k NONE -s -m ./custom-ocs26# to create the iso file for CD/DVD. or27# /opt/drbl/sbin/ocs-live-dev -g en_US.UTF-8 -k NONE -s -c -m ./custom-ocs28# to create the zip file for USB flash drive.2930# Begin of the scripts:31# Load DRBL setting and functions32DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"3334. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions35. $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf36. $DRBL_SCRIPT_PATH/sbin/ocs-functions3738# load the setting for clonezilla live.39[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf4041# Load language files. For English, use "en_US.UTF-8".42ask_and_load_lang_set en_US.UTF-84344### CHANGE THESE AS NEEDED ###45img_name="2009-10-29-17-delld620"46tgt_part=sda47src_part=sdb248menu_title="Dell d620 Restore Disk"49##############################5051action_restore() {52mkdir -p $ocsroot53if ! mountpoint $ocsroot &>/dev/null; then54 part_fs="$(LANG=C ocs-get-part-info /dev/$src_part filesystem)"55 case "$part_fs" in56 ntfs) ntfs-3g /dev/$src_part $ocsroot ;;57 *) mount /dev/$src_part $ocsroot ;;58 esac59fi60if mountpoint $ocsroot &>/dev/null; then6162 # If you want to run it in batch mode, add option "-b" in the ocs-sr command63 # For more options about ocs-sr, run "ocs-sr -h"64 ocs-sr -e1 auto -e2 -c -r -j2 -p true restoredisk "$img_name" "$tgt_part"65else66 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE67 echo "Fail to mount /dev/$tgt_part as $ocsroot!"68 echo "Program terminated!"69 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL70fi71umount $ocsroot &>/dev/null72}7374##################7576###### MAIN ######77##################7879# Find the device and partition8081TMP="$(mktemp /tmp/menu.XXXXXX)"82trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT83$DIA --backtitle "$menu_title" --title \84"$menu_title" --menu "$msg_choose_mode:" \850 0 0 \86"Restore" "Restore the image in $src_part to $tgt_part" \872> $TMP88mode="$(cat $TMP)"89[ -f "$TMP" ] && rm -f $TMP9091case "$mode" in92Restore)93 action_restore;;94*)95 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE96 echo "Program terminated!"97 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL98 exit 199esac100```101So now when the user boots off the USB key, they only see a single option to perform a restore off the USB key:102103[](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJxug3o84UsLyjBMleJpoajtFLdouWKTKBDsm9vVqbf6L7kqymVL-fufQmS3HTaDE_S4ENJrL1rPyd7aEQ8rPy4E8WDyrTU0ppSw_SxgCgrp5Ps6bTc8HxH_grHXTIFMG4kR8A1wiWlWE/s1600-h/IMG_0119.JPG)104105106