1

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).

nerd7473
  • 115

1 Answers1

1

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.