subject: Playing with LVM ( a.k.a. Logical Volume Manager for Linux ) on any existing disk [print this page] Playing with LVM ( a.k.aPlaying with LVM ( a.k.a. Logical Volume Manager for Linux ) on any existing disk
Let's start with what LVM is; in short it's away to manage disk volumes in more of a user friendly way, whether they are whole hard disk, disk partitions, or SAN disk. Logical Volume Manager gives the Administrator much more flexibility in allocating, re-sizing, and moving storage around. With that being said, the greatest advantage is having the ability to add additional disk space with relative ease, which with Moore's Law and Kryder's Law [1] floating around makes life a little easier on your System Administrator.
Now that you are all interested in using LVM, let's bust out a new hard-drive or re-partition our hard-disk and have at it. Woo! Hang on a minute! That sounds like a pain just to play around with something. That's what I thought too, so here is a way to use your existing partitions using loop devices and empty disk images to play around with and get use to the commands.
I have personally tested this on RHEL 4 and 5, but I don't see why this couldn't be done on any current version of Linux.
1.) First create a couple of empty dd images that will be used as loop devices.
5.) Display the volume group information, so we can see the VG Size and see how big to make the volume.
shell> vgdisplay
--- Volume group ---
VG Name volumegroup0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 288.00 MB
PE Size 4.00 MB
Total PE 72
Alloc PE / Size 0 / 0
Free PE / Size 72 / 288.00 MB
VG UUID 0mAIRf-Gzz0-R4zP-K0OH-u33B-R31w-jvVbC2
6.) Create a logic volume with lvcreate.
shell> lvcreate -L288M -nvolume0 volumegroup0
Logical volume "volume0" created
7.) Now you can format the volume with mkfs.
shell> mkfs.ext3 /dev/volumegroup0/volume0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
73728 inodes, 294912 blocks
14745 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
36 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
8.) Now you can mount it.
shell> mount /dev/volgroup0/volumename /mnt
Now that you have gotten started, I suggest that you play around with some of the other options, such as adding and removing disks, deleting groups and volumes, moving and splitting volume groups.
[1] "Moore's Law" describes an important trend in the history of computer hardware: that the number of transistors that can be inexpensively placed on an integrated circuit is increasing exponentially, doubling approximately every two years.
A similar law (sometimes called "Kryder's Law") has held for hard disk storage cost per unit of information. Disk storage over the past decades has actually sped up more than once, corresponding to the utilization of error correcting codes, the magneto-resistive effect and the giant magneto-resistive effect. The current rate of increase in hard drive capacity is roughly similar to the rate of increase in transistor count. Recent trends show that this rate has been maintained into 2007.