How to best resize an .img file?
-
I want to copy over my arcade setup for my friend, however, the memory card I ordered him is slightly smaller than mine. They are both 16GB but his is a few sectors smaller. Not even half of the memory card is in use, so there is plenty of free space.
Is there a simple way to resize the image file to shave off some size so I can copy my setup over?
Was reading up on resize2fs, but doesn't seem like you can resize a mounted image.
-
-
@exonerated This script will shrink the .img.
https://retropie.org.uk/forum/topic/6470/script-to-resize-shrink-win32-disk-imager-retropie-images
-
@Floob I actually set up a dual boot on my Windows PC with Debian just so I could do this using gparted. I could have used a live CD/DVD or even a bootable USB but I had the space and wanted to muck about with lunux on a (slightly) more powerful machine than the Pi.
-
@exonerated Don't try and shrink a mounted image. 9 times out of 10 you will corrupt it. Or you could get lucky. Get access to a Linux machine or use a live bootable Linux distro CD/DVD and use gparted. It's really simple, once it's all set up.
-
@columboscoat I totally agree!
I wrote a guide ..... long long time ago ... how to resize fs (with gparted live) and how to create IMG on Windows PCs
I used this method and it worked several times. You can get the sector size even on the gparted system.Imho you are punished by using Windows systems and doing filesystem operations on Unix systems :)
-
Is there an mac option for this?
-
QUESTION
Let's say we are working with a 128gb microSD card. If we are trying to create our own custom 64gb image, and according to the 'dm' command, we appear to be within 64gb image territory: What is the best practice for determining space used prior to writing with Win32 Disk Imager and Shrinking the image? The entire process takes two hours and its extremely frustrating when it Pi Shrink returns a shrunken image thats still too big to fit on a 64gb card.
-
@sigmanutz Ideally you'd look at the dimension of the 64Gb drive with
df
and note the number of total blocks of the/
partition, then compare to thedf
output from your 128Gb card (also in blocks) and note the number of blocks used.
But, just to make sure, just backup the biggest ROMs folder to your PC and you're sure to get a smaller image and the creation process will also be shorter. You can then move back the ROMs to the new system.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.