Mike Slinn

Inside Clonezilla

Published 2024-09-11. Last modified 2024-09-17.
Time to read: 2 minutes.

This page is part of the posts collection, categorized under Ableton, Clonezilla, Ubuntu.

I want to clone an Ubuntu system disk, except for one data partition. The clone should be bootable, so the GPT data, EFI partition and system partition need to function. This is not possible using the Clonezilla menus. I created an issue for the Clonezilla GitHub project and Steven Shiau, the primary author of Clonezilla, replied.

The image below shows the partitions on the drive to clone. All partitions should be copied to the new bootable drive, except the largest partition (shown as /dev/sdb3, labeled Data):

I have no desire to reinvent Clonezilla, or to do any unnecessary programming. The most desirable outcome would be to learn how to use an unmodified Clonezilla to accomplish the desired task.

Clonezilla has dozens of interesting utilities in clonezilla/sbin/ for managing Linux drives. I have not found any documentation on these utilities, so this article documents what I have learned so far.

Definitions

There are 3 versions of Clonezilla (Live, Lite Server and SE). The following are not used by Clonezilla Live, but they are mentioned in the code. I provide these definitions here so readers can understand the following table.

Drbl
Diskless Remote Boot in Linux.
EZIO
EZIO is a tool for rapid server disk image cloning/deployment within local area network. It utilizes the BitTorrent protocol to speed up the data distribution. Also, it uses partclone to dump used filesystem blocks, and an EZIO receiver can directly write received blocks to raw disk, which greatly improves performance.

Programs

The following programs comprise the code base for all 3 versions of Clonezilla. Only the programs used by Clonezilla Live are relevant to the task at hand. Those programs are highlighted in yellow.

