Drewsif / PiShrink

Make your pi images smaller!
MIT License
3.51k stars 645 forks source link

Bad magic number in super-block while trying to open loop device #243

Open JohanNicander opened 2 years ago

JohanNicander commented 2 years ago

Setup

OS: Ubuntu 20.04.5 LTS (bare metal) sd-card OS: Raspberry Pi OS Light (64-bit)

Steps to reproduce error

Clone the sd card (same results using dd)

$ pv < /dev/sda > my-image.img

Run PiShrink

$ pishrink.sh my-image.img
pishrink.sh v0.1.2
pishrink.sh: Gathering data ...
tune2fs: Bad magic number in super-block while trying to open /dev/loop6
tune2fs 1.45.5 (07-Jan-2020)
pishrink.sh: ERROR occurred in line 298: tune2fs failed. Unable to shrink this type of image

Extra info

$ file my-image.img
my-image.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x40,0,1), end-CHS (0x3ff,3,32), startsector 8192, 524288 sectors; partition 2 : ID=0x83, start-CHS (0x3ff,3,32), end-CHS (0x3ff,63,32), startsector 532480, 30384128 sectors
$ fdisk -l my-image.img
Disk my-image.img 14.74 GiB, 15829303296 bytes, 30916608 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: 0x8b97fb85

Device         Boot  Start  End      Sectors  Size  Id Type
my-image.img1        8192   532479   524288   256M  c  W95 FAT32 (LBA)
my-image.img2        532480 30916607 30384128 14.5G 83 Linux
mount -t ext4 my-image.img /mnt -o loop,offset=272629760,ro
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/loop2, missing codepage or helper program, or other error.
fredrikfalkman commented 2 years ago

I have had the same problem running Pishrink on Mac, Ubuntu and Raspian. Also trying to compress Raspberry Pi OS Light (64-bit) 24Gb SD card.

Screen Shot 2022-10-14 at 00 35 17
Drewsif commented 1 year ago

So that error usually means the OS does not know what the partitions filesystem is. Can anyone confirm if the partition layout changed in the latest Raspberry Pi OS Light?

develcore commented 1 year ago

Same error.

OS: Debian Bullseye sd-card OS: Raspbian Buster mmcblk0p1 is fat32. mmcblk0p2 is f2fs.