Difference between revisions of "LVM"

From Alessandro's Wiki
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:




= from command line =
= Info =


  pvdisplay
*; Phisical Volumes
  pvs


  lvremove
*; Volume Groups
  vgs
*; Logical Volumes
lvs


lvdisplay


 
= Phisical Volumes (PV) =
== see the PV's ==


  pvs
  pvs
Line 34: Line 36:
  Volume group "vg_1" successfully removed
  Volume group "vg_1" successfully removed


== create a mirror ==
= Resizing out from Disk->PV->LV->Partition =
 
* After resizing a physical drive this commands will claim the space gained to the file system.
*resizing LVM linux partition to the new disk boundaries
pvresize /dev/md1
* adding 100G
lvextend -L+100G /dev/mapper/vg0-var
* ext4 resizing command
resize2fs /dev/mapper/vg0-var
 
df -hT
 
= Logical Volumes =
== create a mirror volume ==
 
  lvcreate -L 931g vg_1 -m 1 vg_1
  lvcreate -L 931g vg_1 -m 1 vg_1
== create a mirror from existing and mounted volume ==
lvconvert -m1 vg_1/lv_home
* then we check the result:
# pvs;echo;vgs;echo;lvs
  PV        VG        Fmt  Attr PSize  PFree
  /dev/sda2  vg_1 lvm2 a--  930.82g    0
  /dev/sdb  vg_1 lvm2 a--  931.31g 56.33g
  VG        #PV #LV #SN Attr  VSize VFree
  vg_1  2  3  0 wz--n- 1.82t 56.33g
  LV      VG        Attr    LSize  Pool Origin Data%  Move Log          Copy%  Convert
  lv_home vg_1 mwi-aom- 874.98g                        lv_home_mlog 100.00       
  lv_root vg_1 -wi-ao--  50.00g                                                   
  lv_swap vg_1 -wi-ao--  5.84g

Revision as of 20:18, 6 April 2017



Info

  • Phisical Volumes
pvs
  • Volume Groups
vgs
  • Logical Volumes
lvs


Phisical Volumes (PV)

pvs
 PV         VG         Fmt  Attr PSize   PFree  
 /dev/sda  vg_1 lvm2 a--  930.82g      0 
 /dev/sdb  vg_1 lvm2 a--  931.31g 931.31g
 lvs -a -o +devices

add a disk to a PV

 vgextend vg_1 /dev/sdb
 Volume group "vg_1" successfully extended

remove a disk from PV

vgreduce vg_1 /dev/sdb
 Removed "/dev/sdb" from volume group "vg_1"

delete a PV

vgremove vg_1
Volume group "vg_1" successfully removed

Resizing out from Disk->PV->LV->Partition

  • After resizing a physical drive this commands will claim the space gained to the file system.
  • resizing LVM linux partition to the new disk boundaries
pvresize /dev/md1
  • adding 100G
lvextend -L+100G /dev/mapper/vg0-var
  • ext4 resizing command
resize2fs /dev/mapper/vg0-var
df -hT

Logical Volumes

create a mirror volume

lvcreate -L 931g vg_1 -m 1 vg_1

create a mirror from existing and mounted volume

lvconvert -m1 vg_1/lv_home
  • then we check the result:
# pvs;echo;vgs;echo;lvs
 PV         VG         Fmt  Attr PSize   PFree 
 /dev/sda2  vg_1 lvm2 a--  930.82g     0 
 /dev/sdb   vg_1 lvm2 a--  931.31g 56.33g
 VG         #PV #LV #SN Attr   VSize VFree 
 vg_1  2   3   0 wz--n- 1.82t 56.33g
 LV      VG         Attr     LSize   Pool Origin Data%  Move Log          Copy%  Convert
 lv_home vg_1 mwi-aom- 874.98g                         lv_home_mlog 100.00        
 lv_root vg_1 -wi-ao--  50.00g                                                    
 lv_swap vg_1 -wi-ao--   5.84g