Compressing Ras Pi SD card image

I'm find it impossible to do this at the moment, and I need to do so, because I
was surprised to find that SC card I'd built on is just about the max possible
for 16G, so the image won't fit on any others of that nominal size :(
The PiShrink utility seems to do the compression, but the image doesn't work
when put on another card.
I'm wondering if it has anything to do with the fact that this is a devuan
beowulf build not debian. Just to make it more 'interesting' I can no longer
find the image I originally got off the 'net :(
If I ever get to recover this, I'll find an 8G card for the reference build!
--
W J G
Reply to
Folderol
Loading thread data ...
Not all 16G SD cards are of exactly the same size, they may be a couple of Megs smaller or larger. You may want to try to write onto the new card with the "USB Image Tool" and the option "Truncate oversize images..." set to on. This worked for me on a couple of occastions.
- j -
--
Mail address is valid for a limited time only. 

And now for something completely different...
Reply to
Joerg Walther
I would not recommend that, although it might appear to work initially, you will have problems when you come to use partition or filing system tools on such a card.
Far better is to use GParted on the original card to shrink it by a couple of MB until it small enough to fit on the card you want to copy it to.
---druck
Reply to
druck
Fsarchiver can restore one of its file system archives to a differently sized partition, however if you have multiple partitions then you'll need to create an equivalent partition table on the new card manually.
--
__          __ 
#_ < |\| |< _#
Reply to
Computer Nerd Kev
Thanks for all the suggestions. fsarchiver looks like the best bet. I've seen a crib sheet on-line specifically for the Pi using it to compress the main partition, with added instructions to get the FAT one, then how to recombine them on a new card.
This looks promising. I'll try that, and if it works, I'll get an 8G card and flash to that as my development card, after which (hopefully) I can just use the dumb DD method to put copies on 16G cards.
--
W J G
Reply to
Folderol
Dana Sun, 27 Jun 2021 15:03:10 +0100, Folderol napis'o:
This should not be done on the live system... use another Linux system (another card on the Pi or another machine with Linux).
Use resize2fs to shrink it to minimal possible size. Test if it still works. Copy the whole card to the bigger one. Use partition editor to make the partition bigger. Use resize2fs to resize the file system in the bigger partition.
And it should work.
Reply to
Nikolaj Lazic
Thanks everyone for the suggestions, but somehow all of them failed.
The good news is that I was eventually able to find a compressed image of a recent (May 2021) build of 64 bit devuan beowulf. I've tested this on one of my 16G cards and with all the extras I needed for my project it worked perfectly, even though the image is classed as 'experimental'. Also I now know that the completed build uses less the 4G of the card in total. Therefore the idea of getting an 8G card and building on that as my reference, then flashing to 16G ones is perfectly feasible.
The project in question is a softsynth one, that I call the YoshimiPi. Here it is working along with the Rosegarden sequencer.
formatting link

It's pumping out 48kHz 16 bit audio without a single Xrun :) CPU temperature is just under 60deg C, and that's without a heatsink.
--
W J G
Reply to
Folderol
Did you remember to expand the installed filesystem to fill up the card?
--

-TV
Reply to
Tauno Voipio
Not necessary with the original install as this automatically expands a first time startup. However, even then fsck reports a bad superblock (although the image runs perfectly well in the Pi). trying to correct this or change the size just seems to stop it working completely.
Bearing in mind the space actually used, even with an 8G card as the reference one, that still gives over 4G of space for user data.
A collection of over 100 combined Yoshimi + Rosegarden projects is less that 2G so I don't see the wastage as a problem - besides, should you really trust that much data to an SD card?
--
W J G
Reply to
Folderol
This means that your way of shrinking the image is not too good.
If you have another Linux computer with enough memory to store the image, the steps are:
1. Loop mount the image:
sudo losetup -f -P path_to_the_image
2. Check loop setup:
sudo losetup
3. Run gparted on the loop device:
gparted /dev/loopx
where loopx is the device shown on the last losetup
4. Select the ext4 partition and shrink it moving the top limit down. There must be some free space left on the shrunk part. gparted knows to complain if the suggested size is too small.
After shrinking, select 'information' from the 'Partition menu' and note 'Last sector' number. Remember to save the update partition table.
5. Exit gparted and undo loop setup:
sudo losetup -D
6. The size of the new image is the 'Last sector' number + 1 bytes. Truncate the image:
truncate -s the_new_size path_to_image
That's it.
Of course, we need all the utilities necessary for loop setup, GNU parted and truncate.
The partition resize could be done with resize2fs, and gparted uses it. I find it easier to let gparted create the correct commands for the low-level utilities.
--

-TV
Reply to
Tauno Voipio
first
the
he size
erence
that 2G
st that
Thanks for the info, but it's not me doing the initial shrink. That's the devuan image. I simply used the recommended dd command to copy it across to the card.
partitionmanager will then report:
"Device found: Multi Flash Reader" getting smart status failed for "/dev/sdc" : Operation not supported "Partition ?/dev/sdc2? is not properly aligned (last sector : 3808592, modulo: 1361)."
However, on inserting the card in the pi, it will self expand and run quite normally.
--
W J G
Reply to
Folderol

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.