Clonezilla: restore disk image to a smaller drive

A couple of days ago I wanted to clone a 160Gb drive to a 128Gb SSD, using a very recent Clonezilla version.
Online you'll find a lot of information telling you to use "Advanced" and then the flag "-icds", but that was still failing. Here is what I did.

1. First I needed to make the total size of the original partitions smaller than 128Gb. Using GParted Live, I reduced the largest partition at the end of the disk, which had plenty of free space. Then the total size of all the partitions became around 70Gb. Reboot into Clonezilla, use "save-disk" as usual.

2. During restore, you still need to use "Advanced" mode, and turn on "-icds" here:


3. Later, when you get to the point where it asks about what to do with the partition table in the destination disk:
You can use "-k1", but then all the original partitions will be reduced in size. In my case that was not an option that I wanted.
So I chose "-k2", to enter a command line prompt.

4. The Clonezilla image has a file called "sda-pt.sf", which is a dump of the original partition table using sfdisk. This file can be used to restore the partition table to the new destination disk, but it will not work as it is. The drive is too small. Fortunately, this is easy to fix:
  • Go to the folder of the image: cd /home/partimag/
  • Copy the file: cp sda-pt.sf sda-pt-small.sf
  • Check the maximum LBA size of your destination drive: sfdisk -d /dev/sda
  • Look for the line "last-lba:"
  • Edit the file sda-pt-small.sf: nano sda-pt-small.sf, and change "last-lba:" to the number you just saw.
  • Create the partition table on sda using the new file: sfdisk /dev/sda < sda-pt-small.sf
You can now exit the command prompt, and Clonezilla should be able to restore the image just fine.

5. Reboot into GParted Live, and expand the partition again to fill up the whole drive.

6. Done!



Comments