How To Configure LVM on Linux / CentOS / Redhat
Here in this we will learn to Setup Logical Volume Management LVM on Linux. This provides a method of allocating space on mass-storage devices that is more flexible than conventional partitioning schemes. In particular, a volume manager can concatenate, stripe together or otherwise combine partitions into larger virtual ones that administrators can re-size or move, potentially without interrupting system use.
Page index:
Overview
Setup Physical Volumes
Setup Volume Groups
Setup Logical Volume Group
Extending Volume Group
Extending Logical Volume
Reducing Logical Volume
Page 1 of 7
In this lesson we have taken 4 hdd each of 20 GB (sdc,sdd,sde,sdf), These all are device drivers equivalent to physical hdd’s . The following terms will be used in the lesson
Volume Group Layout:
Logical Volumes |
/dev/smbserver/data 45GB |
/dev/smbserver/backup 10GB |
/dev/smbserver/videos 20GB |
Free Space 5GB |
|||
Volume Group |
Smbserver 80GB |
||||||
Physical Volumes |
/dev/sdc1 20GB |
/dev/sdd1 20GB |
/dev/sde1 20GB |
/dev/sdf1 20GB |
You have one or more physical volumes (/dev/sdc1 – /dev/sdf1 in our example), and on these physical volumes you create one or more volume groups (smbserver), and in each volume group you can create one or more logical volumes. If you use multiple physical volumes, each logical volume can be bigger than one of the underlying physical volumes (but of course the sum of the logical volumes cannot exceed the total space offered by the physical volumes).
It is a good practice to not allocate the full space to logical volumes, but leave some space unused. That way you can enlarge one or more logical volumes later on if you feel the need for it.
In this example we will create a volume group called fileserver, and we will also create the logical volumes /dev/smbserver/data, /dev/smbserver/backup, and /dev/smbserver/videos.
Arguments Used:
1 Smbserver 80G – Name of the volume group
2 data 45G – Name of first logical volume
3 backup 10G – Name of second logical volume
4 videos 20G – Name of third logical volume
5 /dev/sdc1,/dev/sdd1,/dev/sde1,/dev/sdf1– Physical volume (PV’s) of the above 4 hdd’s. These all are device drivers equivalent to partitions on hdd’s.
6 – Press enter
Physical Volume Creation:
Use the command to list hdd available on the system. In this /dev/sda and /dev/sdb are used by Linux itself, other four will be used for LVM.
[root@SRV01 ~]# fdisk –l
You will get the following similar output.
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 325 2096482+ 82 Linux swap / Solaris
/dev/sda3 326 452 1020127+ 83 Linux
/dev/sda4 453 3916 27824580 5 Extended
/dev/sda5 453 1727 10241406 83 Linux
/dev/sda6 1728 2556 6658911 83 Linux
/dev/sda7 2557 3193 5116671 83 Linux
/dev/sda8 3194 3916 5807466 83 Linux
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 5 Extended
/dev/sdb5 1 1217 9775489+ 83 Linux
/dev/sdb6 1218 2610 11189241 83 Linux
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn’t contain a valid partition table
Disk /dev/sdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn’t contain a valid partition table
Disk /dev/sde: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn’t contain a valid partition table
Disk /dev/sdf: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn’t contain a valid partition table
In the above we don’t have any partitions. We haven’t made it. We need create the partition and we have to assign the LVM id (8e) to partition.Next create the partition for /dev/sdc. Here I used full hdd space as partition so simply I pressed enter without giving any value in first cylinder and last cylinder below.
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
If you want custom size put the value only on End cylinder value, for example of 5Gb size of partition. It looks like below.
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):+5000M
Using default value 2610
The above two is just example of making partition. Here i am using the following one.
Page 2: Setup Physical Volumes