LVM
What is LVM?
LVM is Logical Volume management. In computer storage, lvm provides a method of allocating spaces on mass storage device that is more flexible than conventional partition schemes. One thing to keep in mind, we cannot bring /boot on LVM.
Following are the steps to create LVM on linux.
- Create physical volume
- Create volume group
- Create logical volume
- Make file system
- Mount the file system
1. Login with root user
2. Look for the unpartion slice or disk
# fdisk -l
Say for example we have /dev/sda4,/dev/sda5,etc
3. We will now create physical volume
# pvcreate /dev/sda4
We can also add two or more slice
# pvcreate /dev/sda4 /dev/sda5
To look for the details of physical volume, run the following command
# pvdisplay
4. Now create the volume group.
# vgcreate data /dev/sda4 /dev/sda5
where data is the name of volume group, by default 5mb volume group is created.
To make aroung 1gb we use the command,
# vgcreate -s 1G data /dev/sda4 /dev/sda5
# vgdisplay
Will display the volume group details.
5. Next step is to create Logical volume
# lvcreate -l 50 -n datavol data
where datavol is the name of logical volume. If we want the logical volume in KB,MB,GB use -L
# lvcreate -L 20G -n datavol data
# lvdisplay
If will display teh details of Logical volume we created.
6. Next step is to create the file system on the logical volume we created.
# mke2fs -j /dev/data/datavol
7.Now create the mount point to use the file system
# mkdir /storage ( name of directory)
# mount /dev/data/datavol /storage
Logical volume /storage is created.
If we need to resize the volume, we need to follow the step
# unmount /storage
# e2fsadm -L -1G /dev/data/datavol ( 1G is the extended volume)
# mount /storage
OR
# umount /storage
# resize2fs /dev/data/datavol 1G
# lvreduce -L -1G /dev/data/datavol
# mount /storage

Leave a Reply