Drewsif / PiShrink

Make your pi images smaller!
MIT License
3.5k stars 644 forks source link

Error: Can't have a partition outside the disk! #252

Closed kevinzezel closed 1 year ago

kevinzezel commented 1 year ago

Hi,

I got this error:

sudo ./pishrink.sh -z myimg.img myimg_new.img 
pishrink.sh v0.1.2
pishrink.sh: Copying myimg.img to myimg_new.img... ...
pishrink.sh: Gathering data ...
Error: Can't have a partition outside the disk!
pishrink.sh: ERROR occurred in line 281: parted failed with rc 1
pishrink.sh: Possibly invalid image. Run 'parted myimg_new.img unit B print' manually to investigate ...

Regards, Kevin

shatteredsword commented 1 year ago

can you show the output of running this command: parted myimg.img unit B print

robertoschwald commented 1 year ago

Same problem here:

> parted sdcard.img unit B print
Error: Can't have a partition outside the disk!
Drewsif commented 1 year ago

How did you take the image of your sdcard

robertoschwald commented 1 year ago

Tried dd, now I make a copy using ddrescue. Stay tuned.

sante85 commented 9 months ago

@Drewsif same problem. root@edge-device:~# sudo pishrink.sh bb/rpi.img bb/rpi-shk.img pishrink.sh v0.1.4 pishrink.sh: Copying bb/rpi.img to bb/rpi-shk.img... ...

pishrink.sh: Gathering data ... Error: /root/bb/rpi-shk.img: unrecognised disk label pishrink.sh: ERROR occurred in line 288: parted failed with rc 1 pishrink.sh: Possibly invalid image. Run 'parted bb/rpi-shk.img unit B print' manually to investigate ...


root@edge-device:~# parted bb/rpi.img unit B print Error: /root/bb/rpi.img: unrecognised disk label Model: (file) Disk /root/bb/rpi.img: 4294966784B Sector size (logical/physical): 512B/512B Partition Table: unknown Disk Flags:

sante85 commented 9 months ago

@robertoschwald have you resolved? @Drewsif how to fix?

quyenvsp commented 6 months ago

it mean your image bad, simple fix error parted sdcard.img unit B print throw.

For Error: Can't have a partition outside the disk! just correct sectors then try pishrink again.

fdisk -l -u=sectors sdcard.img

# result
Disk sdcard.img: 1.84 GiB, 1975517696 bytes, 3858433 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: 0x3a3113ee

Device      Boot Start     End Sectors  Size Id Type
sdcard.img1 *     2048   34815   32768   16M 83 Linux
sdcard.img2      34816 3862527 3827712  1.8G 83 Linux

Total sectors (3858433) should equal End of last device (3862527) +1

But 3858433 != 3862527 + 1

so missing 3862527 + 1 - 3858433 = 4095 sectors

dd if=/dev/zero bs=512 count=4095 >> sdcard.img
parted sdcard.img unit B print
# should work without any errors