linux删除gpt分区工具,Linux分区工具——fdisk parted
分区模式:
①MBR(msdos)主引导记录分区方案
· 分区类型:主分区、逻辑分区、扩展分区
· 最多只能有4个主分区:
- (理论)1~4个主分区,或(实际)3个主分区+1个扩展分区(n个逻辑分区)
- 每个分区最大支持容量为2.2TB的磁盘
- 扩展分区不能格式化
②gpt分区模式
· gpt模式可以分128个主分区,每个分区大小可以超过2T。
· 便于非交互式使用
分区工具:
①fdisk
· format disk,格式化磁盘
· 用途:交互式,MBR模式专用分区表操作工具软件
· 格式:
[root@shell1 ~]# lsblk #列出块设备
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
vdb 252:16 0 20G 0 disk #新磁盘,准备分区使用
]# fdisk /dev/vdb #要分区的磁盘
Command (m for help):m #按m进入帮助
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition #删除一个分区
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition #添加一个新分区
o create a new empty DOS partition table
p print the partition table #查看当前的分区表
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit #保存并退出
x extra functionality (experts only)
Command (m for help): n #新建分区
Partition type:
p primary (0 primary, 0 extended, 4 free) #分区类型,p,主分区
e extended #分区类型,e,扩展分区
Select (default p): #选择分区类型
Using default response p
Partition number (1-4, default 1): #选择分区值
First sector (2048-41943039, default 2048): #设置分区的开始位置
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): #设置分区的结束位置
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set
Command (m for help): p #查看分区表
Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xa227ad92
Device Boot Start End Blocks Id System
/dev/vdb1 2048 41943039 20970496 83 Linux
Command (m for help): w #保存分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
②parted
· 分区模式:gpt、msdos
· parted可以分128个主分区,每个分区大小可以超过2T
· 便于非交互式操作
· 用途:一个分区处理程序
· 格式:
交互式:
[root@shell1 ~]# parted /dev/vdb #分区磁盘
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) m #查看帮助
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
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 #创建分区模式
(parted) mkpart primary 1M 10% #创建主分区 从1M开始 10%结束,留1M给系统使用,避免出问题
(parted) print #输出分区信息
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 2147MB 2146MB primary
(parted) quit #退出
[root@shell1 ~]# partprobe /dev/vdb #刷新分区
非交互式:
[root@test ~]# parted /dev/vdb mklabel gpt #选择分区模式
[root@test ~]# parted /dev/vdb mkpart primary 1 2G #创建分区 主分区 1M开始 2G结束
[root@test ~]# parted /dev/vdb print #输出分区信息
[root@test ~]# partprobe /dev/vdb #刷新分区
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!