Back to Cloud VPS Documentation

    Migrate from AWS EC2 to RamNode

    A comprehensive guide to exporting your AWS workloads and deploying them on RamNode's cloud infrastructure.

    Introduction

    Migrating from AWS to RamNode can provide significant cost savings while maintaining performance and reliability. This guide walks you through the complete process of exporting an EC2 instance, converting it to a compatible format, and deploying it on RamNode's cloud platform.

    RamNode supports multiple image formats including RAW, QCOW2, VMDK, VDI, and VHD/VHDX, making migration from virtually any hypervisor straightforward.

    Prerequisites

    • An active RamNode Cloud account (sign up at cloudorder.ramnode.com)
    • AWS CLI configured with appropriate IAM permissions
    • An S3 bucket for storing exported images
    • A local Linux workstation with qemu-img installed (for image conversion)
    • Sufficient disk space for the exported image (at least 2x the instance's disk size)
    • SSH access to your EC2 instance for pre-migration preparation

    Required IAM Permissions

    Your AWS IAM user or role needs the following permissions for the VM Export feature:

    • ec2:CreateInstanceExportTask
    • ec2:DescribeExportTasks
    • ec2:CancelExportTask
    • s3:PutObject
    • s3:GetBucketLocation

    Additionally, you'll need to create a service role that allows AWS to write to your S3 bucket. See the AWS documentation for creating the vmimport service role.

    1Prepare Your EC2 Instance for Export

    Before exporting, you should prepare your instance to ensure a clean migration. This involves generalizing the system and ensuring compatibility with RamNode's infrastructure.

    Install Required Drivers

    RamNode's cloud platform uses virtio drivers for optimal performance. Most modern Linux distributions include these by default, but you should verify they're available:

    lsmod | grep virtio

    If virtio modules aren't loaded, install them:

    Ubuntu/Debian:

    sudo apt update && sudo apt install linux-modules-extra-$(uname -r)

    CentOS/Rocky/AlmaLinux:

    sudo yum install kernel-modules

    Install and Configure cloud-init

    cloud-init enables RamNode's platform to inject SSH keys, configure networking, and apply user data during instance boot.

    Ubuntu/Debian:

    sudo apt update && sudo apt install cloud-init

    CentOS/Rocky/AlmaLinux:

    sudo yum install cloud-init

    Configure cloud-init to enable DHCP networking by editing /etc/cloud/cloud.cfg.d/99-ramnode.cfg:

    network: {config: disabled}

    Generalize the Instance

    Remove instance-specific configuration to ensure the image works properly when deployed:

    sudo cloud-init clean --logs
    sudo rm -rf /var/lib/cloud/instances/*
    sudo rm -f /etc/ssh/ssh_host_*
    sudo rm -f /etc/machine-id && sudo touch /etc/machine-id

    Important: After running these commands, the instance may behave unexpectedly on reboot. Only run these immediately before creating your export.

    2Export the EC2 Instance

    AWS provides the VM Export feature to create disk images from running or stopped instances. The export process creates a VMDK file stored in your S3 bucket.

    Stop the Instance

    For a consistent export, stop the instance first:

    aws ec2 stop-instances --instance-ids i-1234567890abcdef0

    Wait for the instance to fully stop:

    aws ec2 wait instance-stopped --instance-ids i-1234567890abcdef0

    Create the Export Task

    Create an export task specifying your S3 bucket and the desired output format:

    aws ec2 create-instance-export-task \
      --instance-id i-1234567890abcdef0 \
      --target-environment vmware \
      --export-to-s3-task file-format=vmdk,s3-bucket=your-bucket-name,s3-prefix=exports/

    This command returns an export task ID. Record this for monitoring progress.

    Monitor Export Progress

    Check the status of your export task:

    aws ec2 describe-export-tasks --export-task-ids export-i-1234567890abcdef0

    The export may take 30 minutes to several hours depending on the instance size. The task status will change from 'active' to 'completed' when finished.

    Note: AWS charges for the S3 storage used by the exported image. Delete the image from S3 after successfully uploading to RamNode to avoid ongoing storage costs.

    3Convert the Image to QCOW2

    While RamNode accepts VMDK files directly, converting to QCOW2 format offers several advantages: better compression, copy-on-write efficiency, and native support in RamNode's KVM-based infrastructure.

    Download the Exported Image

    First, download the VMDK from your S3 bucket:

    aws s3 cp s3://your-bucket-name/exports/export-i-1234567890abcdef0.vmdk ./

    Install qemu-img

    Install the QEMU utilities if not already present:

    Ubuntu/Debian:

    sudo apt update && sudo apt install qemu-utils

    CentOS/Rocky/AlmaLinux:

    sudo yum install qemu-img

    macOS (with Homebrew):

    brew install qemu

    Convert VMDK to QCOW2

    Convert the image with compression enabled:

    qemu-img convert -f vmdk -O qcow2 -c export-i-1234567890abcdef0.vmdk ramnode-image.qcow2

    The -c flag enables compression, which significantly reduces file size and upload time.

    Verify the Converted Image

    Check the image information to ensure conversion succeeded:

    qemu-img info ramnode-image.qcow2

    The output shows the virtual size, actual disk usage, and format. Note the virtual size—you'll need this when creating your RamNode instance.

    RamNode Supported Image Formats

    FormatDescriptionBest For
    QCOW2QEMU Copy-On-WriteRecommended - best efficiency
    RAWUncompressed disk imageMaximum compatibility
    VMDKVMware virtual diskDirect AWS exports
    VDIVirtualBox disk imageVirtualBox migrations
    VHD/VHDXMicrosoft Hyper-V formatAzure/Hyper-V migrations

    4Upload to RamNode Cloud

    With your image prepared, you can now upload it to RamNode's cloud platform.

    Upload via Cloud Control Panel

    For images under 2GB, use the web interface:

    1. Log into the RamNode Cloud Control Panel at cloud.ramnode.com
    2. Navigate to Compute → Images
    3. Click Create Image
    4. Select File as the source
    5. Choose your QCOW2 file
    6. Configure image details:
      • Name: Descriptive name (e.g., 'Ubuntu-22.04-WebServer-Migration')
      • Format: QCOW2
      • Minimum Disk: Virtual size from qemu-img info
      • Minimum RAM: Based on your application requirements
    7. Click Create Image and wait for upload to complete

    Upload Large Images (Over 2GB)

    For images larger than 2GB, the web upload may be unreliable. Contact RamNode support to arrange alternative upload methods:

    • Direct server upload via SCP/SFTP: RamNode provides temporary credentials to upload directly
    • Import from URL: Host your image temporarily and provide the URL
    • S3-compatible storage import: Upload to S3 or compatible storage and provide access

    Tip: Keep your original AWS export in S3 until you've verified the migration is successful. This allows you to retry the process if needed.

    5Deploy Your Instance on RamNode

    Once your image is uploaded and shows as 'Active' in the Images list, you can launch instances from it.

    Launch an Instance

    1. In the Cloud Control Panel, navigate to Compute → Instances
    2. Click Launch Instance
    3. Configure the instance:
      • Name: Your instance hostname
      • Source: Select your uploaded image
      • Flavor: Choose appropriate CPU/RAM/disk
      • Network: Select your network configuration
      • Security Groups: Configure firewall rules
      • Key Pair: Select or create SSH key
    4. Review configuration and click Launch
    5. Wait for the instance to become active (typically 1-2 minutes)

    Initial Connection and Verification

    Connect to your new instance via SSH:

    ssh -i your-key.pem user@your-instance-ip

    Verify the system is functioning correctly:

    # Check system information
    uname -a
    cat /etc/os-release
    
    # Verify networking
    ip addr show
    ping -c 3 google.com
    
    # Check disk space
    df -h
    
    # Verify services are running
    systemctl status

    Troubleshooting Common Issues

    Instance Won't Boot

    If your instance fails to boot, check the VNC console in the Cloud Control Panel for error messages. Common causes include:

    • Missing virtio drivers: Rebuild the image with virtio support enabled
    • Bootloader issues: Ensure GRUB is properly configured for the new environment
    • Corrupted image: Re-download from S3 and reconvert
    • Insufficient resources: Ensure the instance flavor meets minimum requirements

    Network Not Working

    If the instance boots but has no network connectivity:

    • Check cloud-init: Verify cloud-init networking is enabled and functioning
    • DHCP configuration: Ensure the primary interface is configured for DHCP
    • Interface naming: Modern Linux may rename interfaces; check for eth0 vs ens3 mismatches
    • Security groups: Verify firewall rules allow your traffic

    SSH Connection Refused

    If you can't SSH into the instance:

    • SSH keys: Verify cloud-init injected your SSH key correctly
    • SSH service: Use VNC console to check if sshd is running
    • User account: Confirm the correct username for your OS (ubuntu, centos, root, etc.)
    • Host keys: If host keys were removed during generalization, they should regenerate on boot

    Need Help? Contact RamNode support if you encounter issues with image uploads or boot problems. The support team can assist with large uploads and troubleshooting.

    Post-Migration Tasks

    After successfully migrating and verifying your instance, complete these final tasks:

    Update DNS Records

    Point your domain names to the new RamNode IP address. Consider using a short TTL initially to facilitate quick rollback if needed.

    Configure Backups

    Set up backup procedures using RamNode's snapshot functionality accessible from the instance details page.

    Update Monitoring

    Update external monitoring services with the new IP addresses. Reconfigure any cloud-specific integrations tied to AWS.

    Clean Up AWS Resources

    After verifying the migration is stable (wait at least one week), terminate the EC2 instance, delete exported images from S3, and release unused Elastic IPs.

    Conclusion

    Migrating from AWS to RamNode is a straightforward process once you understand the export and conversion workflow. By following this guide, you've successfully transferred your workload to RamNode's infrastructure while maintaining all your application data and configurations.

    RamNode's competitive pricing and flexible infrastructure make it an excellent choice for developers and businesses looking to optimize their cloud spending without sacrificing performance or reliability.