Thursday 5 December 2013

Disk Imaging using a Clonezilla ISO file on an Easy2Boot USB Hard Drive

By adding the Clonezilla ISO to your large E2B USB bootable hard drive plus a .mnu file, you can easily create and restore complete hard disk images. Clonezilla can be scripted so that you can define the location of the backup images and the disk to be operated on (i.e. backed-up or restored).

Tutorial 118 describes how to add these options to your E2B menu:


The E2B menu is hard-coded to use '/dev/sda' as the target drive. This means that when you boot from the E2B USB drive, you must ensure that sda is the drive that you want to backup or restore. All backup images are placed in the /clonezilla folder on the E2B USB drive.
Also, E2B assumes that the last linux drive is the E2B USB drive where the /clonezilla image backups are kept. E2B tries to guess at the linux drive designation of the E2B drive, but again you need to double-check this before you confirm the operation.

If you wish you can run the ISO manually and choose your own options.

So add the ISO and .mnu file to your 1TB E2B USB Hard disk and try it out on a test system (but be careful when restoring!).

Disclaimer: please don't blame me if you accidentally wipe your system hard disk when restoring an image or wipe your USB E2B drive - Clonezilla is a powerful tool!

Any comments welcome.

Here is the .mnu file (you can download it from the Tutorial), it is also included in the latest version of E2B in the \_ISO\docs\Sample mnu files folder.

# Note: This menu is for Easy2Boot USB drives which have an unused 4th partition entry - the partnew command used in the grub4dos menu below will erase the 4th partition on the USB boot drive.

# Make a \_ISO\BACKUP\Clonezilla folder and copy clonezilla-live-20131125-saucy-i386.iso and this file to it
# Make and empty \clonezilla folder on your E2B drive (note all lower case letters!)
# If you want the menu to appear in the Main E2B menu - use a \_ISO\MAINMENU\clonezilla folder instead.

title Create Backup Image of first Hard Disk (Clonezilla)\n Make an image backup of your internal hard disk
set ISO=%MFOLDER%/Clonezilla/clonezilla-live-20131125-saucy-i386.iso
set WDRV=sda
# Backup drive is always last drive
set /a HDCNT=*0x475 & 0xff
set /A BAKDRV=%HDCNT%+0x60
echo %BAKDRV:~1,9% | set dlet=
echo -e sd\%dlet%1 | set BAKDRV=
echo BACKUP DRIVE
echo -e ============
echo
echo BACKUP IMAGES will be placed in clonezilla folder on $[010f]%BAKDRV%
set /p ask=Press ENTER if OK or specify the linux name of the USB partition (e.g. %BAKDRV%) : 
echo
echo
if not "%ask%"=="" set BAKDRV=%ask%
set ask=
echo The drive to be backed up will be $[010f]%WDRV%
set /p ask=Press ENTER if OK or specify the linux name of the target drive (e.g. %WDRV%) : 
echo
if not "%ask%"=="" set WDRV=%ask%
echo
echo You can check the drive names once CloneZilla has booted.
echo -e When Clonezilla starts, select <Cancel>
echo Then choose 'cmd' to get to the command prompt
echo Then type    sudo fdisk -l            to show all the drives in the system
echo or   type    sudo fdisk -l /dev/sdb   to show drive sdb parameters
echo
echo $[010f]%BAKDRV% WILL CONTAIN THE IMAGE FILES
echo $[010f]%WDRV%  WILL BE THE DRIVE TO BE BACKED UP
echo
set /p ask=Press Y to continue (Y/N) : 
if not /I "%ask%"=="Y" configfile (md)0xa000+0x50
echo
set ask=
set HDCNT=
set dlet=
partnew (hd0,3) 0x00 %ISO%
map %ISO% (0xff)
map --hook
set BOPT=boot=live quiet live-config noswap nolocales edd=on nomodeset ip=frommedia ocs_live_keymap="NONE" splash
set RUN=ocs_live_run="ocs-live-general" keyboard-layouts="NONE" locales="en_US.UTF-8" live-media-path=/live toram=filesystem.squashfs ocs_live_batch="yes" 
set PRERUN=ocs_prerun="mount /dev/%BAKDRV% /mnt" ocs_prerun1="mount --bind /mnt/clonezilla /home/partimag/"
set RUN1=ocs_live_run="ocs-sr -q2 -c --batch -j2 -z1p -i 2000 -sc -p true savedisk ask_user %WDRV%"
#echo kernel /clonezilla/live/vmlinuz %BOPT% %RUN% %PRERUN% %RUN1%
#pause
root (0xff)
kernel /live/vmlinuz %BOPT% %RUN% %PRERUN% %RUN1%
initrd /live/initrd.img


