LVM2 defragmenter


   1. Purpose
   2. Copying
   3. Requirements
   4. Howto
   5. Limitations
   6. Downloading

1. Purpose

LVM2 Defrag defragments or rearranges a LVM2 volume group using pvmove.

2. Copying

lvm2defrag has been written by Joel Yliluoma and other contributors,
and is distributed under the terms of the General Public License version 3 (GPL3).

3. Requirements

This software is currently written in PHP. The PHP commandline program is required to execute.

4. Howto

Here's how.

Step 1. Dump existing layout

# vgcfgbackup
# cp /etc/lvm/backup/YOURVOLUMEGROUPNAME data.txt
$ php -q dump.php > dump.txt

Step 2. Plan your desired layout

$ cp dump.txt rearrange.txt
$ editor rearrange.txt
In this file, you will move around the partitions between disks into the order you wish they to be in. Be careful to maintain the right amount of disk space on each partition (the sum of numbers must match what they were before). If you fail to maintain those numbers, the next command will warn you, so it is not fatal.

Step 3. Create the sequence of commands to move data around

$ php -q rearrange.php > commands.sh
Now verify the produced file, commands.sh, and edit if you like to. If there are error messages in the file, you may need to resolve them.

Step 4. Execute the commands

# chmod +x commands.sh
./commands.sh
And wait.

Note that the operation may be interrupted (and resumed) at any time. The LVM2 volume group will never be left in a broken state (this is guaranteed by how pvmove works).

5. Limitations

  • This software is provided as-is, from an expert to experts. Do not use it if you think you cannot understand the instructions above.
  • This software does not abide by many usability principles. Apologies. Such work however may be contributed by sending a patch to the author. :)
  • This software cannot probably handle crypted volumes (no experience) or anything other beyond the basic capabilities of LVM2. Apologies.

6. Downloading

Downloading help

  • Do not download everything - you only need one file (newest version for your platform)!
  • Do not use download accelerators or you will be banned from this server before your download is complete!

The most recent source code (bleeding edge) for lvm2defrag can also be downloaded by cloning the Git repository by:

Date (Y-md-Hi) acc        Size Name                
2011-1007-2132 r--       10993 lvm2defrag-0.9.4.tar.bz2
2011-1007-2132 r--       10911 lvm2defrag-0.9.4.tar.gz
2011-0728-1104 r--       10995 lvm2defrag-0.9.3.tar.bz2
2011-0728-1104 r--       10898 lvm2defrag-0.9.3.tar.gz
2011-0718-1126 r--       10935 lvm2defrag-0.9.2.tar.bz2
2011-0718-1126 r--       10849 lvm2defrag-0.9.2.tar.gz
2010-0225-1048 r--       10905 lvm2defrag-0.9.1.tar.bz2
2010-0225-1048 r--       10825 lvm2defrag-0.9.1.tar.gz
2008-0103-1222 r--       10127 lvm2defrag-0.9.0.tar.bz2
2008-0103-1222 r--       10193 lvm2defrag-0.9.0.tar.gz
Back to the source directory index at Bisqwit's homepage