2023年11月25日发(作者:)
Linux主分区_扩展分区_逻辑分区
⽬录:
1、MBR分区介绍
2、创建主分区
3、创建扩展分区
4、创建逻辑分区
1、MBR分区介绍
1.1 分区规定:
每个磁盘设备最多4个主分区,或者3个主分区+1个扩展分区,是因为MBR()的(表)只能存放4个分区 (GPT分区没有这个限制)。
扩展分区只能有⼀个。
逻辑分区可以有多个。
可以从扩展分区中再次划分多个逻辑分区,逻辑分区编号直接从5开始。
1.2 分区作⽤:
主分区:主要是⽤来启动操作系统的,它主要放的是操作系统的启动或引导程序,/boot分区最好放在主分区上;
扩展分区是不能使⽤的,它只是做为逻辑分区的容器存在的,先创建⼀个扩展分区,在扩展分区之上创建逻辑分区;
我们真正存放数据的是主分区和逻辑分区,⼤量数据都放在逻辑分区中。
2、创建主分区
[root@servera ~]# fdisk /dev/vdb
Command (m
for help): n # 创建新分区
Partition type
p primary (004free)
primary, extended,
e extended (container for logical partitions)
Select (default p): p # 创建主分区
Partition number (141): # 回车
-, default
First sector (2048104857592048): # 回车,设置起始扇区
-, default
Last sector, 20481048575910485759409600 # 设置结尾扇区
+sectors or +size{K,M,G,T,P} (-, default ):
Created a new partition 1'Linux'199 MiB.
of type and of size
Command (m for help): n
Partition type
p primary (103free)
primary, extended,
e extended (container for logical partitions)
Select (default p): p # 创建主分区
Partition number (242): # 回车
-, default
First sector (40960110485759411648): # 回车,设置起始扇区
-, default
Last sector, 4116481048575910485759819200 # 设置结尾扇区
+sectors or +size{K,M,G,T,P} (-, default ):
Created a new partition 2'Linux'199 MiB.
of type and of size
Command (m forw # 保存配置
help):
The partition table has been altered.
Calling ioctl() to reread partition table.
-
Syncing disks.
[root@servera l /dev/vdb
~]# fdisk -
Disk 5536870912010485760 sectors
/dev/vdb: GiB, bytes,
Units: sectors of 1512512 bytes
* =
Sector size (logical512512 bytes
/physical): bytes /
I512512 bytes
/O size (minimum/optimal): bytes /
Disklabel type: dos
Disk identifier: 0x03864530
Device Boot Start End Sectors Size Id Type
/dev/vdb1 199M
204840960040755383 Linux
/dev/vdb2 199M
41164881920040755383 Linux
3、创建扩展分区
[root@servera ~]# fdisk /dev/vdb
Command (m
for help): n # 创建新分区
Partition type
p primary (202free)
primary, extended,
e extended (container for logical partitions)
Select (default p): e # 创建扩展分区
Partition number (343): # 选择分区号
,, default
First sector (40960110485759821248): # 起始扇区
-, default
Last sector, 8212481048575910485759): # 结尾扇区
+sectors or +size{K,M,G,T,P} (-, default
Created a new partition 3'Extended'4.6 GiB.
of type and of size
Command (m forw # 保存配置
help):
The partition table has been altered.
Calling ioctl() to reread partition table.
-
Syncing disks.
[root@servera vdb
~]# fdisk -l /dev/
Disk 5536870912010485760 sectors
/dev/vdb: GiB, bytes,
Units: sectors of 1512512 bytes
* =
Sector size (logical512512 bytes
/physical): bytes /
I512512 bytes
/O size (minimum/optimal): bytes /
Disklabel type: dos
Disk identifier: 0x03864530
Device Boot Start End Sectors Size Id Type
/dev/vdb1 199M
204840960040755383 Linux # 主分区
/dev/vdb2 199M
41164881920040755383 Linux # 主分区
/dev/vdb3 .6G Extended # 扩展分区
82124810485759966451245
4、创建逻辑分区
[root@servera ~]# fdisk /dev/
vdb
Command (m for help): n # 创建新分区
All space forin use. # 提⽰所有空间都已经分配给主分区使⽤
primary partitions is
Adding logical partition 5 # 从扩展分区中,⾃动划分逻辑分区
First sector (82329610485759823296): # 起始扇区
-, default
Last sector, 8232961048575910485759): # 结尾扇区
+sectors or +size{K,M,G,T,P} (-, default
Created a new partition 5'Linux'4.6 GiB.
of type and of size
Command (m for help): t # 分区类型
Partition number (1355):
-,, default
Hex code (type L to list all codes): 8e # LVM类型
Changed type of partition 'Linux''Linux LVM'.
to
Command (m forw # 保存配置
help):
The partition table has been altered.
Calling ioctl() to reread partition table.
-
Syncing disks.
[root@servera l /dev/vdb
~]# fdisk -
Disk 5536870912010485760 sectors
/dev/vdb: GiB, bytes,
Units: sectors of 1512512 bytes
* =
Sector size (logical512512 bytes
/physical): bytes /
I512512 bytes
/O size (minimum/optimal): bytes /
Disklabel type: dos
Disk identifier: 0x03864530
Device Boot Start End Sectors Size Id Type
/dev/vdb1 199M
204840960040755383 Linux
/dev/vdb2 199M
41164881920040755383 Linux
/dev/vdb3 .6G
82124810485759966451245 Extended
/dev/vdb5
8232961048575996624644.6G 8e Linux LVM
[root@servera vdb5 # 格式化逻辑分区
~]# /dev/
meta5124301952 blks
-data=/dev/vdb5 isize= agcount=, agsize=
51221
= sectsz= attr=, projid32bit=
= crc= finobt=, sparse=, rmapbt=
1110
= reflink=
1
data 4096120780825
= bsize= blocks=, imaxpct=
= sunit= swidth=
00 blks
naming 2409601
=version bsize= ascii-ci=, ftype=
log 409625602
=internal log bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
51201
realtime 409600
=none extsz= blocks=, rtextents=
[root@servera mount
~]# /dev/vdb5 /var/tmp # 挂载逻辑分区
5、Parted格式化2TB以上的磁盘
通常我们使⽤fdisk⼯具来进⾏磁盘分区,但是fdisk只能格式化⼩于2TB的磁盘。因此⼤于2TB的磁盘分区就需要parted⼯具。
5.1 设置DiskLable Type
# parted /dev/sdb mklabel gpt
5.2 创建分区并格式化
# parted /dev/sdb mkpart primary xfs 0 100%
# /dev/sdb1
5.3 挂载分区
# mount /dev/sdb1 /var/tmp
5.4 删除分区
# parted /dev/sdb rm 1


发布评论