LVM 是逻辑盘卷管理(Logical Volume Manager)的简称,它是 Linux 环境下对磁盘分区进行管理的一种机制,LVM 是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分 LVM 区管理的灵活性, 使得用户在无需停机的情况下方便地调整各个分区大小。现在我们实际来弄一下。
(1)、 创建磁盘分区,转换文件系统类型为 LVM(8e)
fdisk /dev/sdb (对sdb 磁盘进行分区)
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
- software that runs at boot time (e.g., old versions of LILO)
- booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n (创建一个分区)
Command action
e extended
pprimary partition (1-4)
p (即选择主分区)
Partition number (1-4): 1(主分区 序列号)
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): 100
Command (m for help): n
Command action
e extended
pprimary partition (1-4)
p
Partition number (1-4): 2
First cylinder (101-2610, default 101):
Using default value 101
Last cylinder or +size or +sizeM or +sizeK (101-2610, default 2610): 200
Command (m for help): n
Command action
e extended
pprimary partition (1-4)
p
Partition number (1-4): 3
First cylinder (201-2610, default 201):
Using default value 201
Last cylinder or +size or +sizeM or +sizeK (201-2610, default 2610): 500
Command (m for help): n
Command action
e extended
pprimary partition (1-4)
p
Selected partition 4(最多有4个主分区哦)
First cylinder (501-2610, default 501):
Using default value 501
Last cylinder or +size or +sizeM or +sizeK (501-2610, default 2610): 1200
Command (m for help): p(查看刚才建立的分区)
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Command (m for help): t//转换分区类型为 L
Partition number (1-4): 1
Hex code (type L to list codes): 8e //L 对应的 ID 为 8e,此处可以输入 L 查看。
Changed system type of partition 1 to 8e (Linux L)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux L)
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux L)
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux L)
Command (m for help): p
Command (m for help): w (保存所创建的分区)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
partprobe /dev/sdb (使所创建的分区生效)
(2)、创建物理卷 PV
pvdisplay (查看所创建的物理卷)
"/dev/sdb1" is a new physical volume of "784.39 MB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size784.39 MB
AllocatableNO
PE Size (KByte)0
Total PE0
Free PE 0
Allocated PE 0
PV UUID dGLeKz-GIsP-3oT9-jbn9-fSRI-RSQAvSs1vA
"/dev/sdb2" is a new physical volume of "784.42 MB"
--- NEW Physical volume ---
PV Name /dev/sdb2
VG Name
PV Size784.42 MB
AllocatableNO
PE Size (KByte)0
Total PE0
Free PE0
Allocated PE0
PV UUIDNn5qwE-qrAY-CpzQ-HgMC-zY1o-vHeb-3wuABX
"/dev/sdb3" is a new physical volume of "2.30 GB"
--- NEW Physical volume ---
PV Name /dev/sdb3
VG Name
PV Size2.30 GB
AllocatableNO
PE Size (KByte)0
Total PE0
Free PE0
Allocated PE0
PV UUIDcmLeoO-lGFK-JWtH-Y0rD-l9Mz-JvpX-eUdemo
"/dev/sdb4" is a new physical volume of "5.36 GB"
--- NEW Physical volume ---
PV Name /dev/sdb4
VG Name
PV Size5.36 GB
AllocatableNO
PE Size (KByte)0
Total PE0
Free PE0
Allocated PE0
PV UUIDnsj9Ok-E8FL-je15-Td4H-fpMZ-mqk4-JJ9DPg
(3)、创建卷组 VG
(4)、创建逻辑卷 LV
(5)、格式化
(6)、挂载