-
Go through steps 1 - 5 of the installation guide.
-
Steps 3 - 9 of this document replace step 6 (Set up partitions) of the installation guide.
-
Create a small physical /boot partition. In this example, /boot will be
not managed by LVM. This partition will contain your booting kernel and
Grub. I created a 100 MB partition, enough for quite a few kernel
generations.
-
Create a / (root) partition. If you are interested in trying to put your
root partition under LVM management, see the resources section at the end
for a link to a mini-howto on how to do this. The size of the root
partition need not be large if you will keep /opt /usr /home /var and
/tmp in an LVM Volume Group (vg).
I would also recommend NOT to put the following directories in an
LVM partition:
- /etc
- /lib
- /mnt
- /proc
- /sbin
- /dev
- /root
This way, you would still be able to log into your system (crippled, but
still somewhat usable, as root) if something goes terribly wrong.
-
Assuming the /boot and root partitions do not use the whole physical disk,
create a third partition on this disk and set it to type 8e (Linux LVM).
If you have more physical drives you would like to use with LVM, create
one partition on each and give them the same type (8e).
You can also prepare a whole device instead of a partition.
-
Prepare the partitions.
pvcreate /dev/sda3
pvcreate /dev/sdb1
-
Setup a volume group.
vgcreate does not recognize links pointing to the physical
partition therefore use
ls -l /dev/hd* and or /dev/sd*
to find out the actual devices.
In my case /dev/sda1 and /dev/sda2 are
the /boot and root partitions so I care only about /dev/sda3 and /dev/sdb1.
/dev/sda3 points to /dev/scsi/host1/bus0/target0/lun0/part3 and
/dev/sdb1 points to /dev/scsi/host1/bus0/target1/lun0/part1. Therefore my
vgcreate will look as follows:
vgcreate vg /dev/scsi/host1/bus0/target0/lun0/part2 \
/dev/scsi/host1/bus0/target1/lun0/part1
-
Create the logical volumes. Logical volumes are the equivalent of
partitions you create using fdisk in a non LVM environment. In my example
I create the following partitions:
Directory |
Size |
/usr10 GB
/home5 GB
/opt5 GB
/var10 GB
/tmp2 GB
Since I was going to use LVM, I didn't worry too much about partition
sizes since I can always move space around as needed.
Terje Kvernes commented correctly, that it is easier to increase the
size of a partition then to shrink it. You might want therefore to start
with smaller partitions and increase their size as needed.
I also created a swap partition on LVM. You will be probably better off
not using LVM for swap, but I felt I had to try it :-)
lvcreate -L10G -nusr vg
lvcreate -L5G -nhome vg
...
lvcreate -L2G -ntmp vg
-
Format the logical volumes the same way you format a regular partition:
First, lets take care of the swap logical volume:
mkswap /dev/vg/swap
I am using ext3 on the rest of the logical volumes:
mke2fs -j /dev/vg/usr
...
The rest of the installation document is mostly unchanged so I will not
walk you through it again except to point differences.
-
Follow step 7 (Mount partitions) of the installation document exchanging
/dev/vg/partition_name for /dev/hdxx (except of course for the boot and
root partitions since they are not on a LVM).
-
Step 14 (Final steps: kernel and system logger) - Make sure to configure
your kernel to support LVM. You can find this option in the entry named
Multi-device support (RAID and LVM)
also make sure to merge the lvm-user package.
-
Step 16 (Final steps: /etc/fstab) - Add your LVM partitions to /etc/fstab
as needed. Again, here are few lines from my machine:
/dev/sda1 /boot ext3 noauto,noatime 1 1
/dev/sda2 / ext3 noatime 0 0
/dev/vg/opt /opt ext3 noatime 0 0
/dev/vg/usr /usr ext3 noatime 0 0
...
If you configured LVM as a module when you configured the kernel, add to
your /etc/modules.autoload the line
lvm-mod
-
Step 17 (Installation complete!) - Don't forget to umount all your LVM
partitions as well and for a good measure run the following command before
you reboot:
vgchange -an
-
Reboot your machine, but be warned that the boot process will likely give
you many error messages since the localmount script will fail to
recognize the fact that LVM is in use. Once you log into your system,
issue the following command:
vgscan
This will generate the /etc/lvmtab that the localmount script uses to
check if it should start LVM. Restart your machine and now all
partitions should be visible and mounted.