How to Replace an EC2 Instance’s Volume with One Created from a Snapshot

Preparatory Steps:

1. Identify the Desired Snapshot:

  • a. Navigate to the EC2 Dashboard in the AWS Management Console.
  • b. Click on “Snapshots” in the left navigation pane.
  • c. Sort snapshots by creation time/date to locate the snapshot you want to use.

2. Determine the Corresponding Volume:

  • a. From the selected snapshot’s details, identify the source volume ID or any other relevant volume information.

3. Locate the Associated EC2 Instance:

  • a. With the volume information from the previous step, go to “Volumes” in the left pane.
  • b. Locate the volume and check its “Attachment Information” column. This will display the instance ID with which the volume is associated.

4. Document the Pairing:

  • Create a table or list documenting the Snapshot ID, Volume ID, and corresponding Instance ID for streamlined operations. eg:
    • snap-XXXXXXX 500 GiB 20230530 Standard Completed 2023/05/30 09:48 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node3): /dev/sda1 (attached)
    • snap-XXXXXXX 1024 GiB 20230530 Standard Completed 2023/05/30 09:48 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node3): /dev/sdb (attached)
    • snap-XXXXXXX 500 GiB 20230530 Standard Completed 2023/05/30 09:47 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node1): /dev/sda1 (attached)
    • snap-XXXXXXX 500 GiB 20230530 Standard Completed 2023/05/30 09:47 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node2): /dev/sda1 (attached)
    • snap-XXXXXXX 200 GiB 20230530 Standard Completed 2023/05/30 09:47 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-Admin): /dev/sda1 (attached)
    • snap-XXXXXXX 1024 GiB 20230530 Standard Completed 2023/05/30 09:47 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node1): /dev/sdb (attached)
    • snap-XXXXXXX 1024 GiB 20230530 Standard Completed 2023/05/30 09:47 GMT+9 Available (100%) vol-XXXXXXX i-XXXXXXX (ubuntu-XXX-node2): /dev/sdb (attached)

Main Steps:

5. Create a New Volume from the Snapshot:

  • a. In the left navigation pane, click on “Snapshots.”
  • b. Select the snapshot you want to create a volume from.
  • c. Choose “Actions” and then “Create Volume.”
  • d. Configure the volume settings. Ensure the volume is in the same availability zone as the EC2 instance.
  • e. Click “Create.”

6. Stop the EC2 Instance:

  • a. In the left navigation pane, click on “Instances.”
  • b. Select your EC2 instance.
  • c. Click “Instance State” > “Stop Instance.”
  • d. Wait for the instance to be “stopped.”

7. Detach the Current Volume:

  • a. On the EC2 Dashboard, in the left pane, click on “Instances.”
  • b. Select the desired EC2 instance.
  • c. Below the instances list, click on the “Description” tab. Scroll to the “Root device” entry and click on the link next to it. Note the volume ID.
  • d. Navigate to “Volumes” in the left pane. Using the noted volume ID, locate and select the current volume.
  • e. Click “Actions” > “Detach Volume.”

8. Attach the New Volume to the EC2 Instance:

  • a. In the “Volumes” section, find the new volume made from the snapshot.
  • b. Click “Actions” > “Attach Volume.”
  • c. Select your EC2 instance and input the original root device name (e.g., /dev/xvda).
  • d. Click “Attach.”

9. Start the EC2 Instance:

  • a. Navigate back to “Instances.”
  • b. Select your EC2 instance.
  • c. Click “Instance State” > “Start Instance.”

10. Optional Clean-Up:

  • a. Navigate to “Volumes.”
  • b. Select the old volume.
  • c. Click “Actions” > “Delete Volume.”

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始