LVM简介:
Lofical Volume Manger 逻辑卷管理。
LVM将一个或者多个硬盘分区在逻辑集上集合,相当于一个大硬盘来使用,当硬盘的空间不够使用的时候,可以继续将其它的硬盘的分区加入其中,这样可以实现磁盘空间的动态管理,具有很高的灵活性。
创建和管理LVM
步骤:
1、创建分区 fdisk
2、创建逻辑卷 pv
3、将物理卷转化为卷组 vg
4、将卷组生成新的逻辑卷 lv
5、格式化 mkfs
6、挂载 mount
1、创建分区:
使用分区工具(如fdisk等),创建LVM分区,与其它分区创建类型相同,区别仅仅是LVM的分区类型为8e
[root@localhost ~]# fdisk /dev/sda
先创建一个扩展分区:(没有扩展分区无法创建逻辑分区)
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): e
Partition number (3,4, default 3):
First sector (52447232-125829119, default 52447232):
Using default value 52447232
Last sector, +sectors or +size{K,M,G} (52447232-125829119, default 125829119): +10G
Partition 3 of type Extended and of size 10 GiB is set
创建了两个逻辑分区:
Command (m for help): n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (52449280-73418751, default 52449280):
Using default value 52449280
Last sector, +sectors or +size{K,M,G} (52449280-73418751, default 73418751): +2G
Partition 5 of type Linux and of size 2 GiB is set
Command (m for help): n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (56645632-73418751, default 56645632):
Using default value 56645632
Last sector, +sectors or +size{K,M,G} (56645632-73418751, default 73418751): +2G
Partition 6 of type Linux and of size 2 GiB is set
Command (m for help): p
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x0001e85f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 52447231 25174016 8e Linux LVM
/dev/sda3 52447232 73418751 10485760 5 Extended
/dev/sda5 52449280 56643583 2097152 83 Linux
/dev/sda6 56645632 60839935 2097152 83 Linux
更改分区类型: 8e为Linux LVM
Command (m for help): t
Partition number (1-3,5,6, default 6):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to &#