Intro [^]
The DRBL-based PXEBoot Clonezilla is used to clone many computers simultaneously. It is an extremely useful tool, however, it does have several limitations. In order to use it, you must first prepare a DRBL server AND the machine to be cloned must boot from a network (e.g. PXE/Etherboot).
To address these limitations, the Free Software Lab at the NCHC has combined Debian Live with Clonezilla to produce "Clonezilla Live", a new software that can be used to easily clone individual machines.
Clonezilla Live provides two modes of operation:
- device-image
In this mode of operation, a disk/partition can be saved to an image file. This image file can be used to restore the original disk/partition. With Clonezilla-SysRescCD, it can also be used to create an automated restore CD/DVD. This is the mode of operation we will discuss here. - device-device (cloning)
This mode of operation creates an exact copy of the original disk/partition on the fly.
When working in device-image mode, you will always have to specify three things:
- The location of the image file
- The working parameters for the operation
- The disk/partition that will be saved/restored
Clonezilla Live provides a user friendly interface in order to insert this data.
When Clonezilla Live is booted up, either normally or copied to RAM, the contents of the whole CD/DVD can be found in folder /live/image. This is where you will find any extra files, such as the restorecd and the doc folders.
Starting and stopping Clonezilla Live [^]
When you boot into Clonezilla Live, the program (actually a script) starts automatically. There are many places where you can stop it, by selecting Cancel or answering N(o) to a question. When you do that you will probably get the following:
Now you can choose to:
(0) Poweroff
(1) Reboot
(2) Enter command line prompt
(3) Start over
[2]
Select Poweroff or Reboot, only if you haven't already mounted a disk partition. I found out by experience, it is not always safe to let any live CD automatically unmount my partitions. So if you have already specified the image partition and/or the partition to save/restore, you should enter command line prompt and type:
sudo su -
mount | grep /dev/[sh]d
and then unmount the partitions shown by the last command. So if the results of this command is for example:
/dev/hda1 on /home/partimag type vfat (rw)
just type the command:
umount /dev/hda1
and it's now safe to Poweroff of Reboot.
If, on the other hand, you just want to restart the program, type:
ocs-live
About the Image file [^]
One thing should be made clear about the image file: it is not a file, it is a folder, containing the actual image file and some data about the disk/partition it is associated with. So when you insert the image file name, you actually insert the folder name where the image will be saved/restored.
Before you are able to insert the image file name, a list of partitions will be presented to you, so that you can choose where it should be saved/found. When you select one of them, it will be mounted and a list of folders will be presented to you, so you can select the base image directory (first level directory within the partition), which will then be mounted under /home/partimag. This way you can, for example, create a folder called all_my_images in one of your disk partitions, and move all your image files in there; Clonezilla Live will be able to find them!!!
Another thing that should be pointed out is that only unmounted partitions will be included in the above list. This means that if you have stopped the program at some point after specifying the partition where the image file resides, and it has been mounted, it will not be present in the list the next time it is presented to you, and you will not be able to use it.
There are two things you can do in this case; either unmount the partition, as stated above, or select
skip Use existing /home/partimag
instead of any other option, when you restart the program. The later of course means that you still want to use the previously specified partition as the image file location.
Fianlly I should say that Clonezilla Live is able to use a remote disk/partition as the location of the image file, mounted through ssh, samba or nfs. Using any of these options is a more advanced topic, way beyond the scope of this presentation.
Scripts' options [^]
This section presents the options which are available at the "Clonezilla advanced extra parameters" screens, if the "Expert" mode is selected. For other options, see Getting backups and Restoring data.
Backup options [^]
Imaging program priority [^]
-q2 Priority: partclone > partimage > dd
-q1 Priority: Only dd (supports all filesystem, but inefficient)
-q Priority: ntfsclone > partimage > dd
Priority: partimage > dd (no ntfsclone)
This option chooses which imaging programs are preferred. By default, Clonezilla Live uses partclone for nearly all filesystems, including ext2/3/4, NTFS and FAT32. If a filesystem isn't supported by partclone, but is supported by partimage (spesifically: if the filesystem is HFS, HPFS or JFS), it is cloned by partimage. If it isn't supported by either (for example Linux swap, though it doesn't make any sense to clone swap partitions), it is cloned by dd. Unlike partclone or partimage, dd copies all blocks of the partition instead of only used, resulting in slower imaging process and bigger images.
Normally the default option -q2 should be preferred. Try another option if you have problems and believe they are caused by the imaging program used.
Various parameters [^]
These options are available at the second "Clonezilla advanced extra parameters" screen.
-c Client waits for confirmation before cloning
This option causes Clonezilla Live to ask if you really want to clone the disk/partition just before it starts cloning. It is enabled by default.
-j2 Clone the hidden data between MBR and 1st partition
If this option is set, the 15 hidden sectors between Master Boot Record and the first partition are copied. This area usually contains some data necessary for booting. The option is enabled by default and should be kept enabled if you are cloning a bootable disk.
-nogui Use text output only, no TUI/GUI output
Causes Clonezilla Live to force the used programs to use only command-line interface even if text-based or graphical user interface is available.
-a Do NOT force to turn on HD DMA
Prevents Clonezilla Live from using DMA for communicating with hard drives. Slows cloning down but in some conditions cloning without this option can be impossible.
-rm-win-swap-hib Remove page and hibernation files in Win if exists
This option prevents Clonezilla Live from cloning your page file if you are cloning a partition containing Windows. Often the page file is big and unneeded, and skipping it may speed cloning up without causing any harm. Mind you, this option is disabled by default because sometimes the page file may be necessary.
-ntfs-ok Skip checking NTFS integrity, even bad sectors (ntfsclone only)
This option works only if you selected the -q option and you're cloning a NTFS partition. It prevents the integrity check of NTFS partitions and speeds the cloning process up a little. However, if the check is disabled, there is a risk that the filesystem is damaged and the image created from it is useless.
-rescue Continue reading next one when disk blocks read errors
If this option is set, Clonezilla Live continues cloning even if a read error occurs. If there is one, the disk image will be corrupted, but failing hard drives can only be cloned with this option enabled.
-fsck-src-part Check and repair source file system before saving
This option causes Clonezilla Live to check the integrity of the partition(s) to be cloned. If the filesystem of the partition is damaged, Clonezilla Live also attempts to repair it automatically. Enabling this option reduces the risk that the image contains a damaged filesystem. However, the option is disabled by default because the automatic filesystem repair attempt may cause data loss.
-gm Generate image MD5 checksums
Causes Clonezilla Live to calculate MD5 checksum(s) of image(s) created. If the image gets corrupted afterwards, the checksum allows to notice the corruption before the image is restored. Mind you, calculating the checksum takes some time and slows the process down a little.
-gs Generate image SHA1 checksums
This option is identical to the above, but creates SHA1 checksum(s) instead of MD5. SHA1 is considered to be more accurate checksum algorithm than MD5, but MD5 is more popular.
Compression method [^]
-z1p Use parallel gzip compression (testing), for multicore/CPU
-z1 gzip compression (fast with a smaller image)
-z2p Use parallel bzip2 compression (testing), for multicore/CPU
-z2 bzip2 compression (slowest but smallest image)
-z3 lzo compression (faster with image size approx. to that of gzip)(NOTE!!)
-z4 lzma_compression_(slowest_but_also_small_image,_faster_decompression_than_bzip2)
-z5p Use_parallel_xz_compression_(testing),_for_multicore/CPU
-z5 xz_compression_(slowest_but_also_small_image,_faster_decompression_than_bzip2)
-z6p Use_parallel_lzip_compression_(testing),_for_multicore/CPU
-z6 lzip_compression_(slowest_but_also_small_image,_faster_decompression_than_bzip2)
-z0 No compression (fastest but largest image size)
This option chooses the method which is used to compress the image while creating it.
If no compression is used at all, there won't be any negative speed impact caused by compression. However, the image file size is the size of all the data backed up - for example, if you clone a 160 GB hard drive containing 60 gigabytes of data, the resulting disk image will be 60 gigabytes in size.
Gzip and lzop are fast compression methods. Lzop is many times faster than gzip, but creates slightly larger images. Clonezilla Live warns that lzop requires good-quality RAM, but I (the contributor who wrote this chapter) think other compression methods require good RAM too.
Bzip2, lzma, xz and lzip are powerful compression methods. Lzma creates a little smaller images than bzip2, and decompressing lzma-compressed images is faster than decompressing bzip2 images. But there is no free lunch: lzma compression method is very slow compared even to bzip2, which isn't fast method either.
Lzma method is becoming obsolete, and both xz and lzip are attempting to become its successor. They are a bit less powerful compression methods than lzma, but much faster. The differences between xz and lzip are virtually non-existent.
If you don't use the i486 version of Clonezilla-SysRescCD and your processor contains multiple cores and/or supports Hyper-Threading, parallel gzip, bzip2, xz and lzip compression methods are also available. Parallel compression means that each processor core compresses a different part of the image at a time. Without parallel compression one core compresses everything.
The speed impact caused by parallel compression depends on the number of processor cores available. In addition, Hyper-Threading increases the speed by about 30 % if parallel compression is used. For example, if your processor contains four cores and supports Hyper-Threading, speed with parallel compression is nearly 5,2 times as high as without. However, parallel compression is currently an experimental feature.
Splitting [^]
This option (command line: -i [number]) decides if the created image files are splitted into smaller pieces, and if yes, how large the pieces are. This setting doesn't usually matter, but some filesystems (most importantly FAT32) don't allow files larger than four gigabytes. If you're saving the disk image to a FAT32 partition, enter 4000 or less. (Value 0 disables splitting, so don't use it in that case.) If the filesystem allows files big enough, enter any value which isn't too small (you don't want to split the image into too many pieces, do you?)
Clonezilla Live warns that it is no longer safe to disable splitting because value 0 can confuse init. I (the contributor) don't know what the warning exactly means and haven't been able to reproduce the problem. Anyway, entering a very big value, for example 999999999999, is a safe way to keep the image in one piece.
Postaction [^]
-p true Do nothing when the clone finishes
-p reboot Reboot client when the clone finishes
-p poweroff Shutdown client when the clone finishes
In this screen you can decide what Clonezilla Live does when the disk/partition is cloned.
Spiros told above that he has found out that it's not always safe to allow Live CDs automatically unmount partitions, and I have lost data when trying auto-unmount with a script. So, avoid -p reboot and -p poweroff options if possible. You have been warned.
Restore options (script ocs-sr) [^]
Various parameters [^]
These options are available at the first "Clonezilla advanced extra parameters" screen.
-g auto Reinstall grub in client disk MBR (only if grub config exists)
Causes Clonezilla Live to reinstall GRUB into the Master Boot Record of the disk if at least one partition contains GRUB config file (/boot/grub/menu.lst). The option is enabled by default and shouldn't cause any harm. However, it should be disabled if you for example have another bootloader in MBR and chainload GRUB with it.
-e1 auto Automatically adjust filesystem geometry for a NTFS boot partition if exists
The NTLDR bootloader used by Windows isn't able to determine automatically where the files it needs are stored. It only knows their physical locations, which sometimes change when the disk or partition is copied. If the locations are changed and this option is selected, the location information of the files is changed accordingly. This option is enabled by default and if it's disabled, the cloned Windows will fail to boot.
-e2 sfdisk uses CHS of hard drive from EDD(for non-grub boot loader)
This option requires that the -e1 auto option is selected. It causes Clonezilla Live to use disk read interface named EDD for determining the physical locations of the files when updating the location information used by NTLDR. The option is enabled by default because it reduces the risk that Windows doesn't boot.
-hn0 PC Change MS Win hostname (based on IP address) after clone
If this option is selected and a partition containing Microsoft Windows is cloned, its IP address -based hostname is changed after cloning. Computers which are on any network simultaneously need to have different hostnames, so this option is needed if a Windows system is cloned to another computer and the original computer is still used in addition to the one where the image was restored to.
-hn1 PC Change MS Win hostname (based on MAC address) after clone
This option causes the MAC address -based hostname of Windows to change. This option needs also be enabled in the above condition.
-v Prints verbose messages (especially for udpcast)
Causes Clonezilla Live to tell more information of what it does.
-nogui Use text output only, no TUI/GUI output
Causes Clonezilla Live to force the used programs to use only command-line interface even if text-based or graphical user interface is available.
-b Run clone in batch mode (DANGEROUS!)
Causes Clonezilla Live to run in batch mode. According to Clonezilla Live reference card, this option is dangerous, though I (the contributor) don't know why.
-c Client waits for confirmation before cloning
This option causes Clonezilla Live to ask if you really want to clone the disk/partition just before it starts cloning. It is enabled by default.
-t Client does not restore the MBR (Mater Boot Record)
Do NOT restore the MBR (Mater Boot Record) when restoring image. If this option is set, you must make sure there is an existing MBR in the current restored harddisk. Default is Yes.
-t1 Client restores the prebuilt MBR from syslinux (For Windows only)
If this option is set, the MBR is overwritten by prebuilt one which chainloads Windows. Use this option if you have to restore Windows and make it bootable, but don't have the original MBR or backup of it.
-r Try to resize the filesystem to fit partition size
This option is useful if you are cloning a small disk to larger one. It tries to resize the restored filesystem to the size of the partition where it was restored to. It allows you to use the whole size of your new disk without resizing the partition afterwards. The option requires that the disk where the image is copied to already contains a partition where the image is restored or that the option -k1 is enabled.
-e sfdisk uses the CHS value of hard drive from the saved image
Force to use the saved CHS (cylinders, heads, sectors) when using sfdisk. Of cource, there is no use of it when using any of -j0, -k or -k2 options.
-icrc Ignore CRC checking of partclone
This option causes partclone to skip checking the CRC32 checksums of the image. Enabling this option speeds the restore process up. However, if this option is enabled and the -cm and -cs options are disabled, there is no way to notice if the image has corrupted.
-j1 Write MBR (512 B) again after image is restored. Not OK for partition table diffe
When a disk image is restored, the partition table must be updated to reflect the actual partitions in the disk. If you don't want it to happen, enable this option. Then the Master Boot Record (including the partition table) is restored again after restoring the image. Note that using this option can destroy all the data in the target drive.
-j2 Clone the hidden data between MBR and 1st partition
If this option is set, the 15 hidden sectors between Master Boot Record and the first partition are restored. This area usually contains some data necessary for booting. The option is enabled by default and should be kept enabled if you are cloning a bootable disk.
-cm Check image by MD5 checksums
If the image folder contains MD5 checksum(s), this option causes Clonezilla Live to check if the image has corrupted by calculating its checksum and comparing it to the precalculated one. Mind you, calculating the checksum takes some time and slows the process down a little.
-cs Check image by SHA1 checksums
This option is identical to the above, but checks SHA1 checksum(s) instead of MD5.
-a Do NOT force to turn on HD DMA
Prevents Clonezilla Live from using DMA for communicating with hard drives. Slows cloning down but in some conditions cloning without this option can be impossible.
-o0 Run script in $OCS_PRERUN_DIR before clone starts
Run the scripts in the directory $OCS_PRERUN_DIR before clone is started. The location of the directory can be determined by editing the file drbl-ocs.conf. By default it is /opt/drbl/share/ocs/prerun.
-o1 Run script in $OCS_POSTRUN_DIR as clone finishes
Run the scripts in the directory $OCS_POSTRUN_DIR when clone is finished. The location of the directory can be determined by editing the file drbl-ocs.conf. By default it is /opt/drbl/share/ocs/postrun. The command will be run before that assigned in -p.
The scripts will be executed by the program "run-parts". run-parts only accepts that the name of the scripts must consist entirely of upper and lower case letters, digits and underscores. So if your file name has an illegal character ".", run-parts won't run it. You can test which files will be executed by entering the command:
run-parts --test /opt/drbl/share/ocs/postrun
Partition table [^]
This option decides what is done to the partition table of the target drive.
Use the partition table from the image
This option causes Clonezilla Live to copy the partition table from the image. Use this option if you are cloning a whole disk or somehow know that the partition tables are identical (for example, if you are restoring a partition to the same disk where it was copied from and haven't repartitioned the drive after creating the backup). This is the default option.
-k Do NOT create a partition table on the target disk
Do NOT create partition in target harddisk. If this option is set, you must make sure there is an existing partition table in the current restored harddisk.
-k1 Create partition table proportionally (OK for MRB format, not GPT)
Causes Clonezilla Live to create the partition table automatically using sfdisk after restoring the images. This option works nearly always, but sometimes cloned Windows don't boot. Note that this option doesn't work if you have GUID Partition Table on your disk. (Most likely you don't have one.)
-k2 Enter command line prompt to create partition manually later
Like the -k option, this option doesn't create the partition table automatically. However, after restoring the image you are led to command line prompt where you can create the partition table manually. Don't use this option if you don't know how the partition table can be created.
-j0 Use dd to create partition (NOT OK if logical drives exist)
Use dd to dump the partition table from saved image instead of sfdisk.
We read in DRBL FAQ/Q&A:
When I use clonezilla to clone M$ windows, there is no any problem when saving an image from template machine. However, after the image is restored to another machine, it fails to boot, the error message is "Missing Operating System". What's going on ?
Usually this is because GNU/Linux and M$ windows interpret the CHS (cylinder, head, sector) value of harddrive differently. Some possible solutions:
1. Maybe you can change the IDE harddrive setting in BIOS, try to use LBA instead of auto mode.
2. Try to choose
[ ] -j0 Use dd to create partition table instead of sfdisk
and
[ ] -t1 Client restores the prebuilt MBR from syslinux (For Windows only)
when you restore the image.
3. You can try to boot the machine with MS Windows 9x bootable floppy, and in the DOS command prompt, run: "fdisk /mbr".
4. You can try to boot the machine with MS Windows XP installation CD, enter recovery mode (by pressing F10 key in MS XP, for example), then in the console, run "fixmbr" to fix it. Maybe another command "fixboot" will help, too. For more info, refer to this doc
5. Use ntfsreloc to adjust FS geometry on NTFS partitions. For more info, refer to http://www.linux-ntfs.org/doku.php?id=contrib:ntfsreloc
It has been confirmed that activating the -j0 option, fixes the problem.
This option doesn't work if you use LVM (Logical Volume Manager).
This option ends the restore process and enters command line prompt.
Postaction [^]
-p true Do nothing when the clone finishes
-p reboot Reboot client when the clone finishes
-p poweroff Shutdown client when the clone finishes
When image restoration finishes, do one of the following: choose action (default), poweroff or reboot.
Saving image files in NTFS partitions [^]
Although not recomended, you may find yourself having to save your image file in a NTFS (Windows XP) partition. You may never have a problem doing this, but you may get a message like the following one, when the partition gets mounted:
Volume is scheduled for check
Please boot into Windows TWICE, or use 'force' mount option"
and the backup procedure fails. There are two things you can do here:
Exit the program, reboot and use Windows XP Recovery Console to fix the NTFS file system. From Recovery Console prompt, execute the command:
chkdsk /f X:
where X: is the drive letter of the disk. When done, boot back into Clonezilla Live and repeat the backup procedure.
If the disk/partition you are trying to backup is not the Windows System disk (usually C:), you can boot Windows, and execute the command in a DOS window. To open a DOS window click Start / Run... and at the prompt Open: type cmd.
If Windows XP Recovery Console is not available, you don't have the time to execute the procedure described above, or even if you have executed it but you still get the same message, and you are absolutely sure that you get this message because the NTFS partition is really scheduled for check, and it's not because Windows crushed or have become corrupt, you can mount the patririon by hand and tell Clonezilla Live to use it. Assuming the partition is /dev/hda1, exit the program and execute the commands:
sudo su -
ntfs-3g -o force /dev/hda1 /home/partimag
ocs-liveand when you get to the screen "Mount clonezilla image directory", select
skip Use existing /home/partimag
If the Windows version you use is not XP and you're trying to backup the Windows System drive, boot into SystemRescueCD (graphical mode is not needed) and run the following command:
ntfsfix /dev/hda1
where /dev/hda1 is the partition name in GNU/Linux. When done, boot back into Clonezilla Live and repeat the backup procedure.