sbin/ Name Purpose
clonezilla Main entry point.
create-debian-live Creates a Debian live CD iso which is used as a template for clonezilla image with restoration function.
create-drbl-live Creates a DRBL live CD/USB flash drive iso/zip
create-drbl-live-by-pkg Wrapper program to run create-drbl-live that assigns the required packages to create live media.
create-gparted-live Creates a GParted live CD/USB flash drive iso/zip
create-ocs-tmp-img Creates a Clonezilla image, all the partition/LV image files are linked. It is intended to be used to restore the image to other disk.
create-ubuntu-live Creates an Ubuntu live CD iso, which is used as a template for clonezilla image with restoration function.
cv-ocsimg-v1-to-v2 Converts clonezilla image from version 1 to version 2.
drbl-ocs Looks important, but I am unsure what this program does.
drbl-ocs-live-prep Downloads the Clonezilla live iso for Clonezilla SE environment.
ocs-btsrv Starts BitTorrent service for restoration.
ocs-chkimg Checks the integrity of a Clonezilla image.
ocs-chnthn Changes Windows hostname under drbl environment.
ocs-clean-disk-part-fs Cleans the file system/LVM info in every partition on the assigned disk.
ocs-cnvt-usb-zip-to-dsk Converts DRBL/Clonezilla live zip file to raw disk image or vmdk image.
ocs-console-font-size Tunes the Clonezilla live console font size in KMS mode, especially for HiDPI monitor.
ocs-cvt-dev Converts the clonezilla image from one device to another device, e.g., sda to nvme0n1
ocs-cvtimg-comp Converts Clonezilla images between compression formats.
ocs-decrypt-img Decrypts a Clonezilla image.
ocs-encrypt-img Encrypts a Clonezilla image
ocs-expand-gpt-pt Expands a GPT partition table by disk size ratio.
ocs-expand-lvm Expands the PV and LV by size ratio.
ocs-expand-mbr-pt Expands an MBR partition table by disk size ratio.
ocs-ezio-leecher Starts an EZIO client.
ocs-ezio-seeder Checks the integrity of a Clonezilla image.
ocs-gen-bt-metainfo Creates a .torrent file from file system on a partition directly.
ocs-gen-bt-slices Creates Clonezilla BitTorrent slice files from a Clonezilla image.
ocs-gen-grub2-efi-bldr Creates the EFI boot loader from grub2.
ocs-get-dev-info Obtains Linux device information.
ocs-img-2-vdk Converts a Clonezilla image to a virtual machine disk (VMDK) file.
ocs-install-grub Reinstalls grub on a MBR drive. This program is aimed to use the grub in the restored OS first, and if it fails, tries to use the grub from the running OS (live CD, for example).
ocs-iso Puts Debian Live minimal + DRBL/Clonezilla program into a bootable iso file.
ocs-iso-2-onie Converts a Clonezilla live iso to a ONIE self-extracting boot file.
ocs-label-dev Labels a partition.
ocs-lang-kbd-conf Defines keyboard layout.
ocs-langkbdconf-bterm Sets up the Clonezilla Live locale and keyboard layout.
ocs-live Looks like a launcher for Clonezilla Live.
ocs-live-bind-mount Browse and bind mount the image repository.
ocs-live-boot-menu Puts a syslinux.cfg or isolinux.cfg in a target directory, which is used to boot clonezilla live.
ocs-live-bug-report Used by Clonezilla live to collect disk info for bug and problem reports.
ocs-live-dev Puts Debian Live minimal + DRBL/Clonezilla program into a bootable device, such as pendrive/usb stick.
ocs-live-feed-img Feeds multicast/BitTorrent packets for clients to restore.
ocs-live-final-action Allows a Clonezilla user to choose the final action (poweroff, reboot, command line prompt...). The choice is saved in a file.
ocs-live-general Starts saving or restoring an image in Clonezilla live.
ocs-live-get-img Restores an image by receiving multicast packets from a server.
ocs-live-netcfg A lightweight text-based network configuration tool.
ocs-live-nicbonding Enables channel bonding.
ocs-live-preload Preloads a tarball/zip file or copies files from cifs/nfs for a live system.
ocs-live-repository Prepares the Clonezilla live image home directory via a URI (Uniform Resource Identifier).
ocs-live-restore Starts restoring an image in Clonezilla live.
ocs-live-run-menu Displays the Clonezilla Live menu.
ocs-live-save Starts saving an image in Clonezilla live.
ocs-live-swap-kernel Swaps the Linux kernel and modules in Clonezilla live.
ocs-lvm2-start LVM support for /usr, /home, /opt, etc. This should be done before checking local volumes, or they will never be checked.
ocs-lvm2-stop
ocs-makeboot Creates a bootable device using grub (for non-FAT drives) or by using syslinux for USB devices (FAT).
ocs-match-checksum Inspects the checksum in the image and the files in the block device.
ocs-memtester Stress test for finding memory subsystem faults.
ocs-onthefly For "disk to disk" or "partition to partition" clones.
ocs-park-disks Parks the local disks; only useful for rotating rust.
ocs-prep-cache Prepares cache files.
ocs-prep-repo Prepares the Clonezilla live image home directory in interactive mode.
ocs-put-signed-grub2-efi-bldr Saves the signed EFI boot loader from Ubuntu.
ocs-related-srv Saves or removes Clonezilla-related services to a client’s rc1.d.
ocs-resize-part Supposedly solves the small partition image restored to larger partition problem. Looking at the code, I do not believe this is a true statement.
ocs-restore-ebr Reinstalls the executable code area (the first 446 bytes in EBR).
ocs-restore-mbr Reinstalls the executable code area (the first 446 bytes in MBR.)
ocs-restore-mdisks Restores an image to multiple disks, especially many USB flash drives in a same machine by using Clonezilla live.
ocs-restore-veracrypt-vh Restores the volume header of a Veracrypt disk. Only for uEFI/GPT mode.
ocs-rm-win-swap-hib Remove Windows pagefile.sys, swapfile.sys and hiberfil.sys.
ocs-run-boot-param Runs commands assigned in boot parameter, for example: ocs_prerun*, ocs_postrun*, ocs_savedisk_prerun*, etc.
ocs-save-veracrypt-vh Dumps the volume header of a Veracrypt disk. Only for uEFI/GPT mode.
ocs-sr Save or restore an image.
ocs-srv-live Start Clonezilla SE on DRBL live.
ocs-tune-conf-for-s3-swift Assigns a friendly AWS S3/Swift setting for uploading a Clonezilla image.
ocs-tune-conf-for-webdav Assigns a friendly davfs2 setting for uploading a Clonezilla image.
ocs-tux-postprocess Removes Linux udev persistent files.
ocs-update-initrd Updates initramfs for the deployed OS in the hard drive.
ocs-update-syslinux Updates the syslinux partition, including the file ldlinux.sys and the files (*.c32 and *.bin) in the syslinux/ directory.
ocsmgrd Unsure what this does, but it uses PXE for remote boot so it is not used by Clonezilla Live.
update-efi-nvram-boot-entry Updates UEFI NVRAM for a restored disk.

In addition, the following is provided in scripts/sbin/:

Name Purpose
ocs-functions Contains functions for drbl-ocs, ocs-sr and ocs-onthefly.

Approach

A cursory examination of the Clonezilla code shows that device-to-device cloning first creates a temporary image. Usage of the Clonezilla programs must follow that approach.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.