I used dd
on a drive of mine that I am building my Linux distribution on. I have an issue, how do I prep that iso (of a 256GB drive (so I have a 256GB ISO image file)) to be of a smaller size (get rid of the empty space).
1 Answer
You might attach the image using losetup
and use any partition tool to resize partitions. After that, you can safely truncate the image.
For a tutorial, you can refer to: https://softwarebakery.com/shrinking-images-on-linux
From the link above:
# modprobe loop
# losetup -f
# losetup /dev/loop0 myimage.img
# partprobe /dev/loop0
Now you can resize partitions on disk (eg. using gparted /dev/loop0
), keeping the empty space at the end. Then close the loop image:
# losetup -d /dev/loop0
and use truncate
to truncate the file at a specific size.
dd
. Do you also want the resulting image to fit into smaller disks? Or just to take less space where you store it? What is the partition layout of the source drive (and thus of the image)?