I'm trying to shrink a partition on a 64GB SD Card down so that I can fit it on a 32GB USB thumb drive, but I'm not having any success. I have the SD card plugged into a USB adapter, which is plugged into a Raspberry Pi running Raspbian.
Here is the output of
Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes 4 heads, 16 sectors/track, 242560 cylinders, total 15523840 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 Disk identifier: 0x0002c262 Device Boot Start End Blocks Id System /dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA) /dev/mmcblk0p2 122880 15523839 7700480 83 Linux Disk /dev/sda: 63.9 GB, 63864569856 bytes 4 heads, 32 sectors/track, 974496 cylinders, total 124735488 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 Disk identifier: 0x000798a3 Device Boot Start End Blocks Id System /dev/sda1 4096 147455 71680 c W95 FAT32 (LBA) /dev/sda2 151552 124735487 62291968 83 Linux
It's /dev/sda2 that I want to shrink, but when I try
resize2fs /dev/sda2 20G I get:
resize2fs 1.42.5 (29-Jul-2012) resize2fs: Bad magic number in super-block while trying to open /dev/sda2 Couldn't find valid filesystem superblock.
I also tried shrinking the partition first via
fdisk and then running
resize2fs, but it failed with the same error message.
How can I shrink my partition?
PS. I have already imaged the card so I can restore should anything go wrong.