我正在查看一個使用dd
SD 卡創建的映像文件,並以 Raspbian(上面有我不久前編譯的 Qt 5.7)作為輸入。呼叫時
sudo parted raspbian_jessie_qt5.7_all_modules.img unit s print
我明白了
Error: Can't have a partition outside the disk!
fdisk
我使用以下命令檢查了分區
sudo fdisk -lu rasp_jessie_qt5.7.img
具有以下輸出
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
當我看到這個時,我有16267263 扇區為上限,而 Rasbian 所在的 FS 結束於16267263號部門(即處於可用上限的邊緣)。扇區總數為16136192。
我可以使用dd
withif=/dev/zeros
來擴展映像,然後擴展其中的 Linux FS,但 1) 我不確定這是否會解決問題,2)。我真的很想堅持原始圖像的大小約為。 7.7GB。
我忽略了什麼想法以及如何解決它?
請注意,將映像寫入 SD 卡、啟動 Rasbian(SD 卡總共 32 GB)並使用它沒有任何問題。
答案1
您的映像有 16267263 個磁區,但起始和結束磁區從 0 開始計數,因此您的分割區將一個磁區延伸到映像末端之外。由於圖像看起來工作正常,您可以透過向其附加 512 位元組來修復它。
答案2
我遇到了同樣的問題,並使用相同的技術解決了它(使用dd
withif=/dev/zeros
來擴展圖像)。我發布命令僅供將來參考:
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
用於dd
新增一個 512 位元組磁區:
dd if=/dev/zero bs=512 count=1 >> hdd.img
之後parted
確實停止給出錯誤:
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