I’ve been looking for info on how to shrink/resize���or directly dd
—a 32GB USB flash drive I made for my Raspberry Pi into a 2G img file. I have resized the partitions, there’s one with Win32 FAT of 64M and the Linux partition is 2048Mb (2G), and all I want is just a dd
IMG file of around 2G.
I know there is the Gzip compression method, but once uncompressed it will unpack a 32GB img file and sometimes I don’t have that much space. I just want to be able to dd the file into a 2GB USB flash drive, without having a 32G file with just 2G used in it. Get it?
Also, I’m using a SSD, and I’ve read that /dev/zero
-ing the image file is kinda harmful, so I’m hoping there is an easier way to do it. I have Linux and Windows at my disposal, so I’m happy to hear suggestions!
Update: Unfortunately I made a mistake and replaced the USB flash drive with another drive, but I have the whole img file I just mounted to /dev/loop0
and ran fdisk -l
to it, here’s the output:
Disk flashrom32g.img: 29.8 GiB, 32010928128 bytes, 62521344 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xaebebc78
Device Boot Start End Sectors Size Id Type
flashrom32g.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
flashrom32g.img2 137216 4331519 4194304 2G 83 Linux
fdisk -l /dev/your_usb_key
please./compress maximum
flag when capturing the partition. I'd be interested in knowing the result.