The benefits of using LVM
- Create Extremely large logical volumes
- Add logical volumes in a running system
- Add hard disks to volume group in running system
- The snapshot feature allows consistent backups in a running system
Create a physical volume
The first step in LVM is to start with a physical partition. Create a partition using fdisk or parted. Assume that partition is /dev/sda1. To set up a new PV on a properly configured partition, apply pvcreate command:
#pvcreate /dev/sda1
If more than one partition configured as a PV:
#pvcreate /dev/sda1 /dev/sda2 /dev/sdb1
Create a volume group:
#vgcreate MyVol0 /dev/sda1 /dev/sda2
To include additional PV or to extend a VG:
#vgextend MyVol0 /dev/sdb1
Create a logical volume:
#lvcreate -L 3G MyVol0 -n home
Use of Logical Volume:
Create a mount point and mount LV home to mount point.
#mkdir /Test
#mount /dev/MyVol0/home /Test
Remove a LV:
#umount /dev/MyVol0/home
#lvremove /dev/ MyVol0/home
Resize Logical Volumes:
Backup existing data on LV mounted directory for example /home and unmount it.
First extend the VG, if it doesn’t have more space.
#vgextend MyVol0 /dev/sdc1
#vgdisplay MyVol0 - to view total of VG
Then extend LV
#lvextend -L 200M /dev/MyVol0/home
Then resize the LV with resize2fs
#resize2fs /dev/MyVol0/home
No comments:
Post a Comment