I am backing up data from an old hard drive one partition at a time to .img files using dd.
sudo dd if=/dev/sdc5 of=/home/flex/data/partition.img bs=1M status=progress
This gives me a 10GB .img file but I know there is only 3GB data on the partition.
The partition is FAT32 and contains a Windows XP OS.
I loop mount the .img file... it appears at /dev/loop7
sudo losetup --find partition.img
Then open in GParted..
sudo gparted /dev/loop7
Now in Gparted when I go to resize the partition it appears to work and gives no errors but I don't think it actually changes anything. The .img file is still 10GB and this command shows that the size of the partition is still 10GB..
sudo parted /dev/loop7 unit s print free
I thought there would unallocated partition space that I could then do...
truncate --size=$[(End Sector+1)*512] partition.img
What am I doing wrong?
I guess my alternative is to TAR the whole partition.img and then extract to a blank .img file but I want to know if this method with GParted is possible because it seems like a convenient way to resize a .img file for storage.