Moving OpenVZ to a Different Drive

Just a quick simple wizard of moving OpenVZ to another drive, since its stored in the plain folder of /vz

I presume you’ve already partitioned and formatted your drive (ext3 or ext4 works best), so we need to mount your new drive.

mkdir /vznew
mount /dev/<DRIVE IDENTIFIER HERE> /vznew (find identifier via fdisk
-l)

Now we need to turn off your OpenVZ VPSs and move the data, including -p to reserve permissions.

service vz stop
cp -Rvp /vz/* /vznew/

Now we need to disable the old /vz folder and mount the new one as /vz

mv /vz /vzold
umount /vznew
mkdir /vz 
mount /dev/<DRIVE IDENTIFIER HERE> /vz
service vz start

There you go, that should start all your OpenVZ VPSs from the new drive, you’re also need to tell the OS that you want it to mount that drive as /vz every time you boot.

You’re need to edit /etc/fstab and add this line,  remember to change the drive on the first part, and if your using a different drive format, change that too (ext3 etc)

/dev/sdc1        /vz                ext3    defaults        1 1

So you should end up something similar to

LABEL=/                 /                ext3    defaults        1 1
tmpfs                   /dev/shm         tmpfs   defaults        0 0
devpts                  /dev/pts         devpts  gid=5,mode=620  0 0
sysfs                   /sys             sysfs   defaults        0 0
proc                    /proc            proc    defaults        0 0
LABEL=SWAP-sda2         swap             swap    defaults        0 0
/dev/sdc1               /vz    	         ext3    defaults        1 1
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>