Clonezilla is a great tool to backup or restore any computer, it will use partimage to clone your real or virtual hard drive into an image or vice versa. It has available several protocols or options:

  • disk-to-disk (hard drive to hard drive, usb to hard drive, hard drive to usb, etc…)
  • SSH server
  • Samba Server
  • NFS Server (versions 3 and 4)
  • WebDAV Server
  • S3 Server (AWS S3 Server)
  • Swift Server

So you can restore or backup your whole disk to/from a distant repo or to local devices. Many people will remember Northon Ghost as an alternative but clonezilla is way better, is OpenSource and with more available options and languages.

One of the best things you could achieve with Clonezilla is to create a pendrive to do automatically all the process for you. You can have a pendrive which makes a backup automatically (without providing configuration options) or one for restoring the same way. Automating the restore/backup process is really easy and makes everything faster!

Creating the pendrive with the latest clonezilla image in Linux

I suggest using a pendrive with at least 8GB and creating two partitions on it. One for Clonezilla and the other to store the image to be restored. That would be something like:

  • /dev/sda -> Clonezilla
  • /dev/sdb -> Data (your image to be restored)
  1. Download the Clonezilla Live zip file.
  2. If you already have a FAT or NTFS partition on your USB flash drive then skip to the next step (3).
    1. Otherwise prepare at least a 300 MB partition formatted with either a FAT16/FAT32 or NTFS file system. (I recommend 300 MB and FAT32)
    2. If the USB flash drive or USB hard drive does not have any partition, you can use a partitioning tool (e.g. gparted, parted, fdisk, cfdisk or sfdisk) to create a partition with a size of 200 MB or more.
    3. Here we assume your USB flash drive or USB hard drive is /dev/sdd (You have to comfirm your device name, since it’s _NOT_ always /dev/sdd) on your GNU/Linux, so the partition table is like:
# fdisk -l /dev/sdd Disk /dev/sdd: 12.8 GB, 12884901888 bytes 15 heads, 
63 sectors/track, 26630 cylinders 
Units = cylinders of 945 * 512 = 483840 bytes 
Disk identifier: 0x000c2aa7 Device Boot Start End Blocks 
Id System /dev/sdd1 * 1 26630 12582643+ b W95 
FAT32
    1. Then format the partition as FAT with a command such as «mkfs.vfat -F 32 /dev/sdd1»
    2. WARNING! Executing the mkfs.vfat command on the wrong partition or device could cause your GNU/Linux not to boot. Be sure to confirm the command before you run it.
      1. # mkfs.vfat -F 32 /dev/sdd1 mkfs.vfat 2.11 (12 Mar 2005)
  1. Insert your USB flash drive or USB hard drive into the USB port on your Linux machine and wait a few seconds. Next, run the command «dmesg» to query the device name of the USB flash drive or USB hard drive. Let’s say, for example, that you find it is /dev/sdd1. In this example, we assume /dev/sdd1 has FAT filesystem, and it is automatically mounted in dir /media/usb/. If it’s not automatically mounted, manually mount it with commands such as «mkdir -p /media/usb; mount /dev/sdd1 /media/usb/».
  2. Unzip all the files and copy them into your USB flash drive or USB hard drive. You can do this with a command such as: «unzip clonezilla-live-2.4.2-32-i686-pae.zip -d /media/usb/»). Keep the directory architecture, for example, file «GPL» should be in the USB flash drive or USB hard drive’s top directory (e.g. /media/usb/GPL).
  3. To make your USB flash drive bootable, first change the working dir, e.g. «cd /media/usb/utils/linux», then run «bash makeboot.sh /dev/sdd1» (replace /dev/sdd1 with your USB flash drive device name), and follow the prompts.
    1. WARNING! Executing makeboot.sh with the wrong device name could cause your GNU/Linux not to boot. Be sure to confirm the command before you run it.
    2. NOTE: There is a known problem if you run makeboot.sh on Debian Etch, since the program utils/linux/syslinux does not work properly. Make sure you run it on newer GNU/Linux, such as Debian Lenny, Ubuntu 8.04, or Fedora 9.

TIP: If your USB flash drive or USB hard drive is not able to boot, check the following:

  • Ensure that your USB flash drive contains at least one FAT or NTFS partition.
  • Ensure that the partition is marked as «bootable» in the partition table.
  • Ensure that the partition starts on a cylinder boundary.
    • For the first partition this is usually sector 63.

Automating a pendrive to restore an image from it to a Hard Drive

I guess you have followed my suggestion of creating two partitions, one of 300MB with Clonezilla and the rest of your pendrive (at least 8GB) with EXT3 or EXT4 where your image to be restored in the hard drive will be.

Use your recently created pendrive and create an image (of your whole disk), then save it in the /dev/sdb2 partition.

From now on your hard disk will be identified by «/dev/sda» and your pendrive as «/dev/sdb1 (clonezilla) and /dev/sdb2 (your data)»

In your Clonezilla partition make a backup of the file:

vim syslinux/syslinux.cfg

And place this template that worked good for me:

# Created by generate-pxe-menu! Do NOT edit unless you know what you are doing!
# Keep those comment "MENU DEFAULT" and "MENU HIDE"! Do NOT remove them.
# Note!!! If "serial" directive exists, it must be the first directive

default vesamenu.c32
timeout 300
prompt 0
noescape 1
MENU MARGIN 5
 MENU BACKGROUND personalized_logo.png

# Set the color for unselected menu item and timeout message
 MENU COLOR UNSEL 7;32;41 #c0000090 #00000000
 MENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000
 MENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000
 MENU COLOR HELP 7;32;41 #c0000090 #00000000

# MENU MASTER PASSWD

say **********************************************************************
say Clonezilla, the OpenSource Clone System.
say NCHC Free Software Labs, Taiwan.
say clonezilla.org, clonezilla.nchc.org.tw
say THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
say **********************************************************************

# Allow client to edit the parameters
ALLOWOPTIONS 1
# simple menu title
MENU TITLE MORTIZ - Custom OS
label Clonezilla live
MENU DEFAULT
# MENU HIDE
MENU LABEL MORTIZ - Custom OS
# MENU PASSWD
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset noprompt ocs_prerun="mount /dev/sdb2 /home/partimag" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -scr -r -j2 -p poweroff restoredisk ask_user sda" ocs_live_extra_param="" keyboard-layouts=NONE ocs_live_batch="yes" locales=en_US.UTF-8 vga=788 ip= nosplash

TEXT HELP
* Clonezilla live version: 2.2.2-37-i686-pae. (C) 2003-2014, NCHC, Taiwan
* Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY

ENDTEXT

You should be careful, because there are two files for booting. One its for UEFI and the other for NON-UEFI (BIOS), modify the one for your needs.