Add lvm2defrag.sh (easy-mode).
This commit is contained in:
parent
4aa7aa2f0a
commit
5e1d64167f
12
README.rst
12
README.rst
|
@ -21,6 +21,18 @@ This software is currently written in PHP. The PHP commandline program is requir
|
|||
|
||||
Here's how.
|
||||
|
||||
Easy-mode
|
||||
^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
# ./lvm2defrag.sh YOURVOLUMEGROUPNAME
|
||||
# ./commands.sh
|
||||
|
||||
Execute the following commands, Your favorite editor should open, move around your partitions between disks into the order you wish they to be in. Save and exit.
|
||||
You should now have commands.sh which contain all commands you need to process.
|
||||
If something goes wrong, you should probably prefer the manual methode.
|
||||
|
||||
Step 1. Dump existing layout
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
echo "Usage: $0 vgname"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $UID -ne 0 ]
|
||||
then
|
||||
echo "This program need to be run as root."
|
||||
exit
|
||||
fi
|
||||
|
||||
type php &>/dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "This script need php."
|
||||
exit
|
||||
fi
|
||||
|
||||
function fail ()
|
||||
{
|
||||
echo "An error occurs, fix it and try again."
|
||||
exit
|
||||
}
|
||||
vgname=$1
|
||||
vgcfgbackup $vgname || fail
|
||||
cp -f /etc/lvm/backup/$vgname data.txt || fail
|
||||
php -q dump.php > dump.txt || fail
|
||||
cp -f dump.txt rearrange.txt || fail
|
||||
editor rearrange.txt
|
||||
php -q rearrange.php > commands.sh || fail
|
||||
warnline=$(grep -cvE '^(echo|pvmove|#)' commands.sh)
|
||||
if [ $warnline -ne 0 ] ; then
|
||||
echo "Warning or error present in commands.sh, fix them."
|
||||
grep -cvE '^(echo|pvmove|#)' commands.sh
|
||||
exit
|
||||
fi
|
||||
chmod +x commands.sh
|
||||
|
||||
echo "All good, now you just have to execute ./commands.sh"
|
||||
|
||||
|
Loading…
Reference in New Issue