Migrating a Linux Instance to the OUTSCALE Cloud
You can migrate a Linux instance from VMWare, VirtualBox or Amazon Web Services (AWS) to an OUTSCALE Linux instance. For more information about OUTSCALE instances, see About Instances.
The following procedures are generic instructions that you can follow depending on your situation. You may need to adjust them according to your needs.
Migrate the Instance from VMWare or VirtualBox
Before you begin: Make sure you have:
|
Prepare the OUTSCALE Instance
-
Create an OUTSCALE instance. For more information, see Creating / Launching Instances.
-
Attach two volumes to this instance, as /dev/xvdb and /dev/xvdc. For more information, see Attaching a Volume to an Instance.
You can speed up the copy by using an
io1
volume. -
Format the /dev/xvdb volume in ext4 format:
$ mkfs -t ext4 /dev/xvdb
-
Create the mount point:
$ mkdir -p /mnt/source
-
Mount the /dev/xvdb volume:
$ mount /dev/xvdb /mnt/source
The volume is mounted.
Perform the Migration
-
Copy the main volume of your non-OUTSCALE instance to the volume of your OUTSCALE instance using the following command:
$ scp -i keypair.rsa convertible.vmdk user@outscale_ip:/mnt/source
The name of the default user depends on the OMI used:
-
outscale
for Ubuntu 18 and Centos 7 OMIs released since 20 December 2018 -
ubuntu
for older Ubuntu OMIs -
centos
for older Centos 7 OMIs and Centos 6 OMIs
The volume is copied.
-
-
Install the qemu package and convert your files:
$ qemu-img convert -f vmdk /mnt/source/convertible.vmdk -O raw /mnt/source/converted.raw
-
Copy your files to the target partition (the /dev/xvdc disk) bit by bit:
$ dd if=/root/converted.raw of=/dev/xvdc bs=16k status=progress
The files of your non-OUTSCALE instance are migrated to the OUTSCALE instance.
Migrate the Instance from AWS
Before you begin: Make sure you have:
|
Prepare the AWS Instance
-
Detach the bootdisk of your source AWS instance.
-
Create a second AWS instance.
-
Attach the bootdisk of your source AWS instance to the second AWS instance, as /dev/hdb.
-
Add a third volume to the second AWS instance, as /dev/hdc.
-
Compress the /dev/hdb volume into a zip file on /dev/hdc, using the following commands:
$ sudo chown -r ec2-user:root /mnt $ sudo mkfs -t ext4 /dev/hdc $ sudo mount /dev/hdc $ sudo dd if=/dev/hdb | gzip -c > /mnt/aws.raw
The volume is compressed into a zip file.
Prepare the OUTSCALE Instance
-
Create an OUTSCALE instance. For more information, see Creating / Launching Instances.
-
Attach two volumes to this instance, as /dev/xvdb and /dev/xvdc. For more information, see Attaching a Volume to an Instance.
You can speed up the copy by using an
io1
volume. -
Format the /dev/xvdb volume in ext4 format:
$ mkfs -t ext4 /dev/xvdb
-
Create the mount point:
$ mkdir -p /mnt/source
-
Mount the /dev/xvdb volume:
$ mount /dev/xvdb /mnt/source
The volume is mounted.
Perform the Migration
-
Copy the aws.raw file from the second AWS instance to the OUTSCALE instance:
$ scp -i keypair.rsa aws.raw user@outscale_ip:/mnt/source
The name of the default user depends on the OMI used:
-
outscale
for Ubuntu 18 and Centos 7 OMIs released since 20 December 2018 -
ubuntu
for older Ubuntu OMIs -
centos
for older Centos 7 OMIs and Centos 6 OMIs
The file is copied.
-
-
Decompress the data:
$ gunzip -c /mnt/source/aws.raw > /dev/xvdc
The files of your AWS instance are migrated to the OUTSCALE instance.
Configure the Migrated Instance
Chroot the partition
-
Create the mount point/target:
$ mkdir -p /mnt/target
-
Type the following commands to mount the different mandatory files, where X is the number of the partition containing the operating system:
$ mount /dev/xvdcX /mnt/target $ mount --rbind /dev /mnt/target/dev $ mount -t proc /proc /mnt/target/proc $ mount --rbind /sys /mnt/target/sys
-
Create the new path:
$ export PATH=$PATH:/bin:/sbin
-
Chroot the partition you created:
$ chroot /mnt/target
Configure GRUB
-
Change the configuration of GRUB (may be in grub2 if this one is applied):
$ /boot/grub/grub.cfg
-
Check the GRUB parameters in the
/etc/default/grub
file.-
Check if the volume name is vda instead of sda or hda. If it is not, change it.
-
Add the following options to your kernel line in GRUB:
$ GRUB_CMDLINE_LINUX_DEFAULT="elevator=deadline console=tty0 console=ttyS0,38400n8"
GRUB is modified.
-
-
Apply the configuration of GRUB:
$ grub-mkconfig
-
Install the newly configured GRUB:
$ grub-install
Check the last elements
-
Check if the volume names are aligned in
/etc/fstab
. -
Set up the udev rules package. For more information, see Installing the Packages for Linux Device Names.
-
If your
/etc/rc.local
does not contain the SSH key, use the following script to refresh theauthorized_keys
file:$ sed -i '/^exit 0/d' /etc/rc.local cat >> /etc/rc.local <<EOF /bin/mkdir -p /root/.ssh #LINE_TO_STRIP wget http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key -O - > /root/.ssh/authorized_keys /bin/chmod 700 /root/.ssh -R wget http://169.254.169.254/latest/meta-data/local-hostname -O - | cut -d '.' -f 1 > /etc/hostname; #LINE_TO_STRIP hostname -F /etc/hostname #LINE_TO_STRIP sed -i '/^.*LINE_TO_STRIP.*$/d' /etc/rc.local; #LINE_TO_STRIP EOF
-
Clean up the sensitive elements of your instance. For more information, see Linux Instances Clean-up to Create OMIs.
You can verify the clean-up with either
yum -y clean all`or`apt-get -y clean all
.
Start the Instance
-
Check and clean all programs enabled at boot except
ssh
. -
Create a snapshot of your volume. For more information, see Creating a Snapshot of a Volume.
Your snapshot is created. -
Create an OUTSCALE machine image (OMI) from the snapshot you created. For more information, see Creating an OMI from a Snapshot.
The OMI is created. -
Launch an instance from the OMI you created. For more information, see Creating / Launching Instances.
Related Pages
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.