Wanted to keep this thread updated for the ploop conversion script I wrote. There were some bugs in the old version that were reported. I applied some fixes and more checks. Ploop init also no longer sets a default filesystem, so I made sure that is set to ext4.
Blog post: http://blog.byteonsite.com/?p=10
#!/bin/sh
# ./convert VEID
rsync_options='-aHv'
partition='vz'
if [ ! -e /etc/vz/conf/$1.conf ]; then
echo "Virtual server configuration file: /etc/vz/conf/$1.conf does not exist."
exit 1
fi
if [ -d /$partition/private/$1/root.hdd ]; then
echo "Server already has ploop device"
exit 1
fi
if [ ! -d /$partition/private/$1 ]; then
echo "Server does not exist"
exit 1
fi
# Get disk space in G of current VPS
disk=`vzctl exec $1 df -BG | grep simfs | head -n1 | awk {'print $2'}`
if [ ! $disk ]; then
echo "Could not retrieve disk space figure. Is VPS running?"
exit 1
fi
# Create and mount file system
mkdir -p /$partition/private/1000$1/root.hdd
if [ ! -d /$partition/private/1000$1/root.hdd ]; then
echo "Unable to create temporary VE_PRIVATE"
exit 1
fi
if ! ploop init -s $disk -t ext4 /$partition/private/1000$1/root.hdd/root.hdd ; then
echo "Unable to create ploop device. Make sure diskspace is set on VPS."
exit 1
fi
cp /etc/vz/conf/$1.conf /etc/vz/conf/1000$1.conf
if ! vzctl mount 1000$1 ; then
echo "Unable to mount ploop device";
exit 1;
fi
# Rsync over files (sync 1)
rsync $rsync_options /$partition/root/$1/. /$partition/root/1000$1/
# Stop primary, mount, sync final
vzctl stop $1
vzctl mount $1
rsync $rsync_options /$partition/root/$1/. /$partition/root/1000$1/
vzctl umount $1
vzctl umount 1000$1
mv /$partition/private/$1 /$partition/private/$1.backup
mv /$partition/private/1000$1 /$partition/private/$1
vzctl start $1
# Cleanup
rm -f /etc/vz/conf/1000$1.conf
rmdir /vz/root/1000$1
# Verification
verify=`vzlist -H -o status $1`
if [ `vzlist -H -o status $1` = "running" ]; then
echo "Virtual server conversion successful. Verify manually then run: rm -Rf /$partition/private/$1.backup to remove backup."
else
echo "Server conversion was not successful..Reverting.."
mv -f /$partition/private/$1 /$partition/private/$1.fail
mv /$partition/private/$1.backup /$partition/private/$1
vzctl start $1
fi