I figured I would start a new topic as none of this pertains to the previous messages I posted.
I've got an almost 30-GB disk image of a working debian installation for a Raspberry pi that I should be able to easily squeeze on to a roughly 8 GB SSD card because it only takes up 10% of the 30-GB card and I think I am close but not there yet. Because I hate drudgery with regards to syntax, I wrote a little shell script that makes it easier to duplicate the same actions and also makes it easy to show exactly what is happening so far. The big image name is rpi1_good.img and it is 29 gb in size. Here are the commands that work so far. #!/bin/sh #This resets everything for a new run. sudo losetup -d /dev/loop0 #copy a backup to the image name to start fresh. sudo cp -p rpi1_good.img.bak rpi1_good.img #This takes about half an hour. Now, get to business. sudo losetup -P /dev/loop0 rpi1_good.img #This should show 2 partitions on loop0 when successful. sudo ls -l /dev/loop0* #You get /dev/loop0p1 and p2 #e2fs is required to run before one can resize. sudo e2fsck -f /dev/loop0p2 #I should be telling resize2fs to squeeze everything in to a 7GB #partition. sudo resize2fs /dev/loop0p2 +7G There are no complaints up to this point and resize appeared to work so now it is time to reduce the size of partition 2. This may be where things go off the track. I run sudo fdisk /dev/loop0 and fdisk tells me it is 29.9 GB which I expected since Partition #2 should be mostly empty but for the OS and my login directory. I note that the starting sector for P2 is 137215 since one must start at that sector and then I delete P2 and then add a new partition which defaults to 2. fdisk prompts for the first sector with a default of 2048 but I type in 137215. The last sector is in the 62-million range and I want only 7 GB as the size so I type +7G and it takes that. I then type w to save the changes and there is no complaint. The first hint of trouble is when you do fdisk -l /dev/loop0. The size count is still almost 30 GB but then a ray of Sun in that P2 has a size of around 7 GB. I outwitted Murphy this time by using another file on my computer as the target rather than the SSD card so that if it went over 8 GB, nothing annoying would happen. I watched on another console as the size climbed past 5 GB, then 6 and 7 GB and then it was up past ten so it was going to do the whole 30 GB if I hadn't stopped it. I am not sure what I missed but the manual page for resize2fs warns you to use something like fdisk to trim off the excess empty space which is what I thought I did. I would also have thought that the disk image file should have deflated like a punctured air mattress but it didn't. I think I am almost there but obviously not yet. Thanks in advance for ideas. Martin