title Restore a Disk Image to first Hard Disk (Clonezilla)\n Restores all partitions from an image.\n WARNING: THIS DESTROYS ALL PARTITIONS and FILES!
set ISO=%MFOLDER%/Clonezilla/clonezilla-live-20131125-saucy-i386.iso
set WDRV=sda
# Backup drive is always last drive
set /a HDCNT=*0x475 & 0xff
set /A BAKDRV=%HDCNT%+0x60
echo %BAKDRV:~1,9% | set dlet=
echo -e sd\%dlet%1 | set BAKDRV=
echo RESTORE DRIVE
echo -e =============
echo
echo IMAGE FILES will be looked for in the clonezilla folder on $[010f]%BAKDRV%
set /p ask=Press ENTER if OK or specify the linux name of the USB partition (e.g. %BAKDRV%) : 
echo
echo
if not "%ask%"=="" set BAKDRV=%ask%
set ask=
echo The drive to be written to (all partitions) will be $[010f]%WDRV%
set /p ask=Press ENTER if OK or specify the linux name of the target drive (e.g. %WDRV%) : 
echo
if not "%ask%"=="" set WDRV=%ask%
echo
echo You can check the drive names once CloneZilla has booted.
echo -e When Clonezilla starts, select <Cancel>
echo Then choose 'cmd' to get to the command prompt
echo Then type    sudo fdisk -l            to show all the drives in the system
echo or   type    sudo fdisk -l /dev/sdb   to show drive sdb parameters
echo
echo $[010f]%BAKDRV% WILL CONTAIN THE IMAGE FILES
echo $[010f]%WDRV%  WILL BE THE DRIVE TO BE RESTORED (all drive contents will be destroyed)
echo
echo $[010f]PLEASE NOTE: All partitions on drive %WDRV% will be destroyed.
echo
set /p ask=Press Y to continue (Y/N) : 
if not /I "%ask%"=="Y" configfile (md)0xa000+0x50
echo
set ask=
set HDCNT=
set dlet=
partnew (hd0,3) 0x00 %ISO%
map %ISO% (0xff)
map --hook
set BOPT=boot=live quiet live-config noswap nolocales edd=on nomodeset ip=frommedia ocs_live_keymap="NONE" splash
set RUN=ocs_live_run="ocs-live-general" keyboard-layouts="NONE" locales="en_US.UTF-8" live-media-path=/live toram=filesystem.squashfs ocs_live_batch="yes" 
set PRERUN=ocs_prerun="mount /dev/%BAKDRV% /mnt" ocs_prerun1="mount --bind /mnt/clonezilla /home/partimag/"
set RUN1=ocs_live_run="ocs-sr -c --batch -g auto -e1 auto -e2 -j2    -p true restoredisk ask_user %WDRV%"
#echo kernel /clonezilla/live/vmlinuz %BOPT% %RUN% %PRERUN% %RUN1%
#pause
root (0xff)
kernel /live/vmlinuz %BOPT% %RUN% %PRERUN% %RUN1%
initrd /live/initrd.img

title CloneZilla (boot directly from the ISO file)\n Boot from the ISO for advanced options
set ISO=%MFOLDER%/Clonezilla/clonezilla-live-20131125-saucy-i386.iso
partnew (hd0,3) 0x00 %ISO%
map %ISO% (0xff)
map --hook
root (0xff)
chainloader (0xff)

P.S. I am really excited this Christmas - I saw an advert on the TV last week asking people to 'adopt a Snow Leopard' - so I immediately subscribed. I have just had a large cat flap knocked through the conservatory wall and can't wait for it to arrive... I hope it's house trained!

No comments:

Post a Comment