LVM (Logical Volume Manager) on Linux


LVM Creation

Step 1 : Create Physical Volume (PV)

                # pvcreate /dev/nvme3n1

Step 2: Create Volume Group (VG)

                # vgcreate VG1 /dev/nvme3n1

Step 3: Create Logical Volume (LVM)

                # lvcreate -L 50G -n lvdata VG1

Step 4: Format the created volume as xfs filesystem

                # mkfs.xfs /dev/VG1/lvdata

Step 5: Create a directory lvdata_dir under / and mound the volume

                # mkdir /lvdata_dir

                # mount /dev/VG1/lvdata /lvdata_dir

Step 6: Permanent mount of filesystem

It is recommended to mount the filesystem with its UUID. To get UUID of any filesystem, use blkid command

               # blkid

To mount the fiesystem permanently, edit /etc/fstab file

               UUID=6836863876DGH8    /lvdata_dir    xfs    defaults,nofail    0 0

To extend Logical Volume

Step 1:  Resize Physical Volume (PV)

            # pvresize /dev/nvme3n1

            #pvs - will list the Physical Volumes and size

            #vgs - will list Volume Groups and Size

Step 2: Extend the LVM

            # lvextend -r -L +125G /dev/VG1/lvdata

To Rename Volume Group

           # vgrename vg02 my_volume_group_new

           # vgrename /dev/vg02 /dev/my_volume_group_new

To Rename LVM

           # lvrename vg02 lvold lvnew

           # lvrename /dev/vg02/lvold /dev/vg02/lvnew

No comments:

Powered by Blogger.