Clonezilla

Description

I’ll start this post off with a confession. When clone a drive I have always used dd for everything. I didn’t have a budget for a software to clone anything at home so dd was the tool of choice. Recently I had to clone a drive for a friend’s business and I had a limited window to clone it after hours. Originally my plan was to use dd but researched a bit and found clonezilla being praised highly. I decided to branch out and use it for the clone, and I was impressed by how fast the clone went. This post will go through using clonezilla to clone two drives.

Setup

To run through this tutorial you will need clonezilla installed.

sudo apt update
sudo apt install clonezilla

Connect Drives

Before cloning a drive to another you will need to ensure both are connected to the computer you are using. I like to connect one, run a command to see which /dev device is assigned, and then repeat for the destination drive.

First Drive

  1. Connect the drive you are cloning from.
  2. run lsblk to see which drive you need to remember.

Second Drive

Now repeat this process with the drive you are cloning to. Remember the device assigned to the drive.

Example

Before drives are connected:

xadlien@swift3x:~/git/danstechjourney$ lsblk | grep -v loop
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0    17G  0 part [SWAP]
├─nvme0n1p3 259:3    0 718.7G  0 part /home
├─nvme0n1p4 259:4    0 194.8G  0 part /var/snap/firefox/common/host-hunspell
│                                     /
└─nvme0n1p5 259:5    0   512M  0 part 
nvme1n1     259:6    0 953.9G  0 disk 
├─nvme1n1p1 259:7    0 953.1G  0 part 
└─nvme1n1p2 259:8    0   832M  0 part

Source Drive connected:

xadlien@swift3x:~/git/danstechjourney$ lsblk | grep -v loop
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 465.8G  0 disk 
└─sda1        8:1    0 465.8G  0 part /media/xadlien/Games
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0    17G  0 part [SWAP]
├─nvme0n1p3 259:3    0 718.7G  0 part /home
├─nvme0n1p4 259:4    0 194.8G  0 part /var/snap/firefox/common/host-hunspell
│                                     /
└─nvme0n1p5 259:5    0   512M  0 part 
nvme1n1     259:6    0 953.9G  0 disk 
├─nvme1n1p1 259:7    0 953.1G  0 part 
└─nvme1n1p2 259:8    0   832M  0 part 

Here we can see that the source drive is /dev/sda
Destination Drive connected:

xadlien@swift3x:~/git/danstechjourney$ lsblk | grep -v loop
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 465.8G  0 disk 
└─sda1        8:1    0 465.8G  0 part /media/xadlien/Games
sdb           8:16   0 931.5G  0 disk 
├─sdb1        8:17   0    16M  0 part 
└─sdb2        8:18   0 931.5G  0 part 
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0    17G  0 part [SWAP]
├─nvme0n1p3 259:3    0 718.7G  0 part /home
├─nvme0n1p4 259:4    0 194.8G  0 part /var/snap/firefox/common/host-hunspell
│                                     /
└─nvme0n1p5 259:5    0   512M  0 part 
nvme1n1     259:6    0 953.9G  0 disk 
├─nvme1n1p1 259:7    0 953.1G  0 part 
└─nvme1n1p2 259:8    0   832M  0 part 

The destination drive is /dev/sdb.

Cloning

Now run sudo clonezilla. You should see a screen asking you for a mode. In this example we are using device-device.

NCHC Free Software Labs, Taiwan Opensource Clone System (OCS) ├────────────────┐
│ *Clonezilla is free (GPL) software, and comes with ABSOLUTELY NO WARRANTY*   │
│ ///Hint! From now on, if multiple choices are available, you have to press   │
│ space key to mark your selection. An asterisk (*) will be shown when the     │
│ selection is done///                                                         │
│ Two modes are available, you can                                             │
│ (1) clone/restore a disk or partition using an image                         │
│ (2) disk to disk or partition to partition clone/restore.                    │
│ Besides, Clonezilla lite server and client modes are also available. You can │
│ use them for massive deployment                                              │
│ Select mode:                                                                 │
│                                                                              │
│  device-image  work with disks or partitions using images                    │
│  device-device work directly from a disk or partition to a disk or partitio  │
│  remote-source Enter source mode of remote device cloning                    │
│  remote-dest   Enter destination mode of remote device cloning               │
│  lite-server   Enter_Clonezilla_live_lite_server                             │
│  lite-client   Enter_Clonezilla_live_lite_client 

