Table of Contents

Logical_Volume_Manager

As the Gentoo Wiki suggests, this guide will focus on using Webmin to set up and manage logical volumes in LVM.

Installation and Setup

sudo dpkg –i webmin_1.400_all.deb :It will probably report that some packages are missing, so use sudo apt-get install <…> :to install the missing packages. apt-get should then automatically install Webmin once the pre-requisites are installed.

sudo umount <device> :to unmount it.

Mirroring

Note: At least three physical disks need to be added to the Volume Group before 2-disk (i.e. -m1) mirroring can be enabled, as LVM needs to store a log of the mirroring state on a disk that isn't involved in the mirroring itself. For a 3-disk (-m2) mirror, four physical disks need to be in the VG, etc.

To convert a logical volume so that it is mirrored onto another physical disk, use, e.g.: lvconvert -m1 Pool/Music

The status of mirrored logical volumes, including the state of copying, can be accessed with: lvs -a -o +devices

To convert a mirrored logical volume to a linear (non-mirrored) logical volume, use: lvconvert -m0 Pool/Music

If a physical disk fails, any mirrored volumes stored on it (either wholly or partially) will be automatically converted to linear volumes. To restore the redundancy, replace the failed disk, then convert the volume back to a mirrored volume as detailed above. Any non-mirrored volumes that are stored on the failed disk will be either entirely broken, or will at least have a lot of data missing; therefore, mirror any volumes containing data you care about.

Unfortunately mirrored logical volumes cannot (yet) be resized while active, so to resize a mirrored volume, use, e.g.: lvconvert -m0 Pool/Music lvresize -L 10G Pool/Music lvconvert -m1 Pool/Music

Encrypting

dm-crypt can be used to encrypt a partition. This is only useful while the disk is unmounted, as while it is mounted the keys are in memory and the disk can be read.

 # To create
 cryptsetup -y create encrypted-volume /dev/mapper/pool-volume
 mkreiserfs /dev/mapper/encrypted-volume
 
 # To mount
 mount /dev/mapper/encrypted-volume /mnt/volume
 
 # To unmount
 umount /dev/mapper/encrypted-volume
 cryptsetup remove encrypted-volume

Resizing

LVM logical volumes can be resized easily, with extra blocks of storage being used wherever they can be found. If you use ReiserFS you can even grow (but not shrink) a logical volume without unmounting it first, otherwise you'll have to unmount it while you perform the resize.

Growing

lvextend -L+1G Pool/Music

ReiserFS

resize_reiserfs /dev/mapper/Pool-Music

XFS

xfs_growfs /mnt/Pool/Music

To Do

Snapshots

LVM provides the ability to create snapshots of volumes, and while Webmin can create them, ideally it should be an automated process that's combined with Samba to allow Windows 2000/2003/2008/XP/Vista clients to access the snapshots as “previous versions”.