Thursday, December 6, 2018

VirtualBox: shrink Clonezilla disk image

I've spent some time until I finally found out how you can not only increase the disk image but also how to shrink it.

Use case:
I had an disk backup created with clonezilla. The source disk size was 1TB and the restore disk size was 256GB. The actual data amount was around 120GB, so it would definitely fit on the smaller disk.
But with clonezilla, I wasn't able to restore it.


To be able to restore such an image, I used virtualbox to prepare new, smaller disk backup.

I did create dynamic disk (size 1TB) and restored original backup with clonezilla.
After that I've  booted GParted live CD and downsized and moved all partitions, so they will fit on an 256GB disk.

Next step is to create smaller virtualbox disk (256GB). You can do that via virtualbox GUI.

Final step is cloning the medium.
With list hdds you can see the source (7a53...) and target (5938...) disk IDs and use clonemedium disk to actually copy the data to a smaller disk:

vboxmanage list hdds
vboxmanage clonemedium disk 7a53e3b2-cf34-41a4-990b-e5b249b00d20 59381f66-1c2c-4dd9-8f8c-3c424fa99001 --existing

After you have your cloned data, boot clonezilla and create new disk backup.

1 comment:

  1. Excellent, thank you!
    Just want to stress the --existing in the clonemedium disk command - easy to loose it, somehow hidden after the two long UUID

    ReplyDelete