"Error: Can't have a partition outside the disk!" even though number of sectors is fine
Solution 1
Your image has 16267263 sectors, but the start and end sectors count from 0, so your partition extends one sector beyond the end of the image. Since the image appears to work fine you can probably fix it by appending 512 bytes to it.
Solution 2
I had the same problem and solved it with using the same technique (using dd
with if=/dev/zeros
to expand the image). I post the commands just for future reference:
user@host $ sudo fdisk -l -u=sectors hdd.img
Disk hdd.img: 465.8 GiB, 500107861504 bytes, 976773167 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: 0x8342379a
Device Boot Start End Sectors Size Id Type
hdd.img1 * 2048 718847 716800 350M 7 HPFS/NTFS/exFAT
hdd.img2 718848 210434047 209715200 100G 7 HPFS/NTFS/exFAT
hdd.img3 210434048 211435519 1001472 489M 83 Linux
hdd.img4 211435520 976773167 765337648 365G 8e Linux LVM
user@host $ sudo parted hdd.img unit s print
Error: Can't have a partition outside the disk!
Ignore/Cancel? Ignore
Error: Can't have a partition outside the disk!
Ignore/Cancel? Ignore
Model: (file)
Disk hdd.img: 976773167s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 718847s 716800s primary ntfs boot
2 718848s 210434047s 209715200s primary ntfs
3 210434048s 211435519s 1001472s primary ext2
4 211435520s 976773167s 765337648s primary lvm
Using dd
to add one 512 bytes sector:
dd if=/dev/zero bs=512 count=1 >> hdd.img
afterwards parted
does stop giving errors:
user@host $ sudo fdisk -lu hdd.img
Disk hdd.img: 465.8 GiB, 500107862016 bytes, 976773168 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: 0x8342379a
Device Boot Start End Sectors Size Id Type
hdd.img1 * 2048 718847 716800 350M 7 HPFS/NTFS/exFAT
hdd.img2 718848 210434047 209715200 100G 7 HPFS/NTFS/exFAT
hdd.img3 210434048 211435519 1001472 489M 83 Linux
hdd.img4 211435520 976773167 765337648 365G 8e Linux LVM
user@host $ sudo hdd.img unit s print
Model: (file)
Disk hdd.img: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 718847s 716800s primary ntfs boot
2 718848s 210434047s 209715200s primary ntfs
3 210434048s 211435519s 1001472s primary ext2
4 211435520s 976773167s 765337648s primary lvm
Related videos on Youtube
rbaleksandar
Updated on September 18, 2022Comments
-
rbaleksandar over 1 year
I am looking at an image file which was created using
dd
with an SD card with Raspbian (with Qt 5.7 on it that I compiled a while ago) as input. When invokingsudo parted raspbian_jessie_qt5.7_all_modules.img unit s print
I get
Error: Can't have a partition outside the disk!
I checked the partitions using
fdisk
usingsudo fdisk -lu rasp_jessie_qt5.7.img
with the following output
Disk rasp_jessie_qt5.7.img: 7.8 GiB, 8328838656 bytes, 16267263 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: 0x65a3fac2 Device Boot Start End Sectors Size Id Type rasp_jessie_qt5.7.img1 8192 131071 122880 60M c W95 FAT32 (LBA) rasp_jessie_qt5.7.img2 131072 16267263 16136192 7.7G 83 Linux
When I look at this I have 16267263 sectors as the upper limit while the FS where Rasbian resides ends at the 16267263th sector (that is at the edge of the available upper limit). The number of sectors in total is 16136192.
I can use
dd
withif=/dev/zeros
to expand the image and then expand the Linux FS in it but 1)I'm not sure if this will fix the problem and 2). I would really like to stick to the size of the original image that is approx. 7.7GB.Any ideas what I have overlooked and how to fix it?
Note that I have no issues writing the image to the SD card, booting my Rasbian (the SD card is 32GB in total) and working with it.
-
rbaleksandar over 7 yearsThanks. Worked like a charm. Use
/dev/zero
to append those 512 Bytes and nowparted
doesn't complain.