CLONEZILLA - Basic Usage
Cloning a Disk to Another Disk
Clonezilla allows you to clone an entire disk, including all partitions, to another disk. This is useful for upgrading to a larger drive or creating a duplicate of the system setup.
To clone a source disk (`/dev/sda`) to a target disk (`/dev/sdb`), use the following command:
sudo clonezilla -q -icds -scs -q2 -rsync -source /dev/sda -target /dev/sdb
Where: - `-q` = Quiet mode, minimizes output. - `-icds` = Ignore checking disk sizes. - `-scs` = Use the default cloning strategy. - `-q2` = Enable faster cloning. - `-rsync` = Use rsync for block-by-block copying.
Saving an Image of a Disk or Partition
To save an image of a disk or partition, Clonezilla allows you to create compressed disk images that can be stored in a remote location, such as a network share or local storage.
To create an image of a partition (`/dev/sda1`) and store it in a folder (`/mnt/backup/`):
sudo clonezilla -q -icds -scs -r -s /mnt/backup/ -source /dev/sda1
Where: - `-r` = Run the backup operation. - `-s` = Specify the location where the image will be stored.
Clonezilla supports various compression options for the saved image, such as gzip, lz4, and zstd. For example, to use gzip compression, append the `-gzip` flag:
sudo clonezilla -q -icds -scs -r -s /mnt/backup/ -source /dev/sda1 -gzip
Restoring an Image to a Disk or Partition
Restoring a previously saved image to a disk or partition is just as simple as saving one. To restore an image stored in `/mnt/backup/` to the partition `/dev/sda1`:
sudo clonezilla -q -icds -scs -r -s /mnt/backup/ -target /dev/sda1
You can also specify compression format while restoring:
sudo clonezilla -q -icds -scs -r -s /mnt/backup/ -target /dev/sda1 -gzip
Network-Based Cloning (Clonezilla Server Edition)
Clonezilla Server Edition (SE) allows you to clone multiple systems over a network using multicast. It requires setting up a server to host the Clonezilla image repository and a network client for each system.
To start the Clonezilla server for multicast imaging, run the following command:
sudo ocs-srvs -s 192.168.1.100 -t 192.168.1.200
Where: - `192.168.1.100` = IP address of the Clonezilla server. - `192.168.1.200` = IP address of the client system.
To deploy a saved image to multiple clients over the network, run:
sudo ocs-srvs -i 192.168.1.100 -d multicast
Where: - `-i` specifies the source image directory. - `-d multicast` uses multicast mode for sending images to clients.
Advanced Options for Disk Cloning
Clonezilla provides advanced options for controlling the cloning process, such as:
- **Partclone Mode**: By default, Clonezilla uses Partclone to clone partitions, but you can specify a different cloning mode like `dd` or `ntfsclone`:
sudo clonezilla -q -icds -scs -p dd -source /dev/sda1 -target /dev/sdb
- **Partition Alignment**: You can enable partition alignment to improve the performance of the cloned disk on SSDs:
sudo clonezilla -q -icds -scs -part_align 1 -source /dev/sda -target /dev/sdb
- **Check Disk Space**: Clonezilla can check the disk space on the target before performing the cloning operation. Use the `-check_space` flag to verify if the target disk has sufficient space:
sudo clonezilla -q -icds -scs -check_space -source /dev/sda -target /dev/sdb
Clonezilla and UEFI Systems
Clonezilla also supports cloning UEFI-based systems. When cloning a system with UEFI firmware, you must ensure that both source and target disks use GPT partitioning. To ensure compatibility, check the partition type with the `gdisk` tool before cloning.
To clone a UEFI system using Clonezilla:
sudo clonezilla -q -icds -scs -gpt -source /dev/sda -target /dev/sdb
Ensure that the target disk is large enough to accommodate the entire UEFI system, including the EFI partition.
Automating Clonezilla with Scripts
Clonezilla can be automated using bash scripts. This allows for unattended backups or clones, making it easier to manage multiple systems.
Here is an example bash script for backing up a disk to a remote server:
#!/bin/bash sudo clonezilla -q -icds -scs -r -s /mnt/backup/ -source /dev/sda1 -gzip echo "Backup of /dev/sda1 completed successfully."
Make the script executable:
chmod +x clone_backup.sh
To schedule regular backups, use cron jobs to run the script at specified intervals. For example, to run the backup every Sunday at 3 AM, add the following to your crontab:
0 3 * * Sun /path/to/clone_backup.sh
Troubleshooting Clonezilla
In case you encounter issues while using Clonezilla, consider the following troubleshooting tips:
- **Disk Size Mismatch**: Clonezilla may warn about a disk size mismatch between source and target. If this happens, ensure that the target disk is equal to or larger than the source disk. - **File System Errors**: Before cloning, check for file system errors using the appropriate file system check tool (e.g., `fsck` for ext4, `chkdsk` for NTFS). - **Invalid Partition Table**: If you receive errors related to invalid partition tables, use `gdisk` to repair the partition table on the source disk before cloning.
