gdisk partition command

GPT fdisk (by the gdisk, cgdisk, sgdisk and fixparts program composed) is a set of text mode partitioning tool for Linux, FreeBSD, Mac OS X and Windows. gdisk, cgdisk and sgdisk programs globally unique identifier (GUID) partition table (GPT) disk to work on, rather than in the old (and most common) Master Boot Record (MBR) partition table to work on. fixparts fixes the disk's MBR certain types of damage, and allow the partition type from the primary partition to a logical partition, and vice versa. This command is used to GPT partition operation, do not operate on MBR partition, first by type (/ dev / sdb replaced disk to operate) parted / dev / sdb print command to view the partition table.

If the phase learn more you can view the Web site: http://www.rodsbooks.com/gdisk/

Now most distributions by default comes with gdisk, if not own their own installation, CentOS7-1810, Debian9.5 gdisk search software is installed, openSUSE15 search gptfdisk installation

A, gdisk method parameters:

# Gdisk device name

Before using this command you should first use lsblk command to view disk available on the system, because this command is not available on the system disk to see those.
-----------------------------------------------
root @ Debian : ~ # gdisk / dev / sdc # on / dev / sdc partition
GPT fdisk (gdisk) version 1.0.1 #GPT fdisk version

Partition table scan: # partition table scans:
the MBR: Present #MBR not: there is no
BSD: not present #BSD: there is no
APM: not present #APM: does not exist
not present #GPT:: GPT does not exist

Creating new GPT entries. # Create a new GPT entry

Command (for help?):? # Input? No. Check command available
b back up GPT data to a file # backup GPT data to a file
c change a partition's name to change the partition name #
d the Delete A Partition # delete the partition
i show detailed information on a partition # displays the partition Details
l list known partition types # list known partition type
n add a new partition # add a new partition
o create a new empty GUID partition table (GPT) # Create a new empty GUID partition table (the GPT)
P print the partition table # print the partition table
q quit without saving changes # to exit without saving changes
r recovery and transformation options (experts only ) # restoration and conversion options (expert use only)
s sort partitions # Classification partition
t change a partition's type code # to change the partition type
v verify disk # Verify Disk
w write table to disk and exit # table is written to disk and exit
x extra functionality (experts only) # additional functionality (only limit the use of experts)
? # Print the this the MENU command to view the available

Command (? for help):

Two, gdisk interactive mode disk partition

1, the new zoning

root @ debian: ~ # gdisk / dev / sdc # disk / dev / sdc partition
GPT fdisk (gdisk) version 1.0.1 #GPT fdisk version

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

Creating new GPT entries. # Automatically create a GPT partition table

Command (? for help): n              #输入n新建分区,默认已经创建了分区表
Partition number (1-128, default 1):     #输入分区号,直接回车就行,默认为1
First sector (34-10485726, default = 2048) or {+-}size{KMGTP}:       #输入起始扇区,直接回车就行,默认2048最前面开始
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}: +1G          #这里输入新增分区的大小可以通过扇区数来增加,也可以通过+size{KMGTP}方式来增加,这里要增加1G的容量就表示为+1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):               #这里要求输入分区的类型,直接回车就行,也可以输入l回车查看所有分区的类型
Changed type of partition to 'Linux filesystem'

2、查看剩余可用的空间等信息

Command (? for help): p                     #输入p查看创建的分区
Disk /dev/sdc: 10485760 sectors, 5.0 GiB         #磁盘总容量
Logical sector size: 512 bytes
Disk identifier (GUID): AC08E842-007B-4604-9545-B0BFF427F928 #分区类型为GPT
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 8388541 sectors (4.0 GiB)          #磁盘可用剩余空间

Number    Start (sector)   End (sector)    Size      Code    Name
1        2048       2099199    1024.0 MiB   8300    Linux filesystem        #已经创建的分区


3、删除分区

Command (? for help): d        #输入d删除分区
Partition number (1-2): 2       #删除分区2

4、修改分区类型

Command (? for help):  l

#回车可以查看更多的信息,其中8200为Linux swap分区、8300为Linux分区、8e00为LinuxLVM分区

Command (? for help): t        #输入t更改分区类型,这里输入l也可以查看分区的类型
Partition number (1-2): 2      #输入要更改的分区
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00     #输入分区类型的编号
Changed type of partition to 'Linux LVM'               #更改成功

Command (? for help): p
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 170FC283-67F2-4188-A687-6882B68F3C3C
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 8388540 sectors (4.0 GiB)

Number    Start (sector)    End (sector)    Size        Code    Name
1        2048       2099199     1024.0 MiB    8300    Linux filesystem
2        2099200      2099200      512 bytes       8E00    Linux LVM       #更改成功

Command (? for help):

5、更改分区名称

 

Command (? for help): c                             #输入c更改分区名称
Partition number (1-2): 2                            #输入要更改的分区
Enter name: pv1 LVM                                    #输入更改后的名称

 

Command (? for help): p
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 170FC283-67F2-4188-A687-6882B68F3C3C
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 8388540 sectors (4.0 GiB)

 

Number    Start (sector)   End (sector)    Size      Code    Name
1       2048        2099199     1024.0 MiB   8300    Linux filesystem
2       2099200       2099200      512 bytes     8E00    pv1 LVM                       #分区名称已经更改

 

Command (? for help):

 


6、保存修改的结果

Command (? for help): w          #输入w保存配置,如果不想保存可以输入q退出

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

Do you want to proceed? (Y/N): y              #问你是否相想继续,输入y继续
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.         #写入成功
root@debian:~#

  

Guess you like

Origin www.cnblogs.com/pipci/p/11369671.html