Using the Linux LVM

From PeformIQ Upgrade
Jump to navigation Jump to search

Links

Qustions

how do i tell if there is a filesystem on a logical volume?

root@polaris:/u# file -s /dev/ubuntu-vg/ubuntu-lv
/dev/ubuntu-vg/ubuntu-lv: symbolic link to ../dm-0
root@polaris:/u#
root@polaris:/u# file -s /dev/ubuntu-vg/lv1
/dev/ubuntu-vg/lv1: symbolic link to ../dm-1

root@polaris:/u# file -L -s /dev/ubuntu-vg/lv1
/dev/ubuntu-vg/lv1: data
root@polaris:/u# file -L -s /dev/ubuntu-vg/ubuntu-lv
/dev/ubuntu-vg/ubuntu-lv: Linux rev 1.0 ext4 filesystem data, UUID=7c6ecda7-f151-4445-93e9-1244e2f50098 (needs journal recovery) (extents) (64bit) (large files) (huge files)




Command Examples


lvremove option LV
lvscan
pvdisplay
lvmdiskscan

lvremove vol_grp/lvol1



u# lvm
lvm> lvmdiskscan
  /dev/loop0 [      61.96 MiB]
  /dev/loop1 [     <79.95 MiB]
  /dev/sda1  [      <1.05 GiB]
  /dev/loop2 [      46.96 MiB]
  /dev/sda2  [       2.00 GiB]
  /dev/loop3 [     <61.96 MiB]
  /dev/sda3  [    <462.71 GiB] LVM physical volume
  /dev/loop4 [     <43.86 MiB]
  /dev/sdb   [     <27.96 GiB]
  1 disk
  7 partitions
  0 LVM physical volume whole disks
  1 LVM physical volume
lvm>
lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               ubuntu-vg
  PV Size               <462.71 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              118453
  Free PE               92853
  Allocated PE          25600
  PV UUID               UhkItV-lktv-M90s-QQ0K-3VpD-fXYN-TOzKI6

lvm> vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <462.71 GiB
  PE Size               4.00 MiB
  Total PE              118453
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       92853 / <362.71 GiB
  VG UUID               wrbg12-UAib-VOEF-c03c-ViIc-WADv-irQQbc

lvm> lvcreate -L 10G -n lv1 vg1
  Volume group "vg1" not found
  Cannot process volume group vg1
lvm> lvcreate -L 200G -n lv1 ubuntu-vg
  Logical volume "lv1" created.
lvm> lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                pedAP4-9fA7-zfZE-NLkU-1SSX-TaZY-nNB5vD
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2022-08-17 09:50:49 +1000
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/lv1
  LV Name                lv1
  VG Name                ubuntu-vg
  LV UUID                THHlpH-FHD4-dyMM-NYrz-fGmw-VwV6-bG9YnN
  LV Write Access        read/write
  LV Creation host, time polaris, 2022-08-21 14:01:17 +1000
  LV Status              available
  # open                 0
  LV Size                200.00 GiB
  Current LE             51200
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

lvm> lvscan
  ACTIVE            '/dev/ubuntu-vg/ubuntu-lv' [100.00 GiB] inherit
  ACTIVE            '/dev/ubuntu-vg/lv1' [200.00 GiB] inherit

Working with FDISK