rss logo

Set up a Clonezilla server on Debian

Clonezilla logo Drbl logo

Here's how to set up a Clonezilla Server on a Debian distribution.

To achieve this, we're going to use the DRBL (https://drbl.org/) / Clonezilla (https://clonezilla.org/) pairing.

So, to sum up, the DRBL server will enable our client machines to boot into Clonezilla via PXE.

Architecture

The tftp, dhcp and nfs services will be installed on the Debian server to enable booting via PXE.

Network diagram illustrating a Clonezilla server setup with PXE boot. Includes a central server running Clonezilla and DRBL, connected to clients booting via PXE, with NFS shares for storing images and two network interfaces.
Deployment server architecture with DRBL and Clonezilla.

Prerequisites and Configuration

Debian logo
  • There are few prerequisites to be met before you can install DRBL.
    • Install Debian on the server
    • ⚠️ Enable PXE boot mode on client workstations.⚠️
    • The server needs two network cards
  • Configuration:
    • Debian: Bullseye 11
    • DRBL: 4.5 (DRBL repository) or 2.32 (official Debian repository)

Network

  • Get network interface names:
root@host:~# ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:50:56:80:a5:be brd ff:ff:ff:ff:ff:ff altname enp11s0 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:50:56:80:e2:ae brd ff:ff:ff:ff:ff:ff altname enp19s0
  • Edit /etc/network/interfaces:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback allow-hotplug ens192 iface ens192 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.254 dns-nameservers 80.67.169.40 # The primary network interface allow-hotplug ens224 iface ens224 inet static address 192.168.10.1 netmask 255.255.255.0
  • Restart to apply configuration:
root@host:~# reboot

Install

  • Install the requisite packages:
root@host:~# apt-get install rsync gawk gnupg curl

Installing DRBL

There are two ways to proceed. The first is to use the official Debian repositories, the other is to add the DRBL repositories.

I'd personally recommend using the DRBL repositories in order to have the latest version of DRBL and Clonezilla, and also because there are fewer actions to perform…

But being a gentleman, I'll detail both methods here.

Solution 1 - DRBL repository (recommended)

