Main > Raspberry Pi & Dev Board
How to make a dedicated MAME 0.250 Appliance on a Raspberry Pi 4/Pi 400
javeryh:
Question… I finally got everything set up exactly how I want and it’s running great. I used a 128GB memory card but do not need all that space. Is there a way to compress the image somehow so I can copy it over to a 32GB card? My current setup uses much less than 32GB.
When I did the initial installation I remember having to expand the image to account for the extra space in the memory card - so I guess now I want to reverse this process. As usual assume I know nothing LOL.
Thanks!
10yard:
--- Quote from: javeryh on December 09, 2021, 06:59:58 pm ---Question… I finally got everything set up exactly how I want and it’s running great. I used a 128GB memory card but do not need all that space. Is there a way to compress the image somehow so I can copy it over to a 32GB card? My current setup uses much less than 32GB.
When I did the initial installation I remember having to expand the image to account for the extra space in the memory card - so I guess now I want to reverse this process. As usual assume I know nothing LOL.
Thanks!
--- End quote ---
I've done this a bunch of times so will chime in to assist.
You can use the "pishrink" utility from https://github.com/Drewsif/PiShrink
You will need a USB storage device of greater capacity than the used space on the SD card you are attempting to shrink. EDIT: We will copy over the used space to an external USB storage device and then shrink it down as small as possible.
Steps to prepare the USB flash drive. It will be mounted to pi as a working area for performing the shrink.
* Format your USB flash drive as NTFS (assuming you are on Windows). Give the volume the name "USB". It will help us to identify the device when we mount it to the pi.
* Connect USB drive to your pi.
* Boot pi with SD card you want to shrink inserted
* Verify USB mounted. Your USB drive should be automatically mounted at /media/pi/USB. I don't have the appliance at the moment so can't be 100%. Give it a try.
--- Code: ---dir /media/pi/USB
--- End code ---
* if not found then you can query mount points using command
--- Code: ---lsblk
--- End code ---
Steps for the shrinking.
* Install pishrink utility
--- Code: ---wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
chmod +x pishrink.sh
sudo mv pishrink.sh /usr/local/bin
--- End code ---
* We now make a copy of the used allocation of your SD card. You should specify a slightly larger size to be safe, so if you've used 7.5GB of space I would round to 8GB (8000 blocks). Set the count= argument accordingly.
--- Code: ---sudo dd if=/dev/mmcblk0 of=/media/pi/USB/shrunk_my_junk.img bs=1M count=8000
--- End code ---
* All being well an image file was created on the USB drive. If the above command returns an error then increase the count and try again.
--- Code: ---cd /media/pi/USB
dir
--- End code ---
* Now we can shrinkify that image
--- Code: ---sudo pishrink.sh -z shrunk_my_junk.img
--- End code ---
That's it.
You should now have a shrunken image on your USB drive which you can copy to your PC and write to a smaller SD card.
Hope if works out for you.
javeryh:
This is great info. I will give this a shot this afternoon or tomorrow (stupid work calls are going to kill the rest of my day...).
For the USB drive that needs to be larger than the SD card I'm trying to shrink, it sounds like it only has to be larger than the USED space. So, for example, I have a 128GB microSD card but only using about 12GB of that space if I had to guess. So you are saying that I could use a 32GB USB drive to make this work, which is larger than the USED space on my 128GB microSD card? It doesn't need to be 256GB or something larger than my 128GB microSD card)?
Also, I assume I can use an external HDD or memory card for this (doesn't have to be a USB stick)?
Thanks!!
10yard:
--- Quote from: javeryh on December 10, 2021, 12:22:32 pm ---For the USB drive that needs to be larger than the SD card I'm trying to shrink, it sounds like it only has to be larger than the USED space. So, for example, I have a 128GB microSD card but only using about 12GB of that space if I had to guess. So you are saying that I could use a 32GB USB drive to make this work, which is larger than the USED space on my 128GB microSD card? It doesn't need to be 256GB or something larger than my 128GB microSD card)?
Also, I assume I can use an external HDD or memory card for this (doesn't have to be a USB stick)?
Thanks!!
--- End quote ---
The USB needs to be larger than the USED space, not larger than the SD card. Yes, in your scenario, a 16GB or 32GB drive should work. Basically, we are copying over the used space to an external device (USB storage) and then shrinking it down.
Any external USB memory should work if NTFS formatted. I use a 16GB USB stick, overkill for my 3GB of USED space on the card. I was able to shrink that down to 1.2GB image. Note that the image will be automatically packed into a tar.gz file to further reduce size. That file works directly with Rasp Pi Imager software.
javeryh:
Excellent. Thanks. I just ran a check on my card and it looks like I'm using less than 10GB. Am I reading this right even though Use% for /dev/root/ is 52% and /dev/mmcblk0p1 is 22%. I assume this is Use% of the different partitions, not the entire card (or the numbers wouldn't add up).
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version