Skip to content

How do I copy data from an encrypted Amazon EBS volume to an unencrypted volume in Linux?

5 minute read
1

I want to copy data from an encrypted Amazon Elastic Block Store (Amazon EBS) volume to an unencrypted volume in Linux. I encrypted the volume with a default or custom AWS Key Management Service (AWS KMS) key.

Short description

Important: Before you begin, create a snapshot of your encrypted volume. Or, create an Amazon Machine Image (AMI) of your Amazon Elastic Compute Cloud (Amazon EC2) instance with the encrypted volume. The snapshot or AMI protects your data before you perform major operations.

You can't directly remove encryption from an encrypted Amazon EBS volume or snapshot. A volume restored from an encrypted snapshot is always encrypted. To move data from an encrypted volume to an unencrypted volume, you must copy the data to a new unencrypted volume.

Note: The following resolution uses a root volume as an example. These steps also apply to secondary volumes.

Resolution

Create and attach an unencrypted volume

To create a new unencrypted volume and attach it to a rescue instance, complete the following steps:

  1. Launch a rescue instance in the same Availability Zone as the original instance.
    Note: Use an operating system (OS) that's similar to the one that launched the original instance.
  2. Create a new unencrypted volume in the same Availability Zone as the original encrypted volume.
  3. Open the Amazon EC2 console.
  4. In the navigation pane, choose Volumes.
  5. Select your new unencrypted volume, choose Actions, and then choose Attach volume.
  6. For Instance, select your rescue instance.
  7. For Device name, select an available device name from the Recommended data volumes section, and then choose Attach volume.

Verify the unencrypted volume

To verify that your OS detected the unencrypted volume, complete the following steps:

  1. Connect to your rescue instance.
  2. To list available block devices, run the following command:
    lsblk -o NAME,SERIAL
    Note: Device names can appear differently based on your instance type. For example, Xen-based instances use /dev/xvd, and Nitro-based instances use /dev/nvme.
    Example output for a Nitro-based instance:
    NAME          SERIAL
    nvme0n1       vol0XXXXXXXX03
    ├─nvme0n1p1
    ├─nvme0n1p127
    └─nvme0n1p128
    nvme1n1       vol0XXXXXX4f
    Note: In the preceding example, nvme1n1 is the unencrypted volume that you attached to the instance.

Attach the encrypted volume

To attach your encrypted volume to the rescue instance, complete the following steps:

  1. Stop the instance with the encrypted root volume.
  2. Open the Amazon EC2 console, and then select the stopped instance.
  3. On the Storage tab, note your root device's name, and then choose Volume ID.
    Note: The root device differs by AMI.
  4. Select the encrypted volume, choose Actions, and then choose Detach volume.
  5. After the volume detaches, choose Actions, and then choose Attach volume.
  6. For Instance, select your rescue instance.
  7. For Device name, enter /dev/sdb, and then choose Attach volume.

Copy data from the encrypted volume to the unencrypted volume

Complete the following steps:

  1. Connect to your rescue instance.

  2. To identify your volumes, run the following command:

    lsblk

    Example output before copying data:

    NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
    nvme0n1       259:0    0   55G  0 disk
    ├─nvme0n1p1   259:6    0   55G  0 part /
    ├─nvme0n1p127 259:7    0    1M  0 part
    └─nvme0n1p128 259:8    0   10M  0 part /boot/efi
    nvme1n1
    nvme2n1

    Note: In the preceding example, nvme1n1 is the unencrypted destination volume, and nvme2n1 is the encrypted source volume.

  3. To copy data from the encrypted volume to the unencrypted volume, run the following command as root or with sudo:

    sudo dd if=/dev/SOURCE_DEVICE of=/dev/DESTINATION_DEVICE bs=4M status=progress

    Note: Replace SOURCE_DEVICE with your encrypted volume device name, such as /dev/nvme2n1. Replace DESTINATION_DEVICE with your unencrypted volume device name, such as /dev/nvme1n1. The data transfer time varies based on the volume size, IOPS provisioned, and instance bandwidth.

  4. To mount both volumes, run the following commands:

    sudo mount -o nouuid /dev/nvme2n1p1 /encrypted
    sudo mount -o nouuid /dev/nvme1n1p1 /unencrypted
  5. To verify that you mounted both volumes and that the volumes contain the same data, run the following command:

    df -Th

    Example output after mounting:

    Filesystem       Type      Size  Used Avail Use% Mounted on
    devtmpfs         devtmpfs  4.0M     0  4.0M   0% /dev
    tmpfs            tmpfs     7.8G     0  7.8G   0% /dev/shm
    tmpfs            tmpfs     3.1G  492K  3.1G   1% /run
    /dev/nvme0n1p1   xfs       8.0G  1.9G  6.1G  24% /
    tmpfs            tmpfs     7.8G     0  7.8G   0% /tmp
    /dev/nvme0n1p128 vfat       10M  1.3M  8.7M  13% /boot/efi
    tmpfs            tmpfs     1.6G     0  1.6G   0% /run/user/0
    /dev/nvme2n1p1   xfs       8.0G  8.0G   20K 100% /encrypted
    /dev/nvme1n1p1   xfs       8.0G  8.0G   20K 100% /unencrypted

    Note: The output confirms that both volumes contain the same amount of data: 8.0G.

Attach the unencrypted volume to your original instance

To attach and use the unencrypted volume, complete the following steps:

  1. Detach the unencrypted volume from the rescue instance.
  2. Attach the unencrypted volume to your original instance as the root device. For example: /dev/xvda or /dev/sda1.
  3. Start your original instance.
  4. Connect to your instance and verify that it boots correctly from the unencrypted volume.
  5. (Optional) To create unencrypted cloned volumes for other encrypted volumes in the original instance, repeat the preceding steps.
  6. Terminate the rescue instance, and then delete the previous encrypted volume.
AWS OFFICIALUpdated 7 months ago
3 Comments

Accurate instructions for the procedure, which worked well for me, but I think the navigation of the console and locations of items has changed since the article was published.

replied 2 years ago

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

AWS
MODERATOR

replied 2 years ago

This article was reviewed and updated on 2026-04-23.

AWS
MODERATOR

replied 7 months ago