MigrazioneOpenVZ

Da Helpedia.

Indice

Creare una immagine del disco

Creazione del file immagine

dd if=/dev/zero of=XenGuest1.img bs=1024k seek=6144 count=0
mkfs -t ext3 XenGuest1.img 
mkdir /tmp/loop
mount -o loop XenGuest1.img /tmp/loop

copia da disco fisico a immagine

cp -ax /vz/private/104/{bin,dev,etc,lib,root,sbin,usr,var,home,opt} /tmp/loop

creazione directory mancanti

mkdir /tmp/loop/{proc,sys,tmp}
chmod 777 /tmp/loop/tmp

Inserimento moduli kernel

scp -pr 109.232.88.14:/lib/modules/* /tmp/loop/lib/modules/

Inserimento boot

scp -pr 109.232.88.14:/boot /tmp/loop

Modificare /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
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

smontaggio e copia

umount del file

umount /tmp/loop/

copia

cd /tmp
wget http://www.xen.org/files/xva/xva.py
chmod 775 xva.py

lancio

./xva.py --is-pv -d /storage/XenGuest1.img -s IP --username=xxx --password=yyy

Method 2

- Duplicazione dello storage del server target - Mount Storage

mount /dev/xvdb2 /mnt/

- salvataggio di ciò che serve

cd /mnt
mkdir -p saveme/modules
mv etc/fstab saveme/
mv lib/modules/* saveme/modules/

- rsync dei dati

rsync -vazx --delete -n --safe-links --exclude="/lib/modules/" --exclude="/etc/udev/" /bin /etc /lib /root /sbin /usr /var /home /opt 109.232.88.14:/mnt/

- ripristino dei moduli kernel

cp -ax /etc/fstab /mnt/etc
cp -ax /etc/inittab /mnt/etc/inittab
cp -ax /etc/securetty /mnt/etc/securetty

oppure (potrebbe servire anche #cp -ax /lib/modules/* /mnt/lib/modules/)

mv /mnt/saveme/fstab /mnt/etc/fstab
mv /mnt/saveme/modules/* /mnt/lib/modules/

- schede di rete

cp -ax /etc/sysconfig/network-scripts/ifcfg-eth* /mnt/etc/sysconfig/network-scripts/

correggere i mac

Troubleshooting

If you have an error like this in dmesg

Starting udev: cp: cannot create special file `/dev/console': File exists
cp: cannot create special file `/dev/core': File exists
cp: cannot create special file `/dev/null': File exists
cp: cannot create special file `/dev/tty': File exists
cp: cannot create special file `/dev/zero': File exists

then remove /etc/udev/devices directory because udev can find all devices.


some useful rsync for qmail

rsync -vazx --delete --safe-links --exclude="/lib/modules/" --exclude="/etc/udev/" --exclude="/var/qmail/spam/*" /bin /etc /lib /root /sbin /usr /var /home /opt /command /package /service 109.232.88.0:/mnt/


method 3

Server virtuale identico come sistema operativo.

rsync -azv -e ssh -safe-links --exclude=/etc/inittab --exclude=/etc/securetty --exclude=/etc/udev/devices --exclude=/etc/fstab --exclude=/boot --exclude=/proc --exclude=/lib/modules/ --exclude=/sys --exclude=/etc/grub.conf --exclude=/etc/sysconfig/networking --exclude=/etc/sysconfig/network-scripts --exclude="/etc/udev/" root@oldserverip:/ /
Strumenti personali
Namespace
Varianti
Azioni
Navigazione
Strumenti