TECHNOLOGY
- Dokuwiki
- Miscellaneous
LVM is a great way to expand storage dynamically. When combined with the drive failure warnings provided by the LM Sensors tool, a certain level of failure avoidance is offered, thus providing a certain level of fault tolerance1).
There is a simple procedure for setting up LVM. The easiest way (which I didn't use) is to set it up during the OS install. Some Linux distros support it while others don't. I didn't have enough drives to need LVM when I built my system, so I added it later.
The process below assumes you have followed the same installation procedure (meaning you are installing LVM onto an already existing system).
sudo -i
command and enter your root password. apt-get install lvm2
modprobe dm-mod
fdisk
. This does the physical partitioning of the drives. My 3 disks are partitioned as type 83 as shown here. Other people recommend type 8e, which fdisk lists as Linux LVM
. Maybe thats the standard for new systems starting with LVM2, but I started with LVM1 and migrated. Device Boot Start End Blocks Id System /dev/hda1 * 1 12853 103241691 83 Linux /dev/hda2 12854 36481 189791910 5 Extended /dev/hda5 12854 13375 4192933+ 82 Linux swap / Solaris /dev/hda6 13376 36481 185598913+ 83 Linux /dev/hdc1 1 24792 199141708+ 83 Linux /dev/hdd1 1 24321 195358401 83 Linux
pvcreate
2) on each partition that will become part of your LVM system, like this: pvcreate /dev/hda6 #my CD drive is /dev/hdb pvcreate /dev/hdc1 pvcreate /dev/hdd1 ...
vgcreate
to setup a volume group on top of the physical volumes:vgcreate vg1 /dev/hda4 /dev/hdc1 /dev/hdd1
video
on the volume group. The size is 595gb in my case. Your system might be different.lvcreate -n video -L 595G vg1
mkfs.xfs /dev/vg1/lv1
/etc/fstab
so the volume group gets mounted at boot time. Notice the device mapper's location is being used rather than the logical device itself (/dev/vg1/lv1
). /dev/mapper/vg1-lv1 /video xfs defaults 0 2
/video
as the storage location for videos in MythTV's setup program./dev/sda
fdisk
3) and create a partition for the entire drive. Creating a partition is optional since LVM can use the entire drive, but it will keep other OSes from overwriting the drive if you ever install it in another system. I used a primary partition and it became /dev/sda1
pvcreate /dev/sda1
to create a physical volume out of the primary partitionvgextend vg1 /dev/sda1
to add the physical volume to the volume group (my volume group is called 'vg1')lvextend -L+460G /dev/vg1/lv1
to add 460gb to a logical volume (Note that 'vgs' command showed how much free space is available).xfs_growfs /video
. Here '/video' is the mountpoint of my volume group. Your filesystem may be different (ext2, ext3, reiser, jfs, etc…) and your mountpoint may have a different name. But the idea is the same…you create a physical volume, add it to a volume group, then extend the size of a logical volume with the volume group, and finally use the normal file system utilities to grow the size of the filesystem.
As a side note, be careful when choosing a filesystem. The filesystem's characteristics do matter. Some are not shrinkable, which will be important if you need to remove a drive later. Others are not growable, which seems to defeat the purpose of using LVM. For me, with MythTV, I am concerned about the efficiency of dealing with large files…creating them, reading them, and then deleting them. The recording, playback, and delete performance of my system (respectively) are impacted by my choice of filesystem.
After a bit of research, I decided on XFS. So far it has been a great choice. I highly recommend it for MythTV systems using LVM for storage management.