#LVM
- There are multiple physical disk in your system . use
lsblk
command to see it . Eg : /sda /sdb - Each of the physical disk has partition like /sda1 /sda2
- use any of the physical disk partition to create a phyical volume . we can use only one disk or more . To create a physical disk use :
pvcreate /dev/sdb
4.put these physical volume in the volume group by "vgcreate <vg-name> <physical-disk>
vgcreate test /dev/sda1 /dev/sda2
5.we can usepvdisplay
andvgdisplay
to see information about physical and volume group . similarly we can find information regarding volume group viavgscan
. - we will create a new logical volume from volume group .
lvcreate -n <lv-new name> --size 1G <vg-name>
lvcreate -n helloworld --size 1G test
- Make a appropriate filesystem to recently created logical volume .
mkfs.xfs /dev/<vg-name/<logical-volume-name>>
mkfs.xfs /dev/test/sudeep
8.Make a directory and mount the newly created partition over there to use :mkdir /home/hello
mount /dev/test/sudeep /home/hello
9.uselvdispaly
to see the list of all logical volume. - For checking and resizing
e2fsck -f /dev/test/sudeep
resize2fs /dev/test/sudeep
Note : creating a raid0
mdadm -v --create /dev/md0 --level=0 --raid-device=2 /dev/sda /dev/sdb
Lvm snapshot will create new block device .
Two types :
LVM 1 = readonly(2.4) LVM 2 = r/w (2.6) = no downtime
- use
vgs
command to view . Here we have to see the size of Vfree . If the size is 0 we have to attach a new physical disk . - use
df -h
command to see the file system . pvcreate /dev/sde
vgextend <vgname to extend> <physical volume name>
vgextend vg-desk8 /dev/sde
This command adds the block device /dev/sde to this volume group .- create a snapshot now.
lvcreate -s <name of volume group> -n <name of snapshot> -L <size of it >
lvcreate -s /dev/mapper/vg-desk-root -n rootsnap -L512M
6.lvs
7.mount /dev/vg-desk8/rootsnap /mnt
8.ls -l /mnt