openEuler 22.03 GPT分区表模式下磁盘分区管理

GPT分区表模式下磁盘分区管理

parted交互式创建分区

步骤 1 执行如下步骤对/dev/sdc磁盘分区

[root@localhost ~]# parted /dev/sdc		#使用parted分区命令
GNU Parted 3.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)  help		#若不清楚如何操作,可以输入help查看帮助信息
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found  partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) mklabel gpt		#设置磁盘分区表格式为GPT
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want
to continue?
Yes/No? yes			#确认
(parted) mkpart		#创建新分区
Partition name?  []? gpt1		#设置分区名称
File system type?  [ext2]? xfs	#设置分区格式化时采用的文件系统类型
Start? 0KB		#设置分区起始位置
End? 2GB		#设置分区结束位置
Warning: You requested a partition from 0.00B to 2000MB (sectors 0..3906250).
The closest location we can manage is 17.4kB to 2000MB (sectors 34..3906250).
Is this still acceptable to you?
Yes/No? yes		#确认
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
Ignore/Cancel? Ignore		#忽略告警
(parted) print		#输出分区信息
Model: Virtio Block Device (virtblk)
Disk /dev/sdc: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  2000MB  2000MB  xfs          gpt1			#这个就是上面步骤创建的分区
(parted) quit
Information: You may need to update /etc/fstab.

非交互式创建分区

步骤 1 输入如下命令直接创建分区。

[root@localhost ~]# parted /dev/sdc mkpart gpt2 2001M 4G		#创建分区,设置起始和结束位置
Information: You may need to update /etc/fstab.

[root@localhost ~]# parted /dev/sdc p 		#输出分区信息
Model: Virtio Block Device (virtblk)
Disk /dev/sdc: 5369MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End      Size     File system    Name  	Flags
 1      17.4kB   2000MB  2000MB               gpt1
 2      2001MB  4000MB  2000MB               gpt2				#这个就是前述步骤创建的分区

#因为/dev/sdc磁盘已经设置了分区表格式是GPT,所以这里没有重复设置。若是一块新的磁盘需要输入如下命令:
[root@localhost ~]# parted /dev/sdc mklabel gpt

删除分区

步骤 1 执行如下命令删除/dev/sdc1分区。

[root@localhost ~]# parted /dev/sdc rm 1
Information: You may need to update /etc/fstab.

[root@localhost ~]# parted /dev/sdc p
Model: Virtio Block Device (virtblk)
Disk /dev/sdc: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End      Size       File system  Name  Flags
 2      2001MB  4000MB  2000MB               gpt2

在这里插入图片描述

  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值