从/dev/sdc和/dev/sdd磁盘中各取出10G组成卷组(VG),然后从此VG中取出15G组成逻辑卷(LV)。创建逻辑卷的过程为创建PV—创建VG—创建LV—挂载。删除为卸载—删lv—删VG—删PV。
对两个磁盘进行分区。t命令更改分区类型为8e。用l可以查看系统分区类型的ID。保存退出后更新分区表。
[root@localhostaudisp]# fdisk /dev/sdc
[root@localhostaudisp]# fdisk /dev/sdd
Command(m for help): n
Commandaction
e extended
p primary partition (1-4)
p
Partitionnumber (1-4): 1
Firstcylinder (1-2610, default 1):
Usingdefault value 1
Lastcylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +10G
Command(m for help): p
Disk /dev/sdc:21.4 GB, 21474836480 bytes
255heads, 63 sectors/track, 2610 cylinders
Units =cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 1217 9775521 83 Linux
Command(m for help): t
Selectedpartition 1
Hex code(type L to list codes): 8e
Changedsystem type of partition 1 to 8e (Linux LVM)
Command(m for help): w
[root@localhostaudisp]# partprobe
创建PV
[root@localhostaudisp]# pvcreate /dev/sdc1
Writing physical volume data todisk “/dev/sdc1”
Physical volume “/dev/sdc1″successfully created
[root@localhostaudisp]# pvcreate /dev/sdd1
Writing physical volume data to disk “/dev/sdd1”
Physical volume “/dev/sdd1″successfully created
创建VG。创建VG过程过程中可以指定PE的大小,选项为-s。
[root@localhostaudisp]# vgcreate vg-data /dev/sdc1 /dev/sdd1
Volume group “vg-data” successfullycreated
创建LV。创建LV也可以根据PE的个数来选择容量,选项为-l。
[root@localhostaudisp]# lvcreate -L 15G -n lv-data /dev/vg-data
Logical volume “lv-data” created
查看LV。
[root@localhostaudisp]# lvdisplay
— Logical volume —
LV Name /dev/vg-data/lv-data
VG Name vg-data
LV UUID rSCcPQ-3b29-TiQC-14cG-PA3o-8xac-Dg3Rvf
LV Write Access read/write
LV Status available
# open 0
LVSize 15.00 GB
Current LE 3840
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
对逻辑卷进行格式化之后挂载到/home目录下。df –h查看磁盘的信息。
[root@localhostaudisp]# mkfs.ext3 /dev/vg-data/lv-data
[root@localhostaudisp]# mount /dev/vg-data/lv-data /home/
[root@localhostaudisp]# df -h
文件系统容量已用可用已用% 挂载点
/dev/sda3 95G 2.5G 88G 3% /
/dev/sda2 95G 582M 90G 1% /data
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 500M 0 500M 0% /dev/shm
/dev/sdb1 20G 173M 19G 1% /mytest/abc
/dev/mapper/vg–data-lv–data
15G 166M 14G 2% /home
逻辑卷的优点是能够在线进行扩展且不影响用户的使用。
若VG空间不够先对VG进行扩展
[root@localhostaudisp]# vgextend vg-data /dev/sda6
No physical volume label read from /dev/sda6
Writing physical volume data to disk”/dev/sda6″
Physical volume “/dev/sda6″successfully created
Volume group “vg-data” successfullyextended
根据需要对LV进行扩展
[root@localhostaudisp]# lvextend -L +50G /dev/vg-data/lv-data
Extending logical volume lv-data to 65.00 GB
Logical volume lv-data successfully resized
对LV进行文件系统更新
[root@localhostaudisp]# resize2fs /dev/vg-data/lv-data
[root@localhostaudisp]# df -h
文件系统容量已用可用已用% 挂载点
/dev/sda3 95G 2.5G 88G 3% /
/dev/sda2 95G 582M 90G 1% /data
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 500M 0 500M 0% /dev/shm
/dev/sdb1 20G 173M 19G 1% /mytest/abc
/dev/mapper/vg–data-lv–data
64G 177M 61G 1% /home
相关阅读:
mysqldump和LVM逻辑卷快照 http://www.linuxidc.com/Linux/2013-09/90382.htm
LVM的综合性介绍及实现 http://www.linuxidc.com/Linux/2013-03/81482.htm
更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10