19

A recurring problem we have is that the computers we use to build our master images on may have larger hard drives than some of the target systems' drives. Its well-known that Clonezilla won't put a disk image on a smaller drive.

Outside of finding a physical drive that is smaller/as small as all of our target systems, I've used this method to get around our problem:

  1. After preparing the master computer, use gparted to shrink the partition(s) so they will all fit on the smaller size disk.
  2. Create a VM with a hard drive of the target size.
  3. Create the right partition(s) on the VM by installing a copy of the target OS on the VM.
  4. Use the save/restore partition functionality in Clonezilla to copy each partition from the master computer to the VM.
  5. Create an image of the VM. Use this image as the golden master for imaging computers.

Is there any way to use gparted (or another program) to resize the master drive before cloning it? I know how to resize individual partitions, but it would be really, really handy if I could do something to make Clonezilla think the original drive was smaller. That way I could use the restore disk functionality to make an image that was small enough for all target systems.

Due to various issues, building the master image directly in a VM is not feasible for our situation.

poke
  • 1,079
  • 4
  • 11
  • 21
  • Why not use a tool that doesn't have that limitation? – joeqwerty Jan 18 '14 at 17:25
  • @joequerty: Clonezilla is the only hammer I know about that I can get the company to pay for. I'm open to other options if they don't have licensing fees on the number of cloned systems created with the image. – poke Jan 18 '14 at 17:29
  • 1
    Is scripting the entire install process an option? If you can come up with a scripted install for all your software, you can just do raw OS installs and avoid all the problems associated with images. – devicenull Mar 14 '14 at 02:14
  • @devicenull: Good thought. I don't see it as being feasible for our situation, though. – poke Mar 14 '14 at 03:51

6 Answers6

13

Inside every clonezilla image, there is a file called sda-pt.parted. You can edit the sector size of /dev/sda to be smaller than your target hard drive.

Here is how we do it:

  1. Install OS and programs
  2. Shrink partition in OS to lowest possible value (we find under 80 works best)
  3. Sysprep and clone
  4. Edit image/sda-pt.parted

Below is a sample of an edited sda-pt.parted file

Model: ATA ST31000524AS (scsi)
Disk /dev/sda: 78200000s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start    End        Size       Type     File system  Flags
1      2048s    206847s    204800s    primary  ntfs         boot
2      206848s  78135295s  77928448s  primary  ntfs

Original:

Model: ATA ST31000524AS (scsi)
Disk /dev/sda: 1953525168s
AWippler
  • 1,055
  • 1
  • 12
  • 32
  • This is a most unconventional way to go about this, but it is the only way that I could get to work properly. Attempting to use the "resize partition table proportionally" option just didn't work at all. – DaveTheMinion Dec 02 '17 at 20:43
5

In creating your Master Image, resize the partitions or "total non Free space area" to be smaller than your smallest target drive will be.

Use the expert mode instead of beginner in Clonezilla.

If you are sure all the data from the image could fit the smaller disk, add the option "-icds"

CloneZilla will work fine Imaging to a smaller drive than the image was created on.

justdon
  • 51
  • 1
  • 1
2

The other fix provided here worked for me. The file to edit is image/sda-pt.parted inside the image folder itself.

In that file, just shrink number in the line that says

Disk /dev/sda: #########s

If you know the target size you want in bytes, you can divide by the sector size to get the number of sectors you want. In my case, I'd built out a 40GB system with 40GB partitions but it was on a 320GB drive. Sure enough, just changing the disk size to 40GB / 512 sectors (40000000000/512=78125000s) did the trick.

Alternatively, you can just look at the end of your partition table in that file and use a number just bigger than that the endpoint of your last partition.

I should also note that none of the options I found when I searched clonezilla help for pushing bigger images to smaller drives worked ("expert mode", resize, etc.). It seems like the best approach is to build your image, then adjust the disk size to be as small as possible before pushing.

Tom Hinkle
  • 21
  • 1
2

We started using a 64Gb SSD to build our images. We have a drive reserved for this purpose. When building a new image, we first put this drive in the computer to be used as a template. We find this also helps us produce and capture images faster, as well as ensuring the resulting image will fit in any system we have in service.

Joel Coel
  • 12,910
  • 13
  • 61
  • 99
0

I found that editing the files did not work and was problematic. Clonezilla (current rev 2.6.0-37) does support restoring to a smaller destination per the following guide.

chipazzo
  • 1
  • 1
-1

Edit image/sda-pt.parted inside the image folder does not work with Clonezilla 20170905-zesty.

https://sourceforge.net/p/clonezilla/support-requests/65/

Option "-C" is for Partclone only. Therefore you can not find it in Clonezilla expert mode. However, if you turn on "-icds" and "-k1" of Clonezilla, it will use the option "-C" for partclone when running partclone.

BTW, to restore an image for that saved in a larger disk to smaller disk might not work. You have to make sure all the used blocks are within the boundary, and the partition table layout can not be too complicated so that Clonezilla is able to deal with that.

See advanced parameters for restoring mode: http://clonezilla.org/clonezilla-live/doc/02_Restore_disk_image/advanced/09-advanced-param.php

flywire
  • 101
  • 1