I’ve found these useful examples about LVM, Article By Roger Hosto
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.
shell>dd if=/dev/zero of=/tmp/diskvol0.img bs=1024 count=102400 102400+0 records in 102400+0 records out shell>dd if=/dev/zero of=/tmp/diskvol1.img bs=1024 count=102400 102400+0 records in 102400+0 records out shell>dd if=/dev/zero of=/tmp/diskvol2.img bs=1024 count=102400 102400+0 records in 102400+0 records out <strong>2.) Ora impostare le immagini come dispositivi loop utilizzando il comando losetup.</strong> shell>losetup /dev/loop0 /tmp/diskvol0.img shell>losetup /dev/loop1 /tmp/diskvol1.img shell>losetup /dev/loop2 /tmp/diskvol2.img <strong>3.) Ora usare il comando pvcreate per inizializzare i dispositivi loop per l'utilizzo da LVM.</strong> |
2.) Now set the images up as loop devices using the losetup command.
shell> pvcreate /dev/loop0 Physical volume "/dev/loop0" successfully created shell> pvcreate /dev/loop1 Physical volume "/dev/loop1" successfully created shell> pvcreate /dev/loop2 Physical volume "/dev/loop2" successfully created |
3.) Now use the pvcreate command to initialize the loop devices for use by LVM.
shell> vgcreate volumegroup0 /dev/loop0 /dev/loop1 /dev/loop2 Volume group "volumegroup0" successfully created |
4.) Create a volume group with vgcreate.
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 |
5.) Display the volume group information, so we can see the VG Size and see how big to make the volume.
shell> lvcreate -L288M -nvolume0 volumegroup0 Logical volume "volume0" created |
6.) Create a logic volume with lvcreate.
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. |
7.) Now you can format the volume with mkfs.
shell> mount /dev/volgroup0/volumename /mnt |
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.
References and more information:
http://www.tldp.org/HOWTO/LVM-HOWTO/
http://www.redhat.com/magazine/009jul05/features/lvm2/
Notes:
[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.
Roger Hosto – About the Author:
I’m a Database, LAMP, LAPP, and LAMJ Professional with over 14 years of intensive hands-on experience managing technology operations (e.g., websites, back end functions, architecture) for leading Internet websites under highly demanding conditions. I’m knowledgeable in cutting-edge hardware, software, database, and Internet technologies. I’m experienced at building and maintaining highly available websites from the ground up. Find out more about me at www.rogerhosto.com.
Popular Posts:
- None Found