查看当前LV及PV信息:
[root@rusky ~]# hostnamectl Static hostname: localhost.localdomain Transient hostname: rusky.com Icon name: computer-vm Chassis: vm Machine ID: 9c10c7a9e32e40acb19659a30f73603b Boot ID: d20cdc4bccf04de3bc2639830b61a8e6 Virtualization: kvm Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server Kernel: Linux 3.10.0-327.el7.x86_64 Architecture: x86-64 ------------------------------------------------------------------------------------------------ [root@rusky ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 7.51g 40.00m /dev/sdb yum_repo_vg lvm2 a-- 15.00g 15.00g --有一个15G大小的PV,VG名字为yum_repo_vg [root@rusky ~]# lvs --有两个默认的LV:root、swap LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 6.67g swap rhel -wi-ao---- 820.00m
1. 在名为yum_repo_vg的卷组上创建一个大小为5GB的逻辑卷
[root@rusky ~]# lvcreate -L 5G yum_repo_vg Logical volume "lvol0" created. [root@rusky ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 6.67g swap rhel -wi-ao---- 820.00m lvol0 yum_repo_vg -wi-a----- 5.00g
虽然没有用-n指定逻辑卷的名字,但是lvcreate命令会自动命名逻辑卷lvo10.
2. 在名为yum_repo_vg的卷组上创建一个大小为2GB的逻辑卷yum_repo_lvm
[root@rusky ~]# lvcreate -L 2G -n yum_repo_lvm yum_repo_vg Logical volume "yum_repo_lvm" created. [root@rusky ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 6.67g swap rhel -wi-ao---- 820.00m lvol0 yum_repo_vg -wi-a----- 5.00g yum_repo_lvm yum_repo_vg -wi-a----- 2.00g
使用-n指定逻辑卷的名字
3. 在名为yum_repo_vg的卷组上创建一个逻辑卷yum_repo_lvm2,大小为50%的VG
[root@rusky ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 7.51g 40.00m /dev/sdb yum_repo_vg lvm2 a-- 15.00g 8.00g [root@rusky ~]# lvcreate -l 50%VG -n yum_repo_lvm2 yum_repo_vg Logical volume "yum_repo_lvm2" created. [root@rusky ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 6.67g swap rhel -wi-ao---- 820.00m lvol0 yum_repo_vg -wi-a----- 5.00g yum_repo_lvm yum_repo_vg -wi-a----- 2.00g yum_repo_lvm2 yum_repo_vg -wi-a----- 7.50g ---使用的是50%VG.PSize
注意:-l 50%VG是使用PSize的50%,而不是PFree的50%,如果是使用%80VG=12G,大于PFree8G,则报错
4. 在名为yum_repo_vg的卷组上创建一个逻辑卷yum_repo_lvm3,使用全部可用VG空间
[root@rusky ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 7.51g 40.00m /dev/sdb yum_repo_vg lvm2 a-- 15.00g 512.00m [root@rusky ~]# lvcreate -l 100%FREE -n yum_repo_lvm3 yum_repo_vg Logical volume "yum_repo_lvm3" created. [root@rusky ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 6.67g swap rhel -wi-ao---- 820.00m lvol0 yum_repo_vg -wi-a----- 5.00g yum_repo_lvm yum_repo_vg -wi-a----- 2.00g yum_repo_lvm2 yum_repo_vg -wi-a----- 7.50g yum_repo_lvm3 yum_repo_vg -wi-a----- 512.00m --使用全部的PFee [root@rusky ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 7.51g 40.00m /dev/sdb yum_repo_vg lvm2 a-- 15.00g 0 --PFree为0
原文参考:http://www.ehowstuff.com/4-lvcreate-command-examples-on-linux/