After selecting device-device it will generate data on the drives of the system and then ask you to select the wizard mode. I used ‘Beginner’.

 ┌───────────────┤ Clonezilla - Opensource Clone System (OCS) ├───────────────┐
 │ Choose the mode to run the following wizard about advanced parameters:     │
 │                                                                            │
 │             Beginner Beginner mode: Accept the default options             │
 │             Expert   Expert mode: Choose your own options                  │
 │             Exit     Exit. Enter command line prompt                       │
 │                                                                            │
 │                                                                            │
 │                    <Ok>                        <Cancel>   

This next screen is important. You can choose to clone individual paritions if you would like. In this example we are choosing the disk option.

┌────────────────┤ Clonezilla - Opensource Clone System (OCS) ├────────────────┐
│ *Clonezilla is free (GPL) software, and comes with ABSOLUTELY NO WARRANTY*   │
│ This software will overwrite the data on your hard drive when cloning! It is │
│ recommended to backup important files on the target disk before you          │
│ cloning!***                                                                  │
│                                                                              │
│         disk_to_local_disk local_disk_to_local_disk_clone                    │
│         part_to_local_part local_partition_to_local_partition_clone          │
│         exit               Exit. Enter command line prompt                   │
│                                                                              │
│                                                                              │
│                     <Ok>                         <Cancel>   

The next screen shows drives you can use as a source. If your source drive isn’t shown you may need to unmount and try again.

─────────────────────────────┤ Clonezilla - Opensource Clone System (OCS) | Mode: disk_to_local_disk ├───────────────────────────────┐
 │ Choose local disk as source.                                                                                                         │
 │ The disk name is the device name in GNU/Linux. The first disk in the system is "hda" or "sda", the 2nd disk is "hdb" or "sdb"...     │
 │                                                                                                                                      │
 │                           nvme1n1 1024GB_Micron_2210_MTFDHBA1T0QFD__Micron_2210_MTFDHBA1T0QFD_20292952C4A7                           │
 │                           sda     500GB_Tech__JMicron_Tech_4E351934707577-0:0                                                        │
 │                           sdb     1000GB_ASMT105x__APPLE_HDD_HTS541010A9E662_JD8008D8GM3GPS                                          │
 │                                                                                                                                      │
 │                                                                                                                                      │
 │                                       <Ok>                                           <Cancel> 

I will choose sda, then on the next screen I will choose sdb as the destination. Please make sure you are choosing the right drives, as this will erase the destination drive. It will then ask for advance parameters. Just hit enter.
Now it will ask what to do after our clone. I am going to choose enter command line prompt.

┌─────────────────────┤ Mode: disk_to_local_disk ├───────
│ The action to perform when everything is finished:     
│                                                        
│  -p choose    Choose reboot/shutdown/etc when everythin
│  -p true      Enter command line prompt                
│  -p reboot    Reboot                                   
│  -p poweroff  Shutdown                                 
│                                                        
│                                                        
│                  <Ok>                      <Cancel>    
│                                                        
└────────────────────────────────────────────────────────

Now just follow the prompts and type ‘y’ when asked about how sure you are. Just be sure that the drives you selected are correct! There is no going back once it starts. It is incredibly fast and will rebuild the partition table first on the destination drive.

Limitations

This has issues with USB drives for some reason. I’m looking into it but may not find a solution. USB drives are small enough that dd is still an ok option.

Extra Functionality

This software also supports clone for:

  • device to image
  • image to device
  • image to image

These work similarly to the example above.

Summary

After finding clonezilla and seeing that it’s a much more effient tool for copying data from one drive to another I’ll probably be using this tool for many years to come. Hopefully I helped you here as well.