This commands will be used when working with LVM
- pvs:
pvs shows information about the physical devices
$ pvs
PV VG Fmt Attr PSize PFree
/dev/sda datavg lvm2 a-- <1.82t <1.14t
- vgs:
vgs shows inforamtion about the volume group built ontop of the physical volume(s)
$ vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 2 0 wz--n- <1.82t <1.14t
- lvs:
lvs shows the actual volumes which are usable and can be mounted
$ lvs
LV VG Attr LSize Pool
datalv datavg -wi-ao---- 500.00g
vmslv datavg -wi-ao---- 200.00g
- pvcreate:
pvcreate is used to add new disks to the LVM manager.
$ pvcreate /dev/sdb
- vgcreate:
Create a new Volume Group ontop of an Physical Volume Group
$ vgcreate testvg /dev/sdb
- lvcreate:
Create an logical volume on an Volume Group.
Size can be set with -L or -l.
-L is used for fixed sizes like -L1G or -L50G or -L1T
-l sets size in % of free space of the VG ex.: -l50%VG or -l100%FREE
This will create a volume with 100 % free space used
lvcreate -n testlv -l100%FREE testvg
This will create a volume with 1G Size
lvcreate -n testlv -L1G testvg
- pvremove:
will remove the physical disk from the LVM configuration
This will not delete the Physical disk. has to be done seperatly
pvremove /dev/sdb
- vgremove:
removes a vg
can be forced with -f option
vgremove testvg
- lvremove:
remove an LV. has to be unmounted to work and no more open files are allowed
can be forced with -f (will not work if still open files)
lvremove /dev/mapper/testvg-testlv
- pvdisplay:
shows more detailed information of the pv
show for all pv (only have one in my setup)
$ pvdisplay
--- Physical volume ---
PV Name /dev/sda
VG Name datavg
PV Size <1.82 TiB / not usable <1.09 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476932
Free PE 297732
Allocated PE 179200
PV UUID dnQPBJ-DSfP-9Z5q-jIsc-UcUo-8exV-d2hA0h
show for specific pv
$ pvdisplay /dev/sda
--- Physical volume ---
PV Name /dev/sda
VG Name datavg
PV Size <1.82 TiB / not usable <1.09 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 476932
Free PE 297732
Allocated PE 179200
PV UUID dnQPBJ-DSfP-9Z5q-jIsc-UcUo-8exV-d2hA0h
- vgdisplay:
Shows detailed information for the Volume Group
show for al vg (only have one in my setup)
$ vgdisplay datavg
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <1.82 TiB
PE Size 4.00 MiB
Total PE 476932
Alloc PE / Size 179200 / 700.00 GiB
Free PE / Size 297732 / <1.14 TiB
VG UUID Pc8kpf-EU3e-0NBc-x8bv-3Ngt-nz21-gX2veC
Show for specific one
$ vgdisplay datavg
--- Volume group ---
VG Name datavg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <1.82 TiB
PE Size 4.00 MiB
Total PE 476932
Alloc PE / Size 179200 / 700.00 GiB
Free PE / Size 297732 / <1.14 TiB
VG UUID Pc8kpf-EU3e-0NBc-x8bv-3Ngt-nz21-gX2veC
- lvdisplay:
Display detailed information about the logical volumes
show all logical volumes
$ lvdisplay
--- Logical volume ---
LV Path /dev/datavg/testlv
LV Name testlv
VG Name datavg
LV UUID 9a1oSw-7Xn1-tBJ7-HigR-4MfQ-oZVg-hYGp3e
LV Write Access read/write
LV Creation host, time manj, 2022-03-17 17:03:30 +0100
LV Status available
# open 1
LV Size 500.00 GiB
Current LE 128000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/datavg/test1lv
LV Name test1lv
VG Name datavg
LV UUID nKzhcg-Osom-H89M-2PMp-d767-Bmvr-w6ZQXx
LV Write Access read/write
LV Creation host, time manj, 2022-03-17 18:12:03 +0100
LV Status available
# open 1
LV Size 200.00 GiB
Current LE 51200
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
show specific logical volume
$ lvdisplay /dev/mapper/datavg-testlv --- Logical volume ---
LV Path /dev/datavg/testlv
LV Name testlv
VG Name datavg
LV UUID 9a1oSw-7Xn1-tBJ7-HigR-4MfQ-oZVg-hYGp3e
LV Write Access read/write
LV Creation host, time manj, 2022-03-17 17:03:30 +0100
LV Status available
# open 1
LV Size 500.00 GiB
Current LE 128000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0