Installing LVM2

Loading the LVM2 module

# modprobe dm-mod

Before scanning and activating LVM, you might want to edit /etc/lvm/lvm.conf to exclude some devices. By default, LVM2 will scan all devices, even your CDROM which can generate error messages. In the following example, the line that allows scanning of all devices is replaced by one that rejects every device but our two IDE disks.

Activating LVM

(Avoid scanning all devices but our disks)

# nano -w /etc/lvm/lvm.conf

(Look for the following line)

  filter = [ "a/.*/" ]

(Replace it with the following one to scan /dev/hda and /dev/hdb and reject anything else)

  filter = [ "a|/dev/hd[ab]|", "r/.*/" ]

(Save the file and quit nano)

# 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

Prepare the partitions.

Preparing the partitions

# pvcreate /dev/sda5
  No physical volume label read from /dev/sda5
  Physical volume "/dev/sda5" successfully created

Setup a volume group. A volume group is the result of combining several physical units into a single logical device.

Creating and extending a volume group

(Create a volume group named vg)

# vgcreate vg /dev/sda5
  /etc/lvm/backup: fsync failed: Invalid argument (Ignore this warning)
  Volume group "vg" successfully created

Create the logical volumes. Logical volumes are the equivalent of partitions you would create using fdisk in a non LVM2 environment. In our example, we create the following partitions: Directory Size /home 5 GB

Since we are going to use LVM2, we should not worry too much about partition sizes because they can always be expanded as needed.

Creating and extending logical volumes

# lvcreate -l100%FREE -nhome  vg
  Logical volume "home" created

Create filesystems on the logical volumes the same way you would on a regular partition. We use ext3 on the logical volumes but any filesystem of your choice will work:

Creating the filesystems

# mke2fs -j /dev/vg/home

Mount your partitions as described in the handbook and mount your LVM2 logical volumes as if they were partitions. Replace the usual /dev/hdxx with /dev/vg/logical_volumename.

Mounting your logical volumes

(Make sure you have mounted your root partition as described in the handbook first)

# mount /dev/vg/home /home
/var/customers/webs/cw01/wiki/data/pages/filesystems/lvm2_install.txt · Last modified: 2010/10/28 09:29 by wadmin
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki