gdisk分区命令

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

gdisk分区命令
GPT fdisk(由gdisk、cgdisk、sgdisk和fixparts程序组成)是⼀组⽤于Linux、FreeBSD、Mac OS X和Windows的⽂本模式分区⼯具。

gdisk、cgdisk和sgdisk程序在全局惟⼀标识符(GUID)分区表(GPT)磁盘上⼯作,⽽不是在旧的(也是最常见的)主引导记录(MBR)分区表上⼯作。

fixparts程序修复MBR 磁盘的某些类型的损坏,并允许将分区类型从主分区更改为逻辑分区,反之亦然。

这个命令⽤来对GPT分区进⾏操作,请不要在MBR分区上操作,先通过parted /dev/sdb print 命令查看分区表的类型(/dev/sdb换成要操作的磁盘)。

如果相了解更多内容可以查看这个⽹站:
现在⼤部分发⾏版都默认⾃带了gdisk,如果没有⾃带⾃⾏安装,CentOS7-1810、Debian9.5搜索软件gdisk安装,openSUSE15搜索gptfdisk 安装⼀、gdisk参数使⽤⽅法:
# gdisk 设备名
使⽤这个命令前应该先⽤lsblk命令查看系统上可⽤的磁盘,因为这个命令不能查看系统上可⽤的磁盘有那些。

-----------------------------------------------
root@debian:~# gdisk /dev/sdc #对/dev/sdc进⾏分区
GPT fdisk (gdisk) version 1.0.1 #GPT fdisk版本
Partition table scan: #分区表扫描:
MBR: not present #MBR:不存在
BSD: not present #BSD:不存在
APM: not present #APM:不存在
GPT: not present #GPT:不存在
Creating new GPT entries. #创建新的GPT条⽬
Command (? for help): ? #输⼊?号查看可⽤的指令
b back up GPT data to a file #将GPT数据备份到⽂件中
c change a partition's name #更改分区的名称
d delet
e a partition #删除分区
i show detailed information on a partition #将显⽰分区的详细信息
l list known partition types #列出已知的分区类型
n add a new partition #添加⼀个新的分区
o create a new empty GUID partition table (GPT) #创建⼀个新的空GUID分区表(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):
⼆、gdisk交互模式磁盘分区
1、新建分区
root@debian:~# gdisk /dev/sdc #对磁盘/dev/sdc进⾏分区
GPT fdisk (gdisk) version 1.0.1 #GPT fdisk版本
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries. #⾃动创建GPT分区表
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:~#。

相关文档
最新文档