[root@localhost ~]# lvcreate [选项] [-n 逻辑卷名] 卷组名
选项:
[root@localhost ~]# lvcreate -L 1.5G -n lamplv scvg
Logical volume "lamplv" created
#在scvg卷组中建立一个1.5GB大小的lamplv逻辑卷
[root@localhost ~]# mkfs -t ext4 /dev/scvg/lamplv
#格式化
[root@localhost ~]# mkdir /disklvm
[root@localhost ~]# mount /dev/scvg/lamplv /disklvm/
#建立挂载点,并挂载
[root@localhost ~]# mount
…省略部分输出…
/dev/mapper/scvg-lamplv on /disklvm type ext4(rw)
#已经挂载了
[root@localhost ~]# lvscan
ACTIVE '/dev/scvg/lamplv' [1.50 GiB] inherit
#能够看到激活的逻辑卷,大小是1.5GB
[root@localhost ~]# lvdisplay
---Logical volume---
LV Path /dev/scvg/lamplv
逻辑卷的设备文件名
LV Name lamplv
#逻辑卷名
VG Name scvg
#所属的卷组名
LV UUID 2kyKmn-Nupd-CldB-8ngY-NsI3-b8hV-QeUuna
LV Write Access read/write
LV Creation host, time localhost, 2013-04-18 03:36:39 +0800
LV Status available
# open 1
LV Size 1.50 GiB
#逻辑卷大小
Current LE 192
Segments 2
Allocation inherit
Read ahead sectors auto
-currently set to 256
Block device 253:0
[root@localhost ~]# lvresize [选项] 逻辑卷的设备文件名
选项:
[root@localhost ~]# cd /disklvm/
[root@localhost disklvm]# touch testf
[root@localhost disklvm]# mkdir testd
[root@localhost disklvm]# ls
lost+found testd testf
[root@localhost disklvm]# lvresize -L 2.5G /dev/scvg/lamplv
Extending logical volume lamplv to 2.50 GiB Logical volume lamplv successfully resized
#增加lamplv逻辑卷的大小到2. 5GB,当然命令也可以这样写
[roots localhost disklvm] # lvresize -L +1G /dev/scvg/lamplv
[root@localhost disklvm]# lvdisplay
---Logical volume ---
LV Path /dev/scvg/lamplv
LV Name lamplv
VG Name scvg
LV UUID 2kyKmn-Nupd-CldB-8ngY-Ns13-b8hV-QeUuna
LV Write Access read/write
LV Creation host, time localhost, 2013-04-18 03:36:39 +0800 LV Status available
# open 1
LV Size 2.50 GiB
#大小改变了
Current LE 320
Segments 3
Allocation inherit
Read ahead sectors auto
-currently set to 256
Block device 253:0
[root@localhost disklvm]# df -h /disklvm/
文件系统 容量 已用 可用 已用% %挂载点
/dev/mapper/scvg-lamplv 1.5G 35M 1.4G 3%/ disklvm
[root@localhost ~]# resize2fs [选项] [设备文件名] [调整的大小]
选项:
[root@localhost ~]# resize2fs /dev/scvg/lamplv
resize2fs 1.41.12(17-May-2010)
Filesystem at /dev/scvg/lamplv is mounted on/ disklvm; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of/dev/scvg/lamplv to 655360 (4k) blocks.
The filesystem on /dev/scvg/lamplv is now 655360 blocks long.
#已经调整了分区大小
[root@localhost ~]# df -h /disklvm/
文件系统 容量 已用 可用 已用% %挂载点
/dev/mapper/scvg-lamplv 2.5G 35M 2.4G 2% /disklvm
#分区大小已经是2.5GB 了
[root@localhost ~]# ls /disklvm/
lost+found testd testf
#而且数据并没有丟失
[root@localhost ~]#lvremove 逻辑卷的设备文件名
我们删除 lamplv 逻辑卷,记得在删除时要先卸载。 命令如下:
[root@localhost ~]# umount /dev/scvg/lamplv
[root@localhost ~]# Ivremove /dev/scvg/lamplv
Do you really want to remove active logical volume lamplv? [y/n]: n
#如果这里选择y,就会执行删除操作,逻辑卷内的所有数据都会被清空
Logical volume lamplv not removed
本文链接:http://task.lmcjl.com/news/11807.html