|
Page 1 of 6
LVM Overview
LVM or Logical Volume Management is a tool used by Unix/Linux administrators to manage disk resources. LVM provides a layer of abstraction between the underlying physical disk/volume and the host operating system (Unix administrators often refer to disks as volumes.) LVM partitions can span across physical hard drives and can be re-sized (unlike traditional ext3 "raw" partitions.) LVM partitions offers features such as resizing, snapshots and mirroring of volumes all of which can be very useful in a variety of situations for management of disk in the enterprise.
In this KB article, we'll show you how to configure LVM on a Linux system. You can find additional articles in the Linux KB to guide you through other LVM administrative tasks such as renaming, removing, resizing, snapshots and mirroring.
Note: LVM is only supported in the Linux kernel 2.4 and above. If you don't have support for LVM, you may have to recompile your kernel from source.
LVM Creation can be broken down into 7 steps:
- Partitioning
- Physical volume(s) creation
- Volume group(s) creation
- Logical volume(s) creation
- Formatting of the file system
- Mounting of file system
- Updating fstab for automatic volume mounting
Partitioning
LVM partitions must be of type 8e (Linux LVM.) We are going to use fdisk to define three (3) new partitions on available disks installed in our server.
- Lets begin by taking a look at our current disks and their associated partitions (you must be root)
[root@Linux01 ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table [root@Linux01 ~]#
|
As you can see, we have one disk (/dev/sda) which already has a couple of partitions (for the running OS.) We have highlighted the three available disks which we will use for our LVM file system (/dev/sdb, /dev/sdc/ and /dev/sdd).
- Define a new partition of type 8e (Linux LVM) on /dev/sdb using fdisk
[root@Linux01 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-522, default 522): 522
|
- Change the type of the file system to 8e (Linux LVM)
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 522 4192933+ 8e Linux LVM |
- Write the changes to the partition table
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks. [root@Linux01 ~]#
|
- Repeat steps 2 - 4 until all the drives have partitions of type 8e created on them
|