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

4 minute read
0

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

Step 1: Determine compatibility of your application source code and libraries

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

Use the Porting Advisor for Graviton command line tool to verify the compatibility of the application source code and application. For more information, see Announcing Porting Advisor for Graviton.

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. AMIs are specific to the architecture of the processor.

Step 2: Copy data to your new instance

Online method

The Porting Advisor for Graviton migrates your software. However, you must manually copy your data to the new 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 any secondary volumes from current instances to Graviton-based instances.

Note: It's a best practice to take a snapshot of your volumes before completing these steps.

1.    Launch an Arm64-based instance.

2.    Install the necessary packages and application dependencies. Then, configure the new instance the same as the source (x86) instance. The new instance must be configured the same as the source instance to run your applications smoothly.

3.    Migrate your data from the x86 instance to the Graviton instance. Sync any required application data to the new instance.

Note: Don't sync the operating system files and binaries as part of this step.

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

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 preserve existing files in the remote destination directory and transfer only new or modified files, use the**--update** or -u flag.

4.    Start the application and confirm that it performs as expected.

Offline method

Note: You can copy application and other data. You must install the required binaries and dependencies on the new Graviton-based instance.

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.

Note: To see a list of available Arm640based AMIs, Run the following AWS Command Line Interface (AWS CLI) command:

$ aws ec2 describe-images --owners self amazon --filters "Name=architecture,Values=arm64" --query 'Images[*].[Name]' --output text

If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.

4.    Use SSH to connect to the Arm64-based instance.

5.    Run the following command to mount the root volume of the x86 instance. In the following example command, change vol_label to your device name. Run the lsblk command to retrieve the device name, if needed.

sudo mount /dev/vol_label /mnt --- vol_label

6.    Copy data between the secondary volume and root volume of the Arm64-based instance. To copy data, use the disk management or migration tool of your preference, such as rsync. For more information on rsync, see rsync on the linux.die.net website.

sudo rsync -avR /source_path /destination_path

7.    Run the following command to unmount the secondary volume:

sudo umount /mnt

8. Detach the secondary volume from the instance.

Related information

Getting started with Graviton

Operating systems available for Graviton-based instances

AWS OFFICIAL
AWS OFFICIALUpdated a year 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 8 months ago

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

profile pictureAWS
MODERATOR
replied 8 months ago