$ sudo gdisk /dev/sda GPT fdisk (gdisk) version 1.0.5
Problem opening /dev/sda for reading! Error is 13. You must run this program as root or use sudo! vvd@vvd-desktop:~$ sudo gdisk /dev/sda GPT fdisk (gdisk) version 1.0.5
Partition table scan: MBR: protective BSD: not present APM: not present GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? forhelp):
查看当前有哪些磁盘设备可以使用 lsblk 命令
可用命令
进入设备操作状态后可以输入 ? 查询帮助文档
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Command (? for help): ? b back up GPT data to a file c change a partition's name d delete a partition i show detailed information on a partition l list known partition types n add a newpartition o create a new empty GUID partition table (GPT) p print the partition table q quit without saving changes r recovery and transformation options (experts only) s sort partitions t change a partition's type code v verify disk w write table to disk and exit x extra functionality (experts only) ? print this menu
Command (? for help): n Partition number (1-128, default1): First sector (34-11721045134, default = 2048) or {+-}size{KMGTP}: Last sector (2048-11721045134, default = 11721045134) or {+-}size{KMGTP}: +500G Currenttypeis8300 (Linux filesystem) Hex code or GUID (L toshow codes, Enter = 8300): Changed typeofpartitionto'Linux filesystem'
Command (? for help): p Disk /dev/sda: 11721045168 sectors, 5.5 TiB Model: ST6000NM0115-2R7 Sector size (logical/physical): 512/4096 bytes Disk identifier (GUID): DA785A85-79D2-4AD1-911E-F169800B803A Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 11721045134 Partitions will be aligned on2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name 120481048578047500.0 GiB 8300 Linux filesystem 2104857804831457300471000.0 GiB 8300 Linux filesystem 3314573004862914580471.5 TiB 8300 Linux filesystem 46291458048117210451342.5 TiB 8300 Linux filesystem
这里我们生成了4个分区表
删除分区表
删除命令为 d
1 2
Command (? for help): d Partition number (1-4): 4
删除刚刚创建的第四个分区表
再次查看
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Command (? for help): p Disk /dev/sda: 11721045168 sectors, 5.5 TiB Model: ST6000NM0115-2R7 Sector size (logical/physical): 512/4096 bytes Disk identifier (GUID): DA785A85-79D2-4AD1-911E-F169800B803A Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 11721045134 Partitions will be aligned on2048-sector boundaries Total free space is 5429589101 sectors (2.5 TiB)
Number Start (sector) End (sector) Size Code Name 120481048578047500.0 GiB 8300 Linux filesystem 2104857804831457300471000.0 GiB 8300 Linux filesystem 3314573004862914580471.5 TiB 8300 Linux filesystem
可以看到第四个分区确实删除了
修改分区名称
命令为 c
1 2 3
Command (? for help): c Partition number (1-4): 4 Enter name: DATA_I_XL
将四个分区改了名称后
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Command (? for help): p Disk /dev/sda: 11721045168 sectors, 5.5 TiB Model: ST6000NM0115-2R7 Sector size (logical/physical): 512/4096 bytes Disk identifier (GUID): DA785A85-79D2-4AD1-911E-F169800B803A Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 11721045134 Partitions will be aligned on2048-sector boundaries Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name 120481048578047500.0 GiB 8300 DATA_I_S 2104857804831457300471000.0 GiB 8300 DATA_I_M 3314573004862914580471.5 TiB 8300 DATA_I_L 46291458048117210451342.5 TiB 8300 DATA_I_XL
退出编辑状态
命令 q 表示不保存本次修改的分区表,退出编辑状态
命令 w 表示保存本次分区表编辑情况,退出编辑状态
1 2 3 4 5 6 7 8 9
Command (? for help): w
Final checks complete. About towrite GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!
Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully.
此时使用 lsblk 命令查看 /dev/sda
1 2 3 4 5 6 7 8 9
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 5.5T 0 disk ├─sda1 8:1 0 500G 0 part ├─sda2 8:2 0 1000G 0 part ├─sda3 8:3 0 1.5T 0 part └─sda4 8:4 0 2.5T 0 part sdb 8:16 0 5.5T 0 disk