I’m currently going through a course on Amazon Web Services, taught by ACloud.Guru. His course focuses on preparing students to pass all of the AWS certification exams. The course consists of important theoretical concepts as well as hands on labs.
We have a lab today regarding Upgrading our EBS Volumes. The scenario is as follows:
You’re managing a server. The server running a 22 GB magnetic hard disk drive (HDD). You have been requested to upgrade the hard drive of the server to a high speed SSD drive. You don’t have a large enough budget to acquire a new physical hard drive and server, so you decide to go with a cheaper solution. You decide that the platform of choice is Amazon Web Services.
Through this lab, we will learn the following:
- Provisioning a Magnetic HDD on an EC2 instance
- Installing a file system using the linux command line interface (CLI)
- Mounting a volume to a directory. (Assigning a directory to a specific mount point)
- Using the Nano Linux Text Editor through the Linux CLI
- Unmounting & Remounting EBS Volumes using the Linux CLI.
- Detaching & Reattaching EBS volumes using the AWS console
- Creating and Restoring Snapshots using the AWS console
To start off, we have to launch an EC2 instance and configure an EBS volume. In the configuration settings, we will select Magnetic to mimic the scenario of our lab.
Now that the server with the classic magnetic hard drive is running, we log into the machine using SSH, and run the routine updates.
To view the EBS volumes attached to the EC2, do the following:
We can see that there are two volumes, XVDA and XVDF. XVDA1. is partitioned from XVDA. The volume of concern is the 22 gb XVDF volume. If you look to the last colum, you can see that the XVDF volume is NOT mounted to a directory. The XVDA volume is mounted to the file system by the symbol: (/). We need to mount the 22 GB XVDF to a new directory called /testdirectory.
Before we can do that, XVDF needs a file system. Otherwise, we will get an error when trying to mount the directory.
After this, we can make the directory and mount it.
Now you can see the XVDF volume has a mount point of /testdirectory. The /testdirectory is now mounted to the volume XVDF.
After this, let’s create a test file to see if it will remain after upgrading the 22 GB EBS volume to SSD.
Navigate to the testdirectory, and display the contents. You will find it empty.
The last command was to start the Linux text editor, called NANO. We created a file called text.html.
At the bottom are the commands for the Nano editor. After writing something in the file,quit the Nano Linux text editor by pressing: CTRL-X then ‘Y’ for “yes” to save and quit.
Now comes the juicy part. We will swap out the 22 gb magnetic EBS volume with a high speed SSD EBS volume. We will do this by attaching another EBS volume to the EC2 through the AWS console. Then we will unmount the /testdirectory and remount it to the new volume. And if the test.html file shows up, we know that our little lab worked out and the data remained in tact.
- First we create snapshot of the XVDF volume in the AWS console:
- Then we create a new SSD Provisioned IOPS EBS Volume from the snapshot. *Make sure the volume is in the same Region as the instance, or else you won’t be able to attach the volume.
- Thirdly, we take the new SSD Volume, and attach it to the EC2 instance. Watch the 2 minute video to see these steps in action.
After attaching the EBS volume in the AWS console, you should see it in your Linux SSH window by the LSBLK command.
The new volume is: XVDG. The final step is to remount the /testdirectory to the new XVDG volume. We have to unmount the /testdirectory from XVDF and mount it to XVDG.