Linux: Configure Clonezilla backups without a Live USB Stick

Taking a snapshot of your hard-disc or its partitions is the purest way to back them up. However, if the operating system (O/S) is in operation, then a backup snapshot will contain dynamic data and could easily end up corrupting the file system. To get the pure snapshot, the system should be complete shut down.

A conventional way to take that shut-down snapshot is to boot off of Live USB Stick with something like Clonezilla running. However, this often requires adjusting BIOS or UEFI boot-time parameters and then you have to have the USB stick ready to go.

Wouldn't it be nice if Clonezilla just lives on the hard-drive and a boot-time menu option allows the system to boot into a Clonezilla Live system without booting up the main Linux box??? Later, when Clonezilla (or whatever) updates to a new version, just update the Live ISO file and it's all ready to roll.

Here are the concepts:

  • Store the Clonezilla Live system as an ISO file within the usual Linux file system (we'll store it in the /srv/iso/ directory as clonezilla.iso.)
  • Adjust the Grub 2 boot menu to offer Clonezilla as a boot-time option.
  • When selected, find the /srv/iso/clonezilla.iso file, mount it as a boot disc, and boot from it.

Getting Clonezilla

Go out to the Clonezilla downloads web page and download the latest stable Clonezilla version. Store the file as /srv/iso/clonezilla.iso

If you know of a good wget snippet that will retrieve the latest stable version automatically, please submit it. Thank you.

Add a Clonezilla menu option to the Grub 2 boot menu

Now, the Grub boot loader has to locate and mount the Clonezilla ISO file that just got saved. To do this, you have to dig a bit deep and find out which partition it is in. Find out where the file lives by typing df -T /srv/iso/clonezilla.iso In the case of the example, it is on the first hard drive "hd0" in partition 3.

Put all of the following example into a file called /etc/grub.d/42_clonezilla


#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Clonezilla live" {
set root=(hd0,3)
set isofile="/srv/iso/clonezilla.iso"
loopback loop $isofile 
linux (loop)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts= ocs_live_batch=\"no\" locales= vga=788 ip=frommedia nosplash toram=live,syslinux,EFI findiso=$isofile
initrd (loop)/live/initrd.img
}
8 / 2020