To use LVM you need to take at least one partition, initialise it for use with LVM and then include it in a volume group. Why would you do this? Well it would let you create new partitions on the fly, and make better use of your space.
In my case I have a laptop with the following setup:
Code:
Name Flags Part Type FS Type [Label] Size (MB)
------------------------------------------------------------------------------
hda1 Boot Primary Linux ext3 [/] 8000.01
hda2 Primary Linux swap / Solaris 1000.20
hda3 Primary Linux 31007.57
Here I have a 7Gb root partition which contains my Debian GNU/Linux installation. I also have a 28Gb partition which will be used by LVM. I've chosen this setup so that I can create a dedicated /home partition using LVM - and if I need more space I can extend it.
In this example hda1, hda2, and hda3 are all
physical volumes. We'll initialize hda3 as a physical volume:
Code:
root@lappy:~# pvcreate /dev/hda3
If you wanted to combine several disks, or partitions you could do the same for those:
Code:
root@lappy:~# pvcreate /dev/hdb
root@lappy:~# pvcreate /dev/hdc
Once we've initialised the partitions, or drives, we will create a volume group which is built up of them:
Code:
root@lappy:~# vgcreate skx-vol /dev/hda3
Here "skx-vol" is the name of the volume group. (If you wanted to create a single volume spanning two disks you'd run "vgcreate skx-vol /dev/hdb /dev/hdc".)
If you've done this correctly you'll be able to see it included in the output of vgscan:
Code:
root@lappy:~# vgscan
Reading all physical volumes. This may take a while...
Found volume group "skx-vol" using metadata type lvm2
Now that we have a volume group (called skx-vol) we can actually start using it.
Working with logical volumes
What we really want to do is create logical volumes which we can mount and actually use. In the future if we run out of space on this volume we can resize it to gain more storage. Depending on the filesystem you've chosen you can even do this on the fly!
For test purposes we'll create a small volume with the name 'test':
Code:
root@lappy:~# vgscan
Reading all physical volumes. This may take a while...
Found volume group "skx-vol" using metadata type lvm2
This command creates a volume of size 1Gb with the name test hosted on the LVM volume group skx-vol.
The
logical volume will now be accessible via /dev/skx-vol/test, and may be formatted and mounted just like any other partition:
Code:
root@lappy:~# vgscan
Reading all physical volumes. This may take a while...
Found volume group "skx-vol" using metadata type lvm2
Cool, huh?