Automates Clonezilla Live on hard drive from a USB stick. A laptop boots straight into Clonezilla from its own drive, keeps disk images on a separate partition, and runs Clonezilla's Lite Server to PXE-boot other computers and deploy images to them.
USB stick (make-usb.sh) laptop internal drive (after install)
┌──────────────────────────┐ ┌──────────┬───────────────────────────┐
│ Clonezilla Live │ ───► │ CZBOOT │ CZIMAGES │
│ + "Install Clonezilla to │ │ 2 GiB │ rest of the drive, ext4 │
│ this computer's HARD │ │ FAT32/EFI│ = /home/partimag │
│ DRIVE" boot entry │ │ /live │ (your images) │
└──────────────────────────┘ └──────────┴───────────────────────────┘
These are the steps from clonezilla.org/livehd.php, scripted:
- Picks the internal drive. USB drives and the installer stick are never offered. If there's more than one internal drive, it asks which one.
- Partitions it (GPT):
CZBOOT: a 2 GiB FAT32 EFI partition holding Clonezilla Live in/live. livehd.php renames it to/live-hd, but Lite Server only works with/live, so keep other Clonezilla USB sticks unplugged when you boot the laptop.CZIMAGES: ext4, the rest of the drive, for images.
- Rewrites Clonezilla's boot menus for the hard drive:
- adds
ocs_repository="dev:///LABEL=CZIMAGES", so the images partition is already mounted as/home/partimagwhen Clonezilla starts. - adds a Clonezilla Lite Server (PXE-boot other computers) entry.
- presets language and keyboard so Clonezilla doesn't ask on every boot.
- adds
- Installs both boot loaders. UEFI uses Clonezilla's own signed shim and GRUB, so Secure Boot works. Legacy BIOS uses syslinux with the GPT MBR. On UEFI machines it also adds a "Clonezilla (hard drive)" boot entry.
- Reboots into Clonezilla from the hard drive.
Run it again on a drive that already has this layout and it upgrades
instead: it replaces Clonezilla on CZBOOT and keeps your images on
CZIMAGES. You can also choose to wipe the drive and start over.
git clone https://github.com/CopesaCola/clonezilla-hd.git
cd clonezilla-hd
lsblk -d -o NAME,SIZE,TRAN,MODEL # find the USB stick, e.g. /dev/sdb
sudo ./make-usb.sh /dev/sdbThe script downloads the latest stable Clonezilla Live (checksum verified),
writes it to the stick, and adds the installer boot entry. To build a
.img to flash with Rufus or balenaEtcher instead, give it a filename:
sudo ./make-usb.sh clonezilla-hd-installer.img.
| Option | Default | |
|---|---|---|
--auto |
off | the installer is the default boot entry (5 s) and skips its prompts: plug in, power on, walk away. It refuses to run if the computer has more than one internal drive. |
--default lite-server |
clonezilla |
make the hard drive boot into Lite Server by default |
--boot-size 4G |
2G |
size of the Clonezilla partition |
--timeout 10 |
30 |
boot menu timeout on the hard drive, in seconds |
--locale '' --keymap '' |
en_US.UTF-8 / us |
empty = Clonezilla asks at every boot |
--clonezilla 3.3.3-37 |
latest | pin a version, or pass a zip URL or local zip file |
- Download the Clonezilla Live zip (amd64, stable) from clonezilla.org.
- Format the USB stick as FAT32. Windows only offers FAT32 for sticks up to 32 GB; for a bigger stick, use Rufus with "Non bootable" and FAT32.
- Extract the zip's contents to the root of the stick, so
live\,EFI\andutils\sit directly on it. - On the stick, open
utils\win64, right-clickmakeboot64.bat, choose Run as administrator and follow its prompts. Check that it names the USB stick's drive letter. - Copy this repo's
czhdfolder to the root of the stick. Don't edit the.shfiles in Notepad: Windows line endings break them. - Boot the laptop from the stick. Choose Clonezilla live, pick your language and keyboard, then Enter_shell, then cmd.
- Run
sudo bash /run/live/medium/czhd/install-to-hd.sh.
The result is the same; you just don't get the extra boot entry or --auto.
- In the laptop's firmware settings, allow booting from USB.
- Boot from the stick and pick Install Clonezilla to this computer's HARD DRIVE.
- Confirm the drive by typing
YES. Skipped with--auto. - When it says so, remove the stick. The laptop reboots into Clonezilla from its own drive.
The laptop's boot menu now offers:
-
Clonezilla live: the normal wizard. Images are saved to and restored from
CZIMAGES. At the repository question, pick "skip — use existing /home/partimag" if it's asked at all. -
Clonezilla Lite Server: PXE-boots other computers and restores an image from
CZIMAGESonto them, one at a time or many at once by multicast.- Connect the laptop and the clients to the same wired network or switch.
- Pick the Lite Server entry, then choose the image repository (the
CZIMAGESpartition, on the laptop's drive). It also asks whether to use an existing DHCP server or start its own: choose "start new" only on an isolated switch with no router. - Set the clients to network/PXE boot. Secure Boot can stay on: Lite
Server normally offers UEFI clients an unsigned boot loader, so this
entry swaps in Clonezilla's signed shim and GRUB (
czhd/lite-server-helper.sh, log in/tmp/czhd-lite-server.log). Signed network boot works best when Lite Server starts its own DHCP on an isolated switch. - Multicast runs in full-duplex mode (the wizard's
-xoption) by default, which is faster with several clients. It needs a switch, not an old network hub. - Waits are shortened: the clients' boot menu starts the restore after
2 s (Lite Server default 7 s), and in "time to wait" mode multicast
waits 10 s before each partition after the first (default 30 s). Both
are set at the top of
czhd/lite-server-helper.sh. Choosing clients-to-wait in the wizard skips the per-partition wait entirely: each partition starts as soon as every client is ready.
-
Import images from a USB drive: copies premade Clonezilla images from a USB drive onto
CZIMAGES, then checks they're restorable.- Pick the entry, plug in the drive when asked, and press Enter.
- Choose which of the listed images to copy (or
all).
The drive is mounted read-only. Images are found up to 3 folders deep, spaces in names become
_, and a half-finished copy never shows up as an image. From a Clonezilla shell you can also runsudo bash /run/live/medium/czhd/import-images.sh [/dev/sdXN]. -
Capturing new images: Lite Server only sends images out. To capture a machine's disk, either:
- connect that disk to the laptop (USB enclosure or dock) and use Clonezilla live → device-image → savedisk, or
- save on the client with the regular stick, then copy the image folder to
the laptop's
/home/partimag.
- x86-64 only, as is Clonezilla's amd64 build.
- Keep other Clonezilla USB sticks unplugged when you boot the laptop. On UEFI, Clonezilla's GRUB finds its menu by looking for a marker file that every Clonezilla stick also has.
install-to-hd.shwrites a log to/tmp/czhd-install.log. If anything fails it shows the error and drops you to a shell.- Advanced/testing:
CZHD_DISK=/dev/nvme0n1forces the target drive;CZHD_NO_REBOOT=1skips the final reboot.
shellcheck -x make-usb.sh czhd/*.sh| File | Runs on | Purpose |
|---|---|---|
make-usb.sh |
any Linux PC | builds the installer USB stick (or .img) |
czhd/install-to-hd.sh |
the laptop, inside Clonezilla Live | partitions the drive and installs Clonezilla |
czhd/import-images.sh |
the laptop, inside Clonezilla Live | copies premade images from a USB drive onto CZIMAGES |
czhd/lite-server-helper.sh |
the laptop, inside Clonezilla Live | fixes Lite Server's client boot files (signed UEFI loader, no laptop-only settings) |
czhd/menu-lib.sh |
both | edits Clonezilla's syslinux and GRUB menus |