X

Rate Us :



Share with Friends :

Menu

Logical Volume Manager(LVM) :

LVM is a method of allocating hard drive space into logical volumes that can be easily resized.

With LVM, the hard drive or set of hard drives are allocated to one or more physical volumes.

The physical volumes are then combined into volume groups.

Each volume group is divided into logical volumes which are formatted with a file system like ext4 and are then mounted.


Configuring LVM :


Create four partition with any size - [root@localhost~]#fdisk /dev/sda Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +10GB Command (m for help): p [lets say we already have 10 partition available so, the new partition will be /dev/sda11]


Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +10GB Command (m for help): p [lets say we already have 11 partition available so, the new partition will be /dev/sda12]
Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +10GB Command (m for help): p [lets say we already have 12 partition available so, the new partition will be /dev/sda13]
Command (m for help): n First cylinder (3634-3917, default 3634): [Enter] (To avoid giving size of partition in cylinder) Last cylinder, +cylinders or +size{K,L,M}{3634-3917, default 3917}: +10GB Command (m for help): p [lets say we already have 13 partition available so, the new partition will be /dev/sda14] Command (m for help): w
To update new partition table without restarting the OS - [root@localhost~]#partprobe /dev/sda [for CentOS 7 or RHEL 7] [root@localhost~]#partx -a /dev/sda [for CentOS 6 or RHEL 6] Create physical volume - [root@localhost~]#pvcreate /dev/sda{11,12,13} To check physical volume database - [root@localhost~]#pvdisplay Create volume group - [root@localhost~]#vgcreate algovg /dev/sda{11,12,13} To check volume group database - [root@localhost~]#vgdisplay Create logical volume - [root@localhost~]#lvcreate -L +10GB algovg -n algolv To check logical volume information - [root@localhost~]#lvdisplay Format the logical volume - [root@localhost~]#mkfs.ext4 /dev/algovg/algolv Create a directory - [root@localhost~]#mkdir /lvmdir Mount the logical volume - [root@localhost~]#mount /dev/algovg/algolv /lvmdir Store data in lvmdir - [root@localhost~]#touch /lvmdir/file1 Resize the logical volume - [root@localhost~]#lvextend -L +10GB /dev/algovg/algolv Update the mounted logical volume size - [root@localhost~]#resize2fs /dev/algovg/algolv To check mounted partition size - [root@localhost~]#lvdisplay [root@localhost~]#df -h /lvmdir Extend the volume group size : Add a new disk into physical volume - [root@localhost~]#pvcreate /dev/sda14 Add a new device to volume group - [root@localhost~]#vgextend algovg /dev/sda14 To see the result - [root@localhost~]#vgdisplay To remove logical volume - [root@localhost~]#unmount /lvmdir