Linux命令之gdisk


gdisk -l [設備]

  gdisk又叫GPT fdisk,算是fdisk的延伸吧,主要使用的是GPT分區類型,用來划分容量大於2T的硬盤。

  擴展1:分區類型GPT和MBR。GPT最大支持18EB(1EB=1024PB,1PB=1024TB),MBR最大支持2TB。

  擴展2(了解):GPT,全局唯一標識分區表(GUID Partition Table),它使用128位GUID來唯一標識每個磁盤和分區。與MBR存在單一故障點不同,GPT提供分區表信息的冗余,一個在磁盤頭部,一個在磁盤尾部;它通過CRC校驗來檢測GPT頭和分區表中錯誤與損壞。默認一個硬盤支持128個分區(可以更多)。

(1).選項

只有一個-l選項,列出一個磁盤的所有分區表

(2).操作菜單說明

  主要用到的幾個和fdisk差不多:n、p、q、w。

  完整的菜單如下:

b 將GPT數據備份到一個文件
c 更改分區名稱
d 刪除一個分區
i 顯示分區詳細信息
l 列出已知分區類型。此處8200是Linux swap,8300是Linux filesystem(對應fdisk的82和83)。還有一個8e00是Linux LVM
n 增加一個新的分區
o 創建一個新的空白的GPT分區表
p 顯示當前磁盤的分區表
q 退出gdisk程序,不保存任何修改
r 恢復和轉換選項(僅限專家)
s 排序分區
t 改變分區的類型
v 驗證磁盤分區表
w 將分區表寫入裁判並退出(保存並退出)
x 額外功能(僅限專家)
? 顯示幫助信息

  擴展:Liunx LVM(Linux邏輯卷管理),將多個硬盤(物理盤)和硬盤分區(物理分區)做成一個邏輯卷,並把這個邏輯卷作為一個整體來統一管理,動態對分區進行擴縮空間大小,安全快捷方便管理。

(3).實例

[root@xuexi ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): p  //顯示當前磁盤的分區表
Disk /dev/sdb: 4194304 sectors, 2.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4E50861F-8360-4B97-986E-51F4080BF678
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4194270
Partitions will be aligned on 2048-sector boundaries
Total free space is 2097085 sectors (1024.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2099199   1024.0 MiB  8300  Linux filesystem

Command (? for help): d  //刪除一個分區
Using 1

Command (? for help): n  //新建一個分區
Partition number (1-128, default 1): 
First sector (34-4194270, default = 2048) or {+-}size{KMGTP}:    //開始扇區
Last sector (2048-4194270, default = 4194270) or {+-}size{KMGTP}: +1G  //終止扇區
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):   //分區類型
Changed type of partition to 'Linux filesystem'

Command (? for help): w  //保存並退出

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

Do you want to proceed? (Y/N): y  //確認覆蓋
OK; writing new GUID partition table (GPT) to /dev/sdb.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.  //提示在下次重啟后生效
The operation has completed successfully.

  額,好像並不需要。后面該格式化的格式化(mkfs.xfs,在此之前注意有沒有掛載,掛載的需要卸載再格式化),該掛載的掛載。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM