HOWTO - Starting clonezilla in batchmode from local hard drive with a custom-ocs (automated backup of hard drive)

 

 

The goal of the game is to install a multiple boot system with GRUB, that gives the option to boot clonezilla live from hard drive in batch mode.

The taken backup will be saved on a samba share in the local network. After completion the system reboots.

In this example, debian lenny is installed in sda1, partion sda2 is used for swapping, sda3 and sda5 will home clonezilla.

 

The ãstep by stepÒ-guide:

 

  1. Prepare the hard drive
    1. Partition the hard drive. In my case I created two extra partitions. One partition /dev/sda3 for a boot into the interactive mode of clonezilla and a second one /dev/sda5 for the batch mode boot option. Like this:

 

                                          Disk Drive: /dev/sda                                         

                                    Size: 5368709120 bytes, 5368 MB                                    

                          Heads: 255   Sectors per Track: 63   Cylinders: 652                          

                                                                                                       

     Name           Flags          Part Type     FS Type               [Label]            Size (MB)     

 ------------------------------------------------------------------------------------------------------

     sda1           Boot            Primary      Linux ext3                                 3002,23    

     sda2                           Primary      Linux swap / Solaris                       1003,49    

     sda3                           Primary      Linux ext3                                  501,75    

     sda5                           Logical      Linux ext3                                  855,43

 

    1. mkfs.ext3 /dev/sda3
    2. mkfs.ext3 /dev/sda5
    3. mount /dev/sda3 /mnt
    4. cd /mnt
  1. Install clonezilla live in sda3; unzip and rename a directory ãliveÒ
    1. Download your preferred Clonezilla-ZIP-file for the hard drive installation from http://clonezilla.org/clonezilla-live/liveusb.php and put it in /mnt .
    2. cd /mnt
    3. unzip clonezilla-live-x.x.x.zip –d .
    4. mv live live-hd
  2. Edit GRUB boot menu in ã/boot/grub/menu.lstÒ for two more boot options:
    1. Add a section in the end of menu.lst for booting the interactive mode:

 

 

 

 

title           Clonezilla live on harddrive sda3 Jaunty

root            (hd0,2)

kernel /live-hd/vmlinuz1 boot=live union=aufs live-media-path=/live-hd vga=788 toram bootfrom=/dev/sda3 vga=791

initrd /live-hd/initrd1.img

boot

 

    1. Add a second section like the following for booting the batch mode:

 

title           Clonezilla live batch on harddrive sda5

root            (hd0,4)

kernel /live-hd/vmlinuz1 boot=live union=aufs live-media-path=/live-hd vga=788 toram bootfrom=/dev/sda5 noprompt noprompt ocs_live_run="custom-ocs" ocs_live_extra_param="" ocs_live_keymap="/usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 nolocales

initrd /live-hd/initrd1.img

boot

 

 

 

  1. Boot ãinteractive ClonezillaÒ by GRUB; generate a customized zip of clonezilla live
    1. Reboot. Choose the interactive clonezilla mode in GRUB.
    2. Choose your language and keyboardmapping, enter the clonezilla shell.
    3. Become root with ãsudo suÒ.
    4. ãmount /dev/sda5 /home/partimagÒ ; ãcd /home/partimagÒ.
    5. Download the clonezilla iso-image (stable, testing or experimental) from http://clonezilla.org/download/sourceforge/ and put it to ã/home/partimagÒ
    6. touch custom-ocs-1
    7. Put he following lines in custom-ocs-1 and change it to your needs:

#!/bin/bash

# Author: Steven Shiau <steven _at_ stevenshiau org>

# License: GPL

# When this script is ready, you can run

# /opt/drbl/sbin/ocs-iso -g en -k NONE -s -m ./custom-ocs

# to create the iso file for CD/DVD. or

# /opt/drbl/sbin/ocs-live-dev -g en -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

if [ ! -f "/opt/drbl/sbin/drbl-conf-functions" ]; then

  echo "Unable to find /opt/drbl/sbin/drbl-conf-functions! Program terminated!"

  exit 1

fi

. /opt/drbl/sbin/drbl-conf-functions

. /opt/drbl/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". For Traditional Chinese, use "zh_TW.UTF-8"

ask_and_load_lang_set en_US.UTF-8

# The above is almost necessary, it is recommended to include them in your own custom-ocs.

# From here, you can write your own scripts.

echo "#########################################################################################"

echo "# 1. Configure network"

dhclient

echo "#########################################################################################"

echo "# 2. Mount the clonezilla image home"

mkdir /home/partimag

mount -t cifs -o username=user01,password=passw0rd //servername/archiv /home/partimag

echo "#######################################after mounting, now showing mounts###########"

mount

echo "#########################################################################################"

echo "# 3. backing up sda3 "

/opt/drbl/sbin/ocs-sr -b -q -j2 -z1 -i 0 -p reboot savedisk "IMAGE" "sda"

echo "#########################################################################################"

 

    1. Execute the ocs-live-dev command in working dir /home/partimag, like this:

 

ocs-live-dev -g en_US.UTF-8 -k /usr/share/keymaps/i386/qwertz/de-latin1-nodeadkeys.kmap.gz -j ./clonezilla-live-1.2.1-39.iso -x noprompt -t -s -c -m ./custom-ocs-1

 

Creating clonezilla Live without any clonezilla image embedded...

The output file name is: clonezilla-live-20090222.zip.

Estimated necessary space size in target dev: 96 MB

Copying the system files to working dir... This might take a few minutes... done!

Copying kernel, initrd, etc...

Trying to find the boot params from template live cd...

Adding syslinux menus for Clonezilla live...

Preparing syslinux.exe, syslinux, makeboot.bat and makeboot.sh...

Downloading http://free.nchc.org.tw/syslinux/syslinux-3.72.tar.bz2...

Extracting files...

syslinux-3.72/linux/syslinux

syslinux-3.72/win32/syslinux.exe

syslinux-3.72/mbr/mbr.bin

  adding: Clonezilla-Live-Version (stored 0%)

  adding: COPYING (stored 0%)

  adding: home/ (stored 0%)

  adding: home/partimag/ (stored 0%)

  adding: live/ (stored 0%)

  .

  .

  .

 adding: utils/mbr/ (stored 0%)

  adding: utils/mbr/mbr.bin (stored 0%)

The created release file is clonezilla-live-20090222.zip. You can extract all the files into your pendrive, and run makeboot.bat from pendrive in MS windows.

Warning: DO NOT RUN makeboot.bat from your local hard drive!! It is intended to be run from your USB device.

Cleaning tmp dirs...

Done!

 

  1. Extract the generated zip file in /home/partimag & reboot:
    1. cd /home/partimag
    2. unzip clonezilla-live-xxxxxx.zip –d .
    3. mv live live-hd
    4. reboot
  2. Reboot. Choose the GRUB entry for clonezilla batch mode

 

Screenshot of the batch mode while saving sda3.