问题和背景:
在像ubuntu-16.04-desktop-amd64.iso这样的发行版的MBR分区表中,为什么GPT分区似乎与主引导分区重叠?如果我尝试以任何方式编辑分区表,这似乎会产生错误。
我想编辑MBR以添加USB持久性(如其他地方所述),必须添加一个分区或扩大引导分区。
我相信这曾经有效,但是在这个和类似的发行版中,重叠的GPT #2分区似乎严重困扰了fdisk、sfdisk、parted、gparted和partprobe。
我的机器是MBR,而不是GPT BIOS。
我错过了什么?
以下是发行版的MBR分区表(直接来自ISO文件):
cat ubuntu-16.04-desktop-amd64.iso | xxd | head -32 | tail -5
给:
00001b0: 28db 2b00 0000 0000 708e 0e0e 0000 8000 (.+.....p.......
00001c0: 0100 0058 e0fa 0000 0000 6048 2c00 00fe ...X......`H,...
00001d0: ffff effe ffff 4411 2c00 8012 0000 0000 ......D.,.......
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
(要解码,请参见https://en.wikipedia.org/wiki/Master_boot_record。)
表格从地址01be开始,您会看到"80",表示第一个主引导分区。
然后请注意地址01d2处的"ef",表示第二个主分区的类型为GPT。
这是一个按分区(小端)的表格细分:
partition#1 (normal MBR):
80 = 'boot' partition flag
00 01 00 = starting HSC (head, sector, cylindar)
00 = partition type ("Empty partition entry")
58 e0 fa = last HSC (head, sector, cylindar)
0000 0000 = LBA (logical block address) of first absolute sector in the
6048 2c00 = number of sectors in partition
partition #2 (GPT):
00 = non-boot partition
fe ff ff = starting HSC (head, sector, cylindar)
ef = partition type ("EFI system partition")
fe ff ff = last HSC
4411 2c00 = LBA (logical block adr) of first abs sector in part.
8012 0000 = number of sectors in partition
尝试编辑分区表:
fdisk
报告这些分区重叠。请注意,sdb2的起始位置[2927216]在sdb1 [0-2955679]内。sudo fdisk -l /dev/sdb
输出如下:
Disk /dev/sdb: 14.5 GiB, 15527313408 bytes, 30326784 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: 0x40a863e7 Device Boot Start End Sectors Size Id Type /dev/sdb1 * 0 2955679 2955680 1.4G 0 Empty /dev/sdb2 2927216 2931951 4736 2.3M ef EFI (FAT-12/16/32)
根据我所了解,拥有GPT分区是可以的,但是分区重叠是不允许的。
当我尝试将ISO文件复制到USB闪存驱动器时,问题就开始了。闪存驱动器可以正常启动Ubuntu Live,但是无论我使用哪个分区编辑器,在未引导和未挂载的情况下都无法编辑分区表。
此外,即使我删除了分区表并将USB闪存驱动器恢复到正常状态,也需要进行以下冗长的步骤:
dd if=/dev/zero of=/dev/sdb bs=[类似512或2048的数字;无关紧要] count=[类似100000的大数字]
^较小的数字似乎并不能解决这个问题。我怀疑您不仅需要清除主要的文件系统块,还需要清除次要的文件系统块。
然后使用
fdisk
在闪存驱动器上创建一个新的MS-DOS分区表。请注意,如果在创建新的分区表之前不执行上述dd命令以进行擦除,则在尝试编辑分区映射时(无论是来自debian8还是ubuntu-16),都会收到以下错误消息或类似消息:
Libparted Warning The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
另外,在ubuntu-12中,我收到了这条最有启发性的消息:
gparted -l /dev/sdb: libparted : 2.3 Could not stat device -l -- No such file or directory. /dev/sdb contains GPT signatures, indicating that it has a GPT table. However, it does not have a valid fake msdos partition table, as it should. Perhaps it was corrupted -- possibly by a program that doesn't understand GPT partition tables. Or perhaps you deleted the GPT table, and are now using an msdos partition table. Is this a GPT partition table? Both the primary and backup GPT tables are corrupt. Try making a fresh table, and using Parted's rescue feature to recover partitions.
所以我该如何编辑发行版的MBR?
顺便说一下,我不是在问如何修复重叠的问题,因为这实际上是发行版的方式,并且从外观上看,已经有一段时间了(我还看过Ub-v16、14和12),我只是想弄清楚是否可能编辑它。
想法:
- 这可能是由于使用isohybrid太多次(用于将ms-dos MBR添加到CDROM 9660 iso以便在USB上引导)引起的吗? - 是否有其他可能更新的分区表编辑器可供使用? - 是否有其他不会出现此问题的不同版本的Ubuntu发行版?