1.Load the LVM2 module:
# modprobe dm-mod
2. Activating LVM
# vgscan
Reading all physical volumes. This may take a while...
No volume groups found
(Make any previously set up volume groups available)
# vgchange -a y
3. Prepare the partitions:
# pvcreate /dev/hda4 /dev/hdb1
No physical volume label read from /dev/hda4
Physical volume "/dev/hda4" successfully created
No physical volume label read from /dev/hdb1
Physical volume "/dev/hdb1" successfully created
4. Create a volume:
(Create a volume group named vg)
# vgcreate vg /dev/hda4
/etc/lvm/backup: fsync failed: Invalid argument (Ignore this warning)
Volume group "vg" successfully created
(Extending an existing volume group)
# vgextend vg /dev/hdb1
/etc/lvm/backup: fsync failed: Invalid argument (Ignore this warning, again and later as well)
Volume group "vg" successfully extended
5. Create a logical volume:
# lvcreate -L10G -nusr vg
Logical volume "usr" created (Further similar messages not displayed)
# lvcreate -L5G -nhome vg
# lvcreate -L5G -nopt vg
# lvcreate -L10G -nvar vg
# lvcreate -L2G -ntmp vg
(As an example, let's extend a logical volume with 5 extra Gbytes)
# lvextend -L+5G /dev/vg/home
To create a 1500MB linear LV named ‘testlv’ and its block device special ‘/dev/testvg/testlv’:
# lvcreate -L1500 -ntestlv testvg
|
To create a 100 LE large logical volume with 2 stripes and stripe size 4 KB.
# lvcreate -i2 -I4 -l100 -nanothertestlv testvg
|
If you want to create an LV that uses the entire VG, use vgdisplay to find the “Total PE” size, then use that when running lvcreate.
# vgdisplay testvg | grep "Total PE"
Total PE 10230
# lvcreate -l 10230 testvg -n mylv
|
This will create an LV called mylv filling the testvg VG.
If you want the logical volume to be allocated from a specific physical volume in the volume group, specify the PV or PVs at the end of the lvcreate command line.
# lvcreate -L 1500 -ntestlv testvg /dev/sdg
6. Create filesystems:
# mke2fs -j /dev/vg/usr
# mke2fs -j /dev/vg/home
# mke2fs -j /dev/vg/opt
# mke2fs -j /dev/vg/var
# mke2fs -j /dev/vg/tmp
Other:
renaming a vg:
I did `lvchange -an` the logical volumes first, then `vgrename`, then `lvchange -ay` again.
http://www.gentoo.org/doc/en/lvm2.xmlhttp://tldp.org/HOWTO/LVM-HOWTO/ http://www.linuxquestions.org/questions/linux-general-1/how-to-rename-a-vol-group-433993/Â
