Linux磁盘分区(含fdisk、parted两种方式)

小于2T

添加并识别硬件设备:fdisk -l
创建分区并识别分区:fdisk /dev/sdb

fdisk分区详细操作:
[root@v6px ~]# fdisk /dev/sdb 
新建分区:(n)
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
默认为分区1,回车即可
Partition number (1-4, default 1): 
配置分区起始点,回车即可
First sector (2048-629145599, default 2048): 
配置分区结束点,回车即可(规划为多个分区时候,可以输入+10G,表示为分区1分配10G空间)
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): 
打印分区情况(p)
Command (m for help): p
保存分区配置(w)
Command (m for help): w 

大于等于2T

添加并识别硬件设备:fdisk -l
创建分区并识别分区:parted /dev/sdb
(parted) 输入值详解:
print 打印已有分区情况
mkpart 创建分区
rm 删除分区
quit 退出

命令详解:
-- 新建分区
(parted) mkpart 
Partition type?  primary/extended? primary 
File system type?  [ext2]? xfs          
Start? 1MB
End? 1T                                                     
(parted) print                                               
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1000GB  1000GB  primary

(parted) mkpart
Partition type?  primary/extended? primary 
File system type?  [ext2]? xfs                               
Start? 1T
End? -1
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1000GB  1000GB  primary
 2      1000GB  2174GB  1174GB  primary

-- 删除分区
(parted) rm                                                 Partition number? 2                                         (parted) print                                               Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1000GB  1000GB  primary

-- 修改分区格式
(parted) mklabel gpt  
(parted) print 
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start  End  Size  Type  File system  Flags

(parted) mklabel gpt                                         Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                 (parted) print                                               Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
Number  Start  End  Size  File system  Name  Flags

-- 修改分区大小
(parted) resizepart

-- 打印分区情况
(parted) print                                               Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 2174GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1000GB  1000GB  primary
 

常见问题:
(parted) print
Error: /dev/sdb: unrecognised disk label
解决方法:
(parted) mklabel gpt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值