4.6 Upgrade EBS Volume Types - Lab1
Steps
SSH to your EC2 instance, go to root user.
See what volumes have been attached to this instance. You can see this in your console, but you also can see it in shell using command: lsblk. You can see two volumes: xvda and xvdb. (xvda is the bootable disk which has been mounted to root directory automatically when instructor created the instance. xvdb is the one that extra attached to this instance when instructor created this instance. xvdb will be used to demo this lab). For now, xvdb hasn't been created file system and also hasn't been mounted to a specific directory.
Create file system on the volume (xvdb) using command: mkfs -t ext4 /dev/xvdb. If you are restoring from a snapshot you won't want to do this because this command will wipe the snapshot. (This situation will be solved later).
Mount this volume with file system to a specific mount point. You can create a new directory as the mount point using command mkdir /acloudguru and mount the volume to this directory using command: mount /dev/xvdb /acloudguru. Now you can check the mount is done successfully by using lsblk, or you can also go to the mount point directory and ls, you will see lost+found. This directory is actually the entry point of the file system of this volume, and you can store files here or build database here.
Unmount a volume from a mount point using command: umount /dev/xvdb. Now you can check unmount is done successfully by using lsblk, or go to mount directory ans ls and you will not see lost+found, it is empty.
Although you can unmount a volume from a specific mount point directory, the states of this volume is maintained. When you mount this volume to a directory again, and go to this directory, and you can see your previous data is still stored in the file ssytem of this volume.
You can detach the volume from your EC2 instance through the AWS console: Elastic Block Store -> Volumes -> Actions -> Detach Volume. You can attach this volume to other instance and mount it, and this is like you attach your disk to another laptop.
You can create snapshot for your volumes: Elastic Block Store -> Volumes -> Actions -> Create Snapshot. Then you can see your snapshots at Elastic Block Store -> Snapshots.
These snapshot can be used to create new volumes which will has same data with the original volume of this snapshot, but you can make it with another type. You can click on a snapshot and Create Volume based on it. You will see your new volume in Volumes.
This is very helpful. Let see an example (REMEMBER THESE STEPS, IT IS EXAM KEY POINT): you may have a Magnetic type volume and there is a MySQL database built on it. Now you want to upgrade this volume to Provisioned IOPS (your DB needs more I/O ability), so you can follow these steps, firstly stop your MySQL service, and then unmount the volume from the mount point directory, and then detach your volume from your instance, and then create a snapshot for this volume, and then create a new volume based on this snapshot with another type (changing the storage medium), and then attach this new volume to your instance, and then re-mount the volume to the mount point directory.
Tips:
Detaching an Amazon EBS Volume from an Instance:
You can detach an Amazon EBS volume from an instance explicitly or by terminating the instance. However, if the instance is running, you must first unmount the volume from the instance.
If an EBS volume is the root device of an instance, you must stop the instance before you can detach the volume.
When the EBS volume is in
in-use
(attached) oravailable
(not attached) status, it will charge you money. Delete the volume to avoid to be charged.
Last updated
Was this helpful?