Partition

GPT 分區表中是否有擴展分區?

  • April 3, 2019

在 MBR 模型下,我們可以創建四個主分區,其中一個可以是進一步細分為邏輯分區的擴展分區。

考慮取自維基百科的這個 GPT 示意圖:

GPT

分區條目範圍從 LBA 1 到 LBA 34,大概我們用完了那個空間,我知道這是相當數量的分區,如果磁碟使用 GPT 分區,是否可以創建擴展分區?如果可能,我們可以為每個 GPT 分區表創建多少個擴展分區?

我不確定這是否是在 LBA 1 到 LBA 34 範圍內具有分區條目的標準,也許我們可以將分區條目擴展到此之外?

實際上這是相當數量的分區,我無意這樣做。

128 個分區是 GPT 的預設限制,在實踐中使用一半的分區可能會很痛苦……

Linux 本身最初在其設備命名空間中也有一些限制。對於 /dev/sdX,它假定不超過 15 個分區(sda 是 8,0,sdb 是 8,16,等等)。如果有更多分區,它們將使用 259,X aka Block Extended Major 表示。

您當然仍然可以通過各種方式進行更多分區。循環設備、LVM,甚至 GPT 內的 GPT。有時,當將分區作為塊設備交給虛擬機時,這種情況會自然發生,他們將分區視為虛擬磁碟驅動器並對其進行分區。

只是不要期望分區內的此類分區會被自動拾取。


正如@fpmurphy1 在評論中指出的那樣,我錯了:您可以使用gdisk, expert menu,更改限制resize partition table。這也可以對現有的分區表進行,前提是在驅動器的開始和結束處有未分區的空間(一個 512 字節的扇區用於 4 個額外的分區條目)。但是,我不確定這得到了多麼廣泛的支持;parted在我嘗試過的其他分區器中似乎沒有它的選項。


您可以設置的最高限制gdisk似乎是,65536但它有問題:

Expert command (? for help): s   
Current partition table size is 128.
Enter new size (4 up, default 128): 65536
Value out of range

進而…

Expert command (? for help): s   
Current partition table size is 128.
Enter new size (4 up, default 128): 65535
Adjusting GPT size from 65535 to 65536 to fill the sector

Expert command (? for help): s
Current partition table size is 65536.

誒?不管你說什麼。

但是嘗試保存該分區表並gdisk在循環中停留幾分鐘。

Expert command (? for help): w

--- gdisk gets stuck here ---
     PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND    
   22253 root      20   0   24004  11932   3680 R 100.0  0.1   1:03.47 gdisk      
--- unstuck several minutes later ---

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Your option? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/loop0.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

以下是parted關於成功完成的操作的說明:

# parted /dev/loop0 print free
Backtrace has 8 calls on stack:
 8: /usr/lib64/libparted.so.2(ped_assert+0x45) [0x7f7e780181f5]
 7: /usr/lib64/libparted.so.2(+0x24d5e) [0x7f7e7802fd5e]
 6: /usr/lib64/libparted.so.2(ped_disk_new+0x49) [0x7f7e7801d179]
 5: parted() [0x40722e]
 4: parted(non_interactive_mode+0x92) [0x40ccd2]
 3: parted(main+0x1102) [0x405f52]
 2: /lib64/libc.so.6(__libc_start_main+0xf1) [0x7f7e777ec1e1]
 1: parted(_start+0x2a) [0x40610a]


You found a bug in GNU Parted! Here's what you have to do:

Don't panic! The bug has most likely not affected any of your data.
Help us to fix this bug by doing the following:

Check whether the bug has already been fixed by checking
the last version of GNU Parted that you can find at:

   http://ftp.gnu.org/gnu/parted/

Please check this version prior to bug reporting.

If this has not been fixed yet or if you don't know how to check,
please visit the GNU Parted website:

   http://www.gnu.org/software/parted

for further information.

Your report should contain the version of this release (3.2)
along with the error message below, the output of

   parted DEVICE unit co print unit s print

and the following history of commands you entered.
Also include any additional information about your setup you
consider important.

Assertion (gpt_disk_data->entry_count <= 8192) at gpt.c:793 in function
_parse_header() failed.

Aborted                                                                   

所以parted拒絕使用超過 8192 個分區條目的 GPT。從來沒有人這樣做過,所以它一定是腐敗的,對吧?

當您不堅持預設設置時,就會發生這種情況。

引用自:https://unix.stackexchange.com/questions/382719