Add the DRBL key (see https://drbl.org/installation/02-install-required-packages.php).

  • Old method with apt-key:
root@host:~# wget -q https://drbl.org/GPG-KEY-DRBL -O- | apt-key add -
  • New method, as apt-key seems deprecated:
root@host:~# curl -s https://drbl.org/GPG-KEY-DRBL | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/GPG-KEY-DRBL.gpg --import root@host:~# chmod 644 /etc/apt/trusted.gpg.d/GPG-KEY-DRBL.gpg
  • Add the drbl repository to the source.list file:
root@host:~# echo "deb http://free.nchc.org.tw/drbl-core drbl stable" >> /etc/apt/sources.list
  • Install the DRBL package:
root@host:~# apt update root@host:~# apt-get install drbl
  • Edit /etc/drbl/drbl.conf to enable secure boot compatibility:
# uEFI network secure boot for clients. This is still in testing. secure_boot_client="yes"
  • Install DRBL server:
Note: We can press the "Enter" key at each question to validate the default values. root@host:~# drblsrv -i
  • Push config:
Note: Choose default values except for the questions detailed below. root@host:~# drblpush -i […] The public IP address of this server is NOT found. Which ethernet port in this server is for public Internet accsess, not for DRBL connection? Available ethernet ports in this server: ens192 (192.168.1.10), ens224 (192.168.10.1), [ens192] […] What is the initial number do you want to use in the last set of digits in the IP (i.e. the initial value of d in the IP address a.b.c.d) for DRBL clients connected to this ethernet port ens224. [1] 10 ****************************************************** How many DRBL clients (PC for students) connected to DRBL server's ethernet network interface ens224 ? Please enter the number: [12] 50 […] ------------------------------------------------------ In the system, there are 3 modes for diskless linux services: [0] Full DRBL mode, every client has its own NFS based /etc and /var. [1] DRBL SSI (Single system image) mode, every client uses tmpfs based /etc and /var. In this mode, the loading and necessary disk space of server will be lighter. NOTE! (a) The client machine memory is recommended at least 256 MB. (b) The setting and config files of client will not be saved to the DRBL server! They are just used once and will vanish after the machine shutdowns! Besides, if you modify any file in the template client (located in /tftpboot/nodes), you have to run drbl-gen-ssi-files to create the template tarball in /tftpboot/node_root/drbl_ssi/. (c) If you want to provide some file to overwrite the setting in the template tarball when client boots, check /tftpboot/node_root/drbl_ssi/clients/00_README for more details. [2] I do NOT want to provide diskless Linux service to client. Which mode do you prefer? [0] 2 No diskless Linux for client is the system. ****************************************************** ------------------------------------------------------ In the system, there are 4 modes available for clonezilla: [0] Full Clonezilla mode, every client has its own NFS based /etc and /var. [1] Clonezilla box mode, every client uses tmpfs based /etc and /var. In this mode, the loading and necessary disk space of server will be lighter than that in Full Clonezilla mode. Note! In Clonezilla box mode, the setting and config files of client will not be saved to the DRBL server! They just use once and will vanish after the machine shutdowns! [2] I do NOT want clonezilla. [3] Use Clonezilla live as the OS (Operating System) of clients. Which mode do you prefer? [0] 3 Use Clonezilla live as the OS (Operating System) of clients when running Clonezilla job. ****************************************************** ****************************************************** What's the Clonezilla live release branch for the clients? [0]: stable (Debian-based) [1]: testing (Debian-based) [2]: alternative stable (Ubuntu-based) [3]: alternative testing (Ubuntu-based) If unsure, choose [2]: alternative stable. [2] From Ubuntu 19.10, only amd64 (x86-64) release of Clonezilla live is available. ****************************************************** The CPU arch for clients when running Clonezilla job: amd64 ------------------------------------------------------

Solution 2 - official Debian repositories

Installation of prerequisites

From the Debian repositories, drbl fails to automatically install nfs, dhcp etc… so we'll have to install them manually.
  • Install the nfs service:
root@host:~# apt update root@host:~# apt install nfs-kernel-server
  • Install the dhcp service:
root@host:~# apt install isc-dhcp-server
  • Install the tftp server:
root@host:~# apt install tftpd-hpa
  • Install any other packages that may be required:
root@host:~# apt install iptables syslinux-common pxelinux grub-efi-amd64 grub-efi-ia32-bin

Install and configure DRBL

  • Install the DRBL package:
root@host:~# apt install drbl
  • Edit /etc/drbl/drbl.conf to enable secure boot compatibility:
# uEFI network secure boot for clients. This is still in testing. secure_boot_client="yes"
  • Install the DRBL server:
Note: We can press the "Enter" key at each question to validate the default values. root@host:~# drblsrv -i
  • Push configuration:
Note: Choose default values except for the questions detailed below. root@host:~# drblpush -i […] The public IP address of this server is NOT found. Which ethernet port in this server is for public Internet accsess, not for DRBL connection? Available ethernet ports in this server: ens192 (192.168.1.10), ens224 (192.168.10.1), [ens192] […] What is the initial number do you want to use in the last set of digits in the IP (i.e. the initial value of d in the IP address a.b.c.d) for DRBL clients connected to this ethernet port ens224. [1] 10 ****************************************************** How many DRBL clients (PC for students) connected to DRBL server's ethernet network interface ens224 ? Please enter the number: [12] 50 […] ------------------------------------------------------ In the system, there are 3 modes for diskless linux services: [0] Full DRBL mode, every client has its own NFS based /etc and /var. [1] DRBL SSI (Single system image) mode, every client uses tmpfs based /etc and /var. In this mode, the loading and necessary disk space of server will be lighter. NOTE! (a) The client machine memory is recommended at least 256 MB. (b) The setting and config files of client will not be saved to the DRBL server! They are just used once and will vanish after the machine shutdowns! Besides, if you modify any file in the template client (located in /tftpboot/nodes), you have to run drbl-gen-ssi-files to create the template tarball in /tftpboot/node_root/drbl_ssi/. (c) If you want to provide some file to overwrite the setting in the template tarball when client boots, check /tftpboot/node_root/drbl_ssi/clients/00_README for more details. [2] I do NOT want to provide diskless Linux service to client. Which mode do you prefer? [0] 2 No diskless Linux for client is the system. ****************************************************** ------------------------------------------------------ In the system, there are 4 modes available for clonezilla: [0] Full Clonezilla mode, every client has its own NFS based /etc and /var. [1] Clonezilla box mode, every client uses tmpfs based /etc and /var. In this mode, the loading and necessary disk space of server will be lighter than that in Full Clonezilla mode. Note! In Clonezilla box mode, the setting and config files of client will not be saved to the DRBL server! They just use once and will vanish after the machine shutdowns! [2] I do NOT want clonezilla. [3] Use Clonezilla live as the OS (Operating System) of clients. Which mode do you prefer? [0] 3 Use Clonezilla live as the OS (Operating System) of clients when running Clonezilla job. ****************************************************** ****************************************************** What's the Clonezilla live release branch for the clients? [0]: stable (Debian-based) [1]: testing (Debian-based) [2]: alternative stable (Ubuntu-based) [3]: alternative testing (Ubuntu-based) If unsure, choose [2]: alternative stable. [2] ****************************************************** What's the CPU arch for the clients when running Clonezilla job with Clonezilla live? [0]: i386 [1]: amd64 If unsure, choose i386. [0] 1 Note: ⚠️If, like me, you have an ipv6 address assigned to the wan interface, the dhcp service may fail to start with the error message: "Failed to start service isc-dhcp-server !!!". To solve the problem, simply edit /etc/dhcp/dhcpd.conf and delete the line "option domain-name-servers". Then restart the services with the drbl-all-service start command.⚠️

Fix UEFI and BIOS configuration files

Whichever method you use to install DRBL, you'll need to modify the boot configuration files, otherwise you won't be able to boot into Clonezilla.

Set UEFI boot menu

  • Edit /tftpboot/nbi_img/grub/grub.cfg:
# Created by gen-grub-efi-nb-menu! Do NOT edit unless you know what you are doing! set default=clonezilla-se-client set timeout_style=menu set timeout=10 set hidden_timeout_quiet=false set graphic_bg=yes # tftpd_opt can be tftpd_opt=tftp or tftpd_opt="tftp,$tftp_server_ip", e.g., tftpd_opt=tftp,192.168.66.254 set tftpd_opt=tftp # "run_load_netboot" is the flag to avoid load_netboot to be run more than once. # function load_netboot { set prefix=($tftpd_opt)/grub echo "Grub CPU and platform: $grub_cpu, $grub_platform" echo 'Network status: ' net_ls_cards net_ls_addr net_ls_routes # sleep 5 } # function load_gfxterm { set gfxmode=auto insmod efi_gop insmod efi_uga insmod gfxterm terminal_output gfxterm } load_netboot # Somehow the grub2 from CentOS 7 will look for unicode.pf2.pf2 if using "loadfont unicode.pf2". While in Debian/Ubuntu it's OK to use "loadfont unicode.pf2". if [ x"${graphic_bg}" = xyes ]; then if loadfont unicode; then load_gfxterm elif loadfont unicode.pf2; then load_gfxterm fi fi if background_image drblwp.png; then set color_normal=black/black set color_highlight=magenta/black else set color_normal=cyan/blue set color_highlight=white/blue fi # Decide if the commands: linux/initrd (default) or linuxefi/initrdefi set linux_cmd=linux set initrd_cmd=initrd export linux_cmd initrd_cmd if [ "${grub_cpu}" = "x86_64" -o "${grub_cpu}" = "i386" ];then set linux_cmd=linuxefi set initrd_cmd=initrdefi fi menuentry "Clonezilla-live" --id clonezilla-se-client { echo "Enter Clonezilla..." echo 'Loading Linux kernel vmlinuz-pxe...' #Add live-netdev="eth0" to force eth0 as primary interface and avoid WWAN0 boot priority see : https://sourceforge.net/p/clonezilla/discussion/Help/thread/1f90134ddd/ $linux_cmd Clonezilla-live-vmlinuz initrd=Clonezilla-live-initrd.img boot=live union=overlay username=user hostname=hirsute config components noswap edd=on nomodeset enforcing=0 locales=en_US.UTF-8 keyboard-layouts=en ocs_live_extra_param= ocs_live_batch=no net.ifnames=0 noeject netboot=nfs nfsroot=192.168.10.1:/tftpboot/node_root/clonezilla-live/ ocs_server="192.168.10.1" ocs_daemonon=\"ssh\" ocs_prerun=\"mount -t nfs 192.168.10.1:/home/partimag /home/partimag/\" ocs_live_run=\"clonezilla -l en_US.UTF-8 -p choose -k --skip-lite-menu \" echo 'Loading initial ramdisk initrd-pxe.img...' $initrd_cmd Clonezilla-live-initrd.img } menuentry "Local operating system (if available)" --id local-disk { echo "Booting first local disk..." # Generate boot menu automatically configfile grub/boot-local-efi.cfg # If not chainloaded, definitely no uEFI boot loader was found. echo "No uEFI boot loader was found!" sleep 15 } menuentry "Reboot" --id reboot { echo "System rebooting..." reboot } menuentry "Shutdown" --id shutdown { echo "System shutting down..." halt } menuentry 'uEFI firmware setup' 'uefi-firmware' { echo "Entering uEFI firmware setup..." insmod efifwsetup fwsetup }
  • As a result, the following screen should appear when clients boot:
Screenshot of the GRUB boot menu for Clonezilla Live, showing options to boot Clonezilla, reboot, shut down, or access UEFI firmware setup. Branded with DRBL and NCHC Taiwan logos.

Set Legacy BIOS boot menu

  • Edit /tftpboot/nbi_img/pxelinux.cfg/default file:
default vesamenu.c32 timeout 100 prompt 0 noescape 1 ENU MARGIN 5 ENU BACKGROUND drblwp.png # Set the color for unselected menu item and timout message ENU COLOR UNSEL 7;32;41 #c0000090 #00000000 ENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000 ENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000 ENU COLOR HELP 7;32;41 #c0000090 #00000000 PATH bios/ say ********************************************** say Welcome to DRBL. say NCHC Free Software Labs, Taiwan. say http://drbl.org; http://drbl.nchc.org.tw say ********************************************** # Allow client to edit boot parameters ALLOWOPTIONS 1 # simple menu title ENU TITLE DRBL (http://drbl.org) label local #MENU DEFAULT # MENU HIDE MENU LABEL Local operating system (if available) # MENU PASSWD kernel chain.c32 append hd0 TEXT HELP Boot local OS from first hard disk if it's available ENDTEXT label Clonezilla-live MENU DEFAULT #MENU HIDE MENU LABEL Clonezilla Live KERNEL Clonezilla-live-vmlinuz #Add live-netdev="eth0" to force eth0 as primary interface and avoid WWAN0 boot priority see : https://sourceforge.net/p/clonezilla/discussion/Help/thread/1f90134ddd/ APPEND initrd=Clonezilla-live-initrd.img boot=live union=overlay noswap noeject nolocales locales=en_US.UTF-8 keyboard-layouts=en ocs_prerun="mount -t nfs 192.168.10.1:/home/partimag /home/partimag/" vga=788 netboot=nfs nfsroot=192.168.10.1:/tftpboot/node_root/clonezilla-live/ ocs_server="192.168.10.1" ocs_live_run="clonezilla -l en_US.UTF-8 -p choose -k --skip-lite-menu" TEXT HELP Clonezilla Live runs on RAM ENDTEXT
  • As a result, the following screen should appear when booting clients:
Screenshot of the Clonezilla Live boot menu displaying options for booting into Clonezilla Live (RAM) or the local operating system. Includes DRBL and NCHC Taiwan logos.

Backup and Restore

Now that the hard part has been done, we can proceed with the backup and restoration of client images.

Here's how to backup and restore a complete system.

Note: the restore option will only appear if at least one image is already in the /home/partimag/ file share.

Backup

  • Select device-image:
Screenshot of the Clonezilla interface displaying mode selection options, including device-image, device-device, remote-source, and remote-dest for cloning and restoring disks or partitions.
  • Select Beginner:
Screenshot of Clonezilla interface displaying options to choose the operation mode: Beginner for default settings, Expert for advanced customization, and Exit for command-line access.
  • Select savedisk:
Screenshot of Clonezilla interface showing options for saving or restoring data, including 'savedisk' to save an entire disk as an image, 'saveparts' to save partitions as images, and 'exit' for command-line access. Includes warnings about overwriting data and recommendations for backups.
  • Give the image a name:
Screenshot of Clonezilla interface prompting the user to input a name for the saved disk image, with examples of reserved names like 'ask_user' and 'autoname'. The name 'debian11-img' is shown as an example.
  • Select the disk to be backed up:
Screenshot of Clonezilla interface showing the selection of a local disk as the source for imaging, highlighting the disk sda with a size of 85.9GB labeled as Virtual_disk_No_disk_serial_no
  • Select the compression option:
Screenshot of Clonezilla interface displaying advanced parameters for selecting compression options, including gzip for parallel compression on multicore CPUs and zstdmt for fast, small image compression
  • Choose whether or not to check and repair the file system before backing up:
Screenshot of Clonezilla interface showing options to check and repair the file system before saving, including skipping the check, interactive repair, and automatic repair with caution for supported file systems like ext2, ext3, ext4, and reiserfs
  • Choose whether or not to check the integrity of the backup image:
Screenshot of Clonezilla interface asking if the saved image should be checked for restorability, with options to check the image or skip the verification
  • Choose whether or not to encrypt the image:
Screenshot of Clonezilla interface displaying options to encrypt the saved image using eCryptfs with industry-standard cryptographic ciphers, or to skip encryption
  • Finally, press enter and then type y to launch the backup:
Screenshot of Clonezilla showing the backup process log, including details of the selected device sda, partition information, and the generated command to save the image as debian11-img
  • Wait until the process is complete:
Screenshot of Partclone interface displaying the cloning progress, showing details of the file system, device size, blocks processed, elapsed time, and data transfer rate

Restore

  • Select device-image:
Screenshot of Clonezilla mode selection menu showing options for cloning or restoring disks and partitions, including device-image, device-device, remote-source, and remote-dest modes
  • Select Beginner mode:
Screenshot of Clonezilla interface displaying mode selection options including Beginner mode to accept default settings, Expert mode for advanced customization, and Exit to enter the command line
  • Select restoredisk:
Screenshot of Clonezilla menu displaying options to save or restore disks and partitions, including savedisk, saveparts, restoredisk, restoreparts, and additional advanced options like encryption and conversion
  • Select the image to restore from the list:
Screenshot of Clonezilla interface showing the selection of an image file to restore, with the image debian11-img_2021-1128-1724_sda_85.9GB highlighted
  • Select the destination disk, ⚠️all disk data will be deleted⚠️::
Screenshot of Clonezilla interface prompting the user to select the target disk for restoration, with a warning about overwriting all data and the disk sda 85.9GB Virtual_disk_No_disk_serial_no highlighted
  • Choose whether or not to check image integrity before restoring:
Screenshot of Clonezilla interface prompting the user to check if the image is restorable before proceeding with restoration, with options to perform or skip the check
  • Finally, press Enter and then type y to launch the restore:
Screenshot of Clonezilla interface showing the process log and a confirmation prompt to restore an image to a disk, with warnings about overwriting all existing data on the selected partition
  • Wait until the process is complete:
Screenshot of Partclone interface showing the progress of restoring data to a disk, including details of file system, device size, blocks processed, elapsed time, remaining time, and data transfer rate

References

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address