How do I migrate my Amazon EC2 Linux instance to a Graviton-based instance type?

4 minute read
2

I want to migrate my Amazon Elastic Compute Cloud (Amazon EC2) instance to an AWS Graviton based instance type.

Short description

To migrate to an AWS Graviton based instance, complete the following steps:

  1. Determine the compatibility of your application source code and libraries with AWS Graviton based instances.
  2. Use the online or offline method to copy your data to the new instance.

For a detailed migration strategy, see AWS Graviton fast start.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Determine compatibility of your application source code and libraries

Analyze your current workload requirements to determine whether the AWS Graviton based instance can support them.

To verify the compatibility of the application source code and application, use the Porting Advisor for Graviton on the GitHub website.

Select an instance type with the same processor architecture as the current instance type. Instances that use a processor architecture other than ARM64 can't be upgraded in place. Amazon Machine Images (AMIs) are specific to the processor's architecture.

Copy data to your new instance

Online method

The Porting Advisor for Graviton provides guidance about how to migrate your software. However, you must still run tests to make sure that the migrated software runs on the Graviton instance. After you migrate the code, you must manually copy your data to the new Graviton instance.

AWS Graviton based instances created with an ARM64-based AMI must have an ARM64-based Amazon Elastic Block Store (Amazon EBS) root volume. You can automatically generate this root volume at launch.

If the instance supports the file system type, then you can mount secondary volumes even if they're built with or use the x86_64 architecture. Attach the root volume of your current instances as secondary volumes, mount them, and then copy the data to Graviton root volumes. You can attach secondary volumes from current instances to Graviton-based instances.

Important: It's a best practice to take a snapshot of your volumes before you complete the following steps.

To copy data to your instance, complete the following steps:

  1. Launch an ARM64-based instance.
  2. Install the necessary packages and application dependencies.
  3. Configure the new instance the same as the source (x86) instance. You must configure the new instance the same as the source instance to run your applications smoothly.
  4. To migrate your data from the x86 instance to the Graviton instance and sync application data to the new instance, run the following command:
    sudo rsync -avR -e "ssh -i key.pem" /source_path/AppData ec2-user@ec2_dns_name.amazonaws.com:/destination_path
    -a, --archive archive mode
    -R, --relative use relative path names
    -v, --verbose increase verbosity
    Note: Don't sync the operating system (OS) files and binaries as part of this step. The preceding command overwrites existing files in the remote destination directory that have the same name as the files in the local source directory. To keep existing files in the remote destination directory and transfer only new or modified files, use the --update or -u flag.
  5. Start the application, and then verify that it performs as expected.

Offline method

Note: You must install the required binaries and dependencies on the new Graviton-based instance.

To copy data to your instance, complete the following steps:

  1. Stop the x86 based instance.

  2. Launch a new instance from an ARM64-based AMI in the same Availability Zone.

  3. Attach the root volume of the x86-based instance as a secondary device (/dev/sdf) to the ARM64-based instance.
    To see a list of available ARM64-based AMIs, run the following describe-images AWS CLI command:

    $ aws ec2 describe-images --owners self amazon --filters "Name=architecture,Values=arm64" --query 'Images[*].[Name]' --output text
  4. Use SSH to connect to the ARM64-based instance.

  5. Run the following command to mount the root volume of the x86 instance:

    sudo mount /dev/vol_label /mnt

    Note: Replace vol_label with your device name. If needed, then run the lsblk command to retrieve the device name.

  6. Copy data between the secondary volume and root volume of the ARM64-based instance. To copy data, use a disk management or migration tool such as rsync. Example:

    sudo rsync -avR /source_path /destination_path

    Note: For more information about rsync, see rsync(1) - Linux man page on the die.net website.

  7. To unmount the secondary volume, run the following command:

    sudo umount /mnt
  8. Detach the secondary volume from the instance.

Related information

Getting started with Graviton

Operating systems available for Graviton based instances on the GitHub website

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago
2 Comments

Are all instance type supported for Graviton 2 / Graviton 3 migrations . How do we get to know about elgible instances for migration

replied 2 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 2 years ago