Logical Volume Manager v.2
This is going to be a page dedicated to LVM2, with information on "what, why and how", complete with several examples. What is LVM2, Why use LVM2, How to use LVM2
Anyone and everyone with knowledge and experinece with LVM2 are more than welcome to contribute.
Since this page is far from complete, you shoud also take a look at Installing_with_Software_RAID_or_LVM, TLDP LVM HOWTO and RAID_Encryption_LVM
Example 1: Install with root on lvm2
- A desktop system with one disc, 20GB. No other os installed.
- The install medium used in this example is the Archlinux-i686-2007.05-Duke-Linuxtag2007.ftp.iso
We need to create some partitions. One for /boot and one for the LVM setup. I prefer cfdisk for this, but you can use any tool you like.
- /dev/sda1 100Mb Primary, type 83, bootable
- This is going to be boot partition. It is possible to have the boot partition on lvm2, but you will have to use Lilo or Grub 1.95 or later. (arch provides grub 0.97 on the cd)
- /dev/sda2 20Gb Primary, type 83
- This is where we are going to put the LVM. You don't realy need to create a partition for it, but it has some advantages. Mainly, many partition tools can't see a LVM setup, and just think that the space is free, unless you set up a normal partition for it. This can can cause problems e.g. if you later decide to set up dualboot with another os.
Set up LVM2
First load the necessary kernel module:
# modprobe dm-mod
Initialize the partition so that lvm can use it: Note: On the install cd, you have to run lvm [some_tool] instead of [some_tool] as you would on an already installed system.
# lvm pvcreate /dev/sda2
Create a volume group (you can use another name instead of vgroup1, if you want)
# lvm vgcreate vgroup1 /dev/sda2
Create some logical volumes(partitions) on the volume group. (you can give them any name you want)
- First, lets create a 5GB / partition:
# lvm lvcreate -L 5G vgroup1 -n root
- Next, a 512MB swap
# lvm lvcreate -L 512M vgroup1 -n swap
- And last, let's use the remaining free space for /home
# lvm lvcreate -l 100%FREE vgroup1 -n home
Now we need to activate the volume group before we start the installer:
# lvm vgchange -a y vgroup1
The Arch Installer
Note: This only list the steps that have to do with lvm2. Refer to the install guide for more information about the other steps of the install.
Start the installer
In the installer, under "Prepare Hard Drive, skip directly to step 3 "Set Filesystem Mountpoints"(don't choose autoprepare or partition hard drive)
- /boot with ext3
- /root with ext3
- swap with swap
- /home with ext3
Important:' Answer YES to Preconfiguration with hwdetect, and to boot from LVM2
- Chang USELVM="no" to USELVM="yes"
- Make sure that lvm2 is present in HOOKS=
- Just glance over it to check that the mount points are correct.
- The installer usualy get this one right, but just check that everything is ok, specialy the root= line.
Install grub to /dev/sda and choose NO to the software raid question.
That's it, exit the installer, remove the cd, and reboot.