This is a fast solution that should never be performed for a production environment.
In this tutorial, a source virtual machine will be migrated by copying all files to the destination virtual machine.
The following will be accomplished:
- Setup SSH on destination instance to allow root access.
screento ensure uninterrupted copying.
- Copy all necessary files from source to destination instance.
Perform the following:
- Create a new instance with the same OS as the source's instance
- SSH into the destination instance
- Edit SSH configuration to allow root login
sudo vim /etc/ssh/sshd_config
PermitRootLogin and remove the
# character, or for short perform this:
/Permit [Enter] [i] [Remove hash]
- Restart SSH service
# Redhat sudo service ssh restart # Debian sudu service sshd restart
- Set a password for root user
sudo passwd root
You will be prompted to enter password twice.
- SSH to destination instance with root credentials in another terminal to make sure you have root access
SSH to your source instance
Create a new file called
excludes.confwith the following contents:
/boot /proc /sys /tmp /dev /var/lock /etc/fstab /etc/mtab /etc/resolv.conf /etc/conf.d/net /etc/network/interfaces /etc/networks /etc/sysconfig/network* /etc/sysconfig/hwconf /etc/sysconfig/ip6tables-config /etc/sysconfig/kernel /etc/hostname /etc/HOSTNAME /etc/hosts /etc/modprobe* /etc/modules /net /lib/modules /etc/rc.conf /usr/share/nova-agent* /usr/sbin/nova-agent* /etc/init.d/nova-agent*
Add all other folders that you do not wish to migrate such as log files.
screento be able to continue with the migration process should your SSH connection fail
# Redhat sudo yum install screen -y # Debian sudu apt-get install screen
- Start the migration process
screen sudo rsync -azPx --exclude-from="excludes.conf" / root@<ip-address>
Restart destination instance.
Remove the SSH key used for the destination's VM as it now uses the source's VM SSH credentials.
ssh-keygen -R <ip-address>
- SSH again to destination instance.
All should be working fine.