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 become a bit of a chore.

We 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).

I 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.

I used the following instructions to build the Clonezilla Live image that I placed on the bootable USB partition: 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):

#!/bin/bash

# When this script is ready, you can run
# /opt/drbl/sbin/ocs-iso -g en_US.UTF-8 -k NONE -s -m ./custom-ocs
# to create the iso file for CD/DVD. or
# /opt/drbl/sbin/ocs-live-dev -g en_US.UTF-8 -k NONE -s -c -m ./custom-ocs
# to create the zip file for USB flash drive.

# Begin of the scripts:
# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions

# load the setting for clonezilla live.
[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf

# Load language files. For English, use "en_US.UTF-8".
ask_and_load_lang_set en_US.UTF-8

### CHANGE THESE AS NEEDED ###
img_name="2009-10-29-17-delld620"
tgt_part=sda
src_part=sdb2
menu_title="Dell d620 Restore Disk"
##############################

action_restore() {
mkdir -p $ocsroot
if ! mountpoint $ocsroot &>/dev/null; then
  part_fs="$(LANG=C ocs-get-part-info /dev/$src_part filesystem)"
  case "$part_fs" in
    ntfs) ntfs-3g /dev/$src_part $ocsroot ;;
    *) mount /dev/$src_part $ocsroot ;;
  esac
fi
if mountpoint $ocsroot &>/dev/null; then

  # If you want to run it in batch mode, add option "-b" in the ocs-sr command
  # For more options about ocs-sr, run "ocs-sr -h"
  ocs-sr -e1 auto -e2 -c -r -j2 -p true restoredisk "$img_name" "$tgt_part"
else
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "Fail to mount /dev/$tgt_part as $ocsroot!"
  echo "Program terminated!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
umount $ocsroot &>/dev/null
}

##################

###### MAIN ######
##################

# Find the device and partition

TMP="$(mktemp /tmp/menu.XXXXXX)"
trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT
$DIA --backtitle "$menu_title" --title  \
"$menu_title" --menu "$msg_choose_mode:" \
0 0 0 \
"Restore" "Restore the image in $src_part to $tgt_part" \
2> $TMP
mode="$(cat $TMP)"
[ -f "$TMP" ] && rm -f $TMP

case "$mode" in
Restore)
  action_restore;;
*)
  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
  echo "Program terminated!"
  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
  exit 1
esac

So now when the user boots off the USB key, they only see a single option to perform a restore off the USB key: