Force cloned hard-disk image upon a smaller hard-disk

9

4

I have a image which was taken with Clonezilla as SAVEDISK on a 160GB harddrive.
Now a newer version of the PC released with a 120GB harddrive, the space in use is just 20GB

Is there a way I can force Clonezilla (or any other program) to manipulate the images 'original size' to 120GB or lower, so Clonezilla can write it to the new PC?

Sander

Posted 2011-09-07T09:18:38.810

Reputation: 263

I don't know how clonezilla works, but if there are only 20GB of data, what is the exact problem you encounter? – Michael K – 2011-09-07T10:42:53.627

1Since the image was taken of a 160GB disk, it includes a 160GB partition table, which won't allow me to override it. – Sander – 2011-09-08T05:56:27.017

Is there no way to 'open' the image and copy the data away? – Michael K – 2011-09-08T06:43:52.040

I have various .aa .ab .ac files (sda1.ntfs-ptcl-img.gz.aa till sda1.ntfs-ptcl-img.gz.ae) seeming this is the image of the harddisk, I think I can un-aa it into one .img.gz file, but then I need a way to write it back. – Sander – 2011-09-08T06:58:07.823

Answers

9

Clonezilla relies on Partclone to save and restore filesystems. Although it's useful, even if you use the -icds option, that alone isn't enough. When restoring the original filesystem on the smaller disk, Partclone will encounter a seek error trying to write beyond the disk boundary. So this is a limitation of not only Clonezilla, but the underlying tools it uses.

What you can do however, is to restore the image temporarily on a 160GB disk, use a filesystem resize tool such as ntfsresize (for NTFS) or resize2fs (for ext3/4) to shrink the filesystem, say to 25GB. Resizing the partition table, which GParted does, isn't necessary. Use Clonezilla again to create a new image using the "savedisk" option.

When restoring the image on the smaller disk, use the -icds option to skip Clonezilla checking if the disk is the same or larger than the original disk. Since you shrunk the filesystem, Partclone won't encounter a seek error and your data will be restored on your smaller disk.

If you used the option to restore the partition table proportionally (-k1), Clonezilla will create a proper partition table and resize (expand) the original filesystem so that all the free space on the new disk becomes available.

EDIT: The -icds option isn't passed to ocs-expand-mbr-pt, so this step currently fails. A bug report has been filed about this with the project. The bug has been fixed.

jcharaoui

Posted 2011-09-07T09:18:38.810

Reputation: 571

2I've a question about the bug mentioned in the EDIT paragrah: Which versions of clonezilla and partclone were effected by this bug? – pefu – 2015-12-10T08:26:49.000

5

Restore the image to a 160GB or larger harddrive ... could be virtual.
Boot that machine with PartedMagic Live CD.
Resize down the partition with parted.

Put drive in as a secondary drive in windows or Linux,
and resize using parted, gparted, or windows disk manager.

rjt

Posted 2011-09-07T09:18:38.810

Reputation: 878

1Moreover, a virtual drive can be put on compressed underlying storage so you don't actually need a 160GB or larger drive, only enough to hold the compressed data (~20GB or so?) – qasdfdsaq – 2015-07-06T13:31:48.163

I think that this is the easiest way to do it. – Sekhemty – 2013-05-08T20:43:27.673

2

I solved it with a Windows 10 image as follows

  1. Temporarly move some files if your source drive is nearly full.
  2. A drefragmented drive leaves more space for shrinking, so defrag c:\ through right clicking on the drive -> tools
  3. shrink c:\ through windows disk management as small as possible
  4. start Clonezilla, expert, device-device, local, select -icds and finally the -k1 option
  5. switch off and disconnect old drive
  6. restart with the new drive and hold shift on windows login, select restart -> troubleshooting -> startup repair

In the past the 4th step failed, but since 2015 clonezilla supports GPT with the -k1 option so I think this is the reason why this works, now:
http://clonezilla.org/downloads/stable/changelog.php

Clonezilla live 2.4.2-38 ... Proportition GPT partition layout could be created by the option -k1.

The 6th step is needed because Windows does not recognize the boot drive in the optimization tool (SSD trim) and will try to repair the drive randomly so something seems to be wrong in the boot sector/partition table but startup repair will fix it.

EDIT: I uploaded a video of the the complete process (German):
https://www.youtube.com/watch?v=GJ2LVY5ja-o

mgutt

Posted 2011-09-07T09:18:38.810

Reputation: 433

0

In my case -icds alone has not solved the problem. I don't know if the problem is exactly the same as mine. But I left here my cent.

I have tried a disc to disc clone from a 930GiB HDD (source drive) with a GPT partition table to 890GiB SSD (destination). Please note I am a Linux user and I have a dual boot with windows 10. I have tried to left unchanged all the partitions and to reduce slightly the size of my data partition only.

  1. With gparted, I resized the bigger data partition in order to have an overall size that fits the destination SSD, and moved all free space at the end
  2. I used clonezilla-Live from USB pen, with advanced mode and -icds enabled.

It failed. It looks like Clonezilla fails, at start, to clone the partition table to the destination disk because it wrongly uses sfdisk utility that is for older partition types instead of sgdisk utils. My solution:

  1. The same as previous (overall size must fit)
  2. I manually copied the partition from one drive to another, using Clonezilla shell with this command (only for GPT partitions!):

    sgdisk /dev/sdSourceDeviceName -R /dev/sdDestinationDeviceName

  3. Performed Clonezilla disc-to-disc clone, selecting the option -icds and the option to NOT CREATE a partition table on destination disk, option -k. (In this case Clonezilla uses the destination partitions as they are, and resizes partitions when sizes are smaller, in order to fit, it perform a good "best effort").

It worked. I obtained all the partitions the same size as source (Yes I only reduced the bigger partition a bit). Dual boot with windows keeps working well. Regards

Fabiano Tarlao

Posted 2011-09-07T09:18:38.810

Reputation: 153

0

If the space is not in use, go into expert mode and enable -icds then restore the image. It will skip the partition size check and will succesfully restore it (only if < 120 GB is in use).

Devator

Posted 2011-09-07T09:18:38.810

Reputation: 962

0

My situation:

  • Clonezilla image (of Windows 7) based on 128GB drive (100MB system partition + 117GB "C"),
  • new 120GB drive.

Following suggestions (like https://superuser.com/a/592283/229908) did not solve the problem for me.

What worked for me was:

  1. restore the image to another (larger) drive,
  2. defragment that drive (because it seems Clonezilla restores the data as was structured on the original drive, so possibly there won't be enough free space to shrink the partition to target size),
  3. shrink the partition (in my case, the 117GB "C") to the size of the target drive/partition (in my case 111GB) or, more safely, to a smaller size,
  4. install Windows 7 on the target drive (and have it create its system partition by using advanced options),
  5. use Clonezilla to restore each partition (with restorepart command) from the resized drive to the corresponding partition on the target drive.

The main trick why this worked was creating partition table (in my case done automatically by installing the Windows) that corresponds to the target drive, then just copying contents (via restorepart) which wouldn't touch the partitions configuration. So, even if the source partition that is being restored was smaller than the target, as partition table is not touched by restorepart, there is no need to "extend" the target partition after the operation.

Saran

Posted 2011-09-07T09:18:38.810

Reputation: 220