Clonezilla Live USB - a really handy imaging/recovery tool 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---
11
12Recently 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.
13
14We 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).
15
16I 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.
17
18I 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):
20
21```
22#!/bin/bash
23
24# When this script is ready, you can run
25# /opt/drbl/sbin/ocs-iso -g en_US.UTF-8 -k NONE -s -m ./custom-ocs
26# to create the iso file for CD/DVD. or
27# /opt/drbl/sbin/ocs-live-dev -g en_US.UTF-8 -k NONE -s -c -m ./custom-ocs
28# to create the zip file for USB flash drive.
29
30# Begin of the scripts:
31# Load DRBL setting and functions
32DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"
33
34. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
35. $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
36. $DRBL_SCRIPT_PATH/sbin/ocs-functions
37
38# load the setting for clonezilla live.
39[ -e /etc/ocs/ocs-live.conf ] && . /etc/ocs/ocs-live.conf
40
41# Load language files. For English, use "en_US.UTF-8".
42ask_and_load_lang_set en_US.UTF-8
43
44### CHANGE THESE AS NEEDED ###
45img_name="2009-10-29-17-delld620"
46tgt_part=sda
47src_part=sdb2
48menu_title="Dell d620 Restore Disk"
49##############################
50
51action_restore() {
52mkdir -p $ocsroot
53if ! mountpoint $ocsroot &>/dev/null; then
54  part_fs="$(LANG=C ocs-get-part-info /dev/$src_part filesystem)"
55  case "$part_fs" in
56    ntfs) ntfs-3g /dev/$src_part $ocsroot ;;
57    *) mount /dev/$src_part $ocsroot ;;
58  esac
59fi
60if mountpoint $ocsroot &>/dev/null; then
61
62  # If you want to run it in batch mode, add option "-b" in the ocs-sr command
63  # 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"
65else
66  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
67  echo "Fail to mount /dev/$tgt_part as $ocsroot!"
68  echo "Program terminated!"
69  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
70fi
71umount $ocsroot &>/dev/null
72}
73
74##################
75
76###### MAIN ######
77##################
78
79# Find the device and partition
80
81TMP="$(mktemp /tmp/menu.XXXXXX)"
82trap "[ -f "$TMP" ] && rm -f $TMP" HUP INT QUIT TERM EXIT
83$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> $TMP
88mode="$(cat $TMP)"
89[ -f "$TMP" ] && rm -f $TMP
90
91case "$mode" in
92Restore)
93  action_restore;;
94*)
95  [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
96  echo "Program terminated!"
97  [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
98  exit 1
99esac
100```
101So now when the user boots off the USB key, they only see a single option to perform a restore off the USB key:
102
103[![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJxug3o84UsLyjBMleJpoajtFLdouWKTKBDsm9vVqbf6L7kqymVL-fufQmS3HTaDE_S4ENJrL1rPyd7aEQ8rPy4E8WDyrTU0ppSw_SxgCgrp5Ps6bTc8HxH_grHXTIFMG4kR8A1wiWlWE/s320/IMG_0119.JPG)](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJxug3o84UsLyjBMleJpoajtFLdouWKTKBDsm9vVqbf6L7kqymVL-fufQmS3HTaDE_S4ENJrL1rPyd7aEQ8rPy4E8WDyrTU0ppSw_SxgCgrp5Ps6bTc8HxH_grHXTIFMG4kR8A1wiWlWE/s1600-h/IMG_0119.JPG)
104
105
106