Clonezilla Live, legacy BIOS and UEFI USB boot

Posted by Sven Kiljan on

Summary

Clonezilla Live is a wonderful GNU/Linux distribution which allows you to easily backup and restore images of disks. For the old-timers, think of a open source version of Norton/Symantec Ghost. All kinds of operating systems can be easily backed up ('imaged') and restored. It can do this for systems that boot using a legacy BIOS and for systems that boot using UEFI.

A limitation of Clonezilla Live's installation instructions for USB is that it instructs on creating a bootable USB medium that only boots on either legacy BIOS or UEFI systems. With a bit of effort it is possible to create a USB medium that can boot both systems, and of which its excess storage can be used for storing Clonezilla images.

This post outlines the steps needed to prepare a USB medium. It assumes that an Arch Linux system is used, but should be usable with any modern Linux distribution. Note that the prepared USB medium can also be read from and written to in Windows, and Clonezilla Live upgrades can also be done in Windows.

Prepare USB medium

A USB mass storage device (hard drive, solid state drive or flash drive) is necessary. It needs at least 512 MB of storage space for Clonezilla Live. Any other available space will be usable for images made with Clonezilla Live.

Note that all data on the USB mass storage device (MSD) will be destroyed. Be careful that you reference the correct block device. In this tutorial /dev/sdX will be used as the name of the block device that represents the USB MSD.

Partition

For this the util-linux and gptfdisk packages are required.

Run the following commands:

sgdisk \
  --clear \
  --new=1:0:+512M \
  --typecode=1:ef00 \
  --new=2:0:0 \
  --typecode=2:0700 \
  --hybrid=1:2 \
  /dev/sdX
echo -ne "M\na\n2\nw\nM\nq\n" | fdisk /dev/sdX

The first command creates a GPT partition table and a MBR partition table. The former is needed for UEFI systems that are not equipped with a Compatibility Support Module, and the latter is needed for legacy BIOS systems. This command also creates two partitions. The first partition is 512 MB and will be used to store Clonezilla Live. Its type ('ef00', EFI System) ensures that an UEFI system will look for boot files on this partition. The second partition takes up the rest of the space and will be used to store and load images from.

The second command makes the partition which will have Clonezilla Live the active partition in the MBR, which is required for the MBR boot loader to find the volume boot record of the partition. The volume boot record will contain Syslinux, which loads and starts Clonezilla Live.

Format

Format the two partitions:

mkfs.vfat -F 32 /dev/sdX1
mkfs.exfat /dev/sdX2

The first partition will be formatted as FAT32. This is a file system supported by both the boot loader used for legacy boot and directly by UEFI systems, which need to load Clonezilla Live from it.

The second partition is formatted as exFAT, which is a lightweight file system supported for reading and writing by all modern operating systems. It is used instead of FAT32 since it lacks some of its limitations, such as a file size limit of 4 GiB.

Download and extract Clonezilla Live

Make sure to download a ZIP archive of Clonezilla Live from here. Then run:

mount /dev/sdX1 /mnt
cd /mnt
unzip <ClonezillaLive.zip>

This will put Clonezilla Live on the first partition. Due to that the partition is of the type EFI System, formatted as FAT32 and has EFI binaries with proper names located in EFI/boot/, Clonezilla Live can now be booted on UEFI systems. A bit more work is needed to also support systems that boot using a legacy BIOS.

Prepare for legacy BIOS booting

Run:

dd bs=440 count=1 conv=notrunc if=/mnt/utils/mbr/mbr.bin of=/dev/sdX
/mnt/utils/linux/x64/syslinux -d syslinux -f -i /dev/sdX1
sync
cd ~
umount /mnt

The first command will install the master boot record (MBR) code. The second command installs the volume boot record (VBR) code in the first sector of the first partition. These two combined allow legacy BIOS systems to use Syslinux to boot Clonezilla Live.

Optional: Clonezilla Live upgrade

Make sure you downloaded a new Clonezilla Live ZIP archive. Run the following commands for a 'safe' upgrade:

mkfs.vfat -F 32 /dev/sdX1
mount /dev/sdX1 /mnt
cd /mnt

unzip <ClonezillaLive.zip>

dd bs=440 count=1 conv=notrunc if=utils/mbr/mbr.bin of=/dev/sdX
utils/linux/x64/syslinux -d syslinux -f -i /dev/sdX1
sync
cd ~
umount /mnt

For a less safe but more convenient upgrade it is also possible to simply overwrite all existing files except the syslinux directory on the boot partition without a format. This does not upgrade Syslinux, but an older bootloader should not be an issue in most situations.

Comments