Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Why not use a tool that doesn't have that limitation? –  joeqwerty Jan 18 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 at 17:29
    
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 at 2:14
    
@devicenull: Good thought. I don't see it as being feasible for our situation, though. –  poke Mar 14 at 3:51

2 Answers 2

up vote 1 down vote accepted

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
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.