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:

  • SSH service installed

  • SSH key or login/password remotely allowed (/etc/sshd/sshd_config)

  • Security group set up to connect to an instance

Prepare the OUTSCALE Instance

  1. Create an OUTSCALE instance. For more information, see Creating / Launching Instances.

  2. 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.

  3. Format the /dev/xvdb volume in ext4 format:

    $ mkfs -t ext4 /dev/xvdb
  4. Create the mount point:

    $ mkdir -p /mnt/source
  5. Mount the /dev/xvdb volume:

    $ mount /dev/xvdb /mnt/source

    The volume is mounted.

Perform the Migration

  1. 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.

  2. Install the qemu package and convert your files:

    $ qemu-img convert -f vmdk /mnt/source/convertible.vmdk -O raw /mnt/source/converted.raw
  3. 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:

  • SSH service installed

  • SSH key or login/password remotely allowed (/etc/sshd/sshd_config)

  • Security group set up to connect to an instance

Prepare the AWS Instance

  1. Detach the bootdisk of your source AWS instance.

  2. Create a second AWS instance.

  3. Attach the bootdisk of your source AWS instance to the second AWS instance, as /dev/hdb.

  4. Add a third volume to the second AWS instance, as /dev/hdc.

  5. 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

  1. Create an OUTSCALE instance. For more information, see Creating / Launching Instances.

  2. 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.

  3. Format the /dev/xvdb volume in ext4 format:

    $ mkfs -t ext4 /dev/xvdb
  4. Create the mount point:

    $ mkdir -p /mnt/source
  5. Mount the /dev/xvdb volume:

    $ mount /dev/xvdb /mnt/source

    The volume is mounted.

Perform the Migration

  1. 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.

  2. 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

  1. Create the mount point/target:

    $ mkdir -p /mnt/target
  2. 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
  3. Create the new path:

    $ export PATH=$PATH:/bin:/sbin
  4. Chroot the partition you created:

    $ chroot /mnt/target

Allow root login

Allow the root login only via SSH and a key in /etc/ssh_config.

Configure GRUB

  1. Change the configuration of GRUB (may be in grub2 if this one is applied):

    $ /boot/grub/grub.cfg
  2. Check the GRUB parameters in the /etc/default/grub file.

    1. Check if the volume name is vda instead of sda or hda. If it is not, change it.

    2. Add the following options to your kernel line in GRUB:

      $ GRUB_CMDLINE_LINUX_DEFAULT="elevator=deadline console=tty0 console=ttyS0,38400n8"

      GRUB is modified.

  3. Apply the configuration of GRUB:

    $ grub-mkconfig
  4. Install the newly configured GRUB:

    $ grub-install

Check the last elements

  1. Check if the volume names are aligned in /etc/fstab.

  2. Set up the udev rules package. For more information, see Installing the Packages for Linux Device Names.

  3. If your /etc/rc.local does not contain the SSH key, use the following script to refresh the authorized_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
  4. 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

  1. Check and clean all programs enabled at boot except ssh.

  2. Create a snapshot of your volume. For more information, see Creating a Snapshot of a Volume.
    Your snapshot is created.

  3. 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.

  4. 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.