Last active
March 28, 2016 19:42
-
-
Save levnovikov/5863ff7662bcb50ddab1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID=112 | |
OLD_IP=192.168.25.20 | |
NEW_IP=192.168.35.20 | |
HOSTNAME=ha-web-01.ged.su | |
mkdir /vz/root/$ID /vz/private/$ID | |
cat /etc/vz/conf/1.conf > /etc/vz/conf/$ID.conf | |
cat >/tmp/exclude.txt | |
/tmp | |
/boot | |
/lib/modules | |
/etc/blkid | |
/etc/mtab | |
/etc/lvm | |
/etc/udev | |
rsync -avz -H -X --one-file-system --numeric-ids --exclude-from=/tmp/exclude.txt -e ssh root@$OLD_IP:/ /vz/private/$ID/ | |
rsync -avz -H -X --one-file-system --numeric-ids --exclude-from=/tmp/exclude.txt -e ssh root@$OLD_IP:/u01/ /vz/private/$ID/u01/ | |
vzctl set $ID --ipdel all --ipadd $NEW_IP --nameserver 192.168.25.98 --save | |
vzctl set $ID --hostname $HOSTNAME --features "nfs:on" --save | |
sed -i -e 's/^[0-9].*getty.*tty/#&/g' /vz/private/$ID/etc/inittab | |
ln -sf /proc/mounts /vz/private/$ID/etc/mtab | |
mv /vz/private/$ID/etc/fstab /vz/private/$ID/etc/fstab.old | |
egrep '/dev/pts|/dev/shm|/proc|/sys' /vz/private/$ID/etc/fstab.old > /vz/private/$ID/etc/fstab | |
mknod --mode 666 /vz/private/$ID/dev/ptmx c 5 2 | |
mkdir /vz/private/$ID/dev/pts | |
/sbin/MAKEDEV -d /vz/private/$ID/dev ttyp ptyp | |
rm -f /vz/private/$ID/dev/null | |
mknod --mode 666 /vz/private/$ID/dev/null c 1 3 | |
mknod --mode 444 /vz/private/$ID/dev/urandom c 1 9 | |
ls -la /vz/private/$ID/ | grep proc | |
mkdir /vz/private/$ID/tmp | |
chmod 1777 /vz/private/$ID/tmp | |
vzctl start $ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment