I have several disk images stored at my fileserver at the moment, these are mainly system images created with dd. The reason for why I have created these images is because I needed the harddrive for something else, so I have created a image that I can later restore at the harddrive when it's available.

The problem is that the disk images are pretty size consuming, and there is a lot of free space inside of the images, so is it possible to shrink the images to only contain the actual content of the disk? Let me show you a example, I did mount one of the images to get an example.

Disk.img (500GB)
Disk.imgp1 (Total:1GB/Free:920MB) ext2 /boot
Disk.imgp2 (Total:4GB/Free:4GB) swap swap
Disk.imgp3 (Total:495GB/Free:390GB) ext4 /

As you guys can see, there is lot of free space but still the images takes up 500GB. Is there away to shrink it ~106GB, and then grow it back before restoring it on the harddrive again? Mainly I have images with GPT and DOS tables with EXT and NTFS partitions (Some of the partitions are encrypted with LUKS).


1 Answer 1


This tutorial appears to be what you're looking for. Essentially, you mount the disk image, use GParted to trim it down to size, and then use fdisk to truncate it.

  • 2
    Please edit your post to include the essential steps discussed in the link. :) Commented May 14, 2017 at 23:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .