Download this program

NAME - Assist in managing LVMs: creating and mounting a logical volume.

SYNOPSIS                     test   # Displays LV 'test' -drives b-c -create test   # Creates LV 'test' from /dev/sdb1 and /dev/sdc1 -drives 'b c' -size 146.8 -create test  # Same, but checks size of each is 146.8GB -drives sdd3 -add  test     # Adds /dev/sdd3 to LV 'test' -free        -add  test     # Shows what drives are available -delete            test     # Deletes PV, VG for LV 'test' 


Use this program to help manage LVMs. While creating a logical volume and making it available is not terrifically difficult, most of us do not work with these very often. Extending a volume can be confusing and always takes longer than I want. Prehaps this script will make it faster and less error prone. was written to help with the following:

  • Create an LVM
  • Extend an LVM
  • Extend the filesystem for an LVM
  • Delete an LVM, VG and PV
  • Identify what drives are free to add to an LVM

As with any program, there are dependencies on the system and naming conventions. Here's what I have identified so far:

  • Install LVM2 software
  • Determining drives (-free) uses /dev/disk/by-id (Debian, others?)
  • LVMs are mounted at /lvm

Here is a handy fragment of SH for your rc.local script. This determines what LVMs exist and mounts them under /lvm.

     for l in `lvdisplay | grep 'LV Name' | sed -e  's/LV Name//'`; do
       d=`basename $l`
       echo "Mounting logical volume group '$l' on '$d'"
       mount -t xfs $l $d

The script does all the sanity checking I could think of to catch errors so you don't trash existing disks. Nonetheless, you should be extremely careful when replying to the prompts. This script is only an assistant and not a tool for the complete novice. Nothing beats actually understanding what's going on.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Details about this program are available from



Specifies the logical volume name (either of an existing LVM or of one to be created). You must specify one LVM name.



Specifies the LVM should be created. You must specify the drives or partitions to be used with the option -drives. This will attempt to create physical volumes on the partitions, create the volume group, create the logical volume and then format the LVM and mount it.


Specifies an existing LVM should be extended with additional drives or partitions. You must specify the drives or partitions to be used with the option -drives. This will attempt to create physical volumes on the new partitions, add to the volume group, resize the logical volume and then extend the filesystem of the LVM.


Specifies an existing LVM which should be deleted. This will attempt to delete the logical volumes, the volume group and physical volumes.


Specifies an existing LVM which should be exported. The volume group is marked as not available.


Specifies an exported volume group which should be imported. You must specify the drives or partitions to be used with the option -drives. The volume group is marked as available.


-drives drive-list

Specifies a set of drives or partitions to be used when creating or adding to an LVM. drive-list provides a convenient way to specify sets of drives and includes any combination of the following:

  • single letter, e.g. b (i.e. /dev/sdb1)
  • 'sd' + single letter, e.g. sdb (i.e. /dev/sdb1)
  • single letter-single letter, e.g. b-d (i.e. /dev/sdb1 /dev/sdc1 /dev/sdd1)
  • '/dev/sd' + single letter, e.g. /dev/sdb (i.e. /dev/sdb1)
  • full partition name e.g. /dev/sdb1

Asks the script to determine what devices (not partitions) are not in use (e.g. not mounted and not part of a volume group). This can sometimes find surprising devices like virtual floppy devices or umounted thumb drives. This list might be candidates for -drives, but you should carefully review the devices.

-size XXX

Specifies the size of the drives in a drives-list. This is one way to allow the script to avoid incorrectly adding drives to a volume group. 'XXX' is simple a string that can be found from the command 'fdisk -l /dev/sdX' and is typically a floating point number like 160.0. This is a very crude check, so don't expect too much. This only works if all drives in drive-list are the same size.

-vg NAME

Specifies the volume group name to use when creating a new logical volume. If the LVM already exists (as with -add, -delete etc) the existing VG name will be used.


Prevents the script from actually issuing destructive commands. This is always a good thing to do if you are not certain what will happen.


If no fatal errors are detected, the program exits with a return code of 0. Any error will set a non-zero return code.


Written by Terry Gliedt <> in 2009. This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; See