Upgrading EBS Volume Types (33-34)

  Amazon Web Services (AWS)

Main Menu

Part 1

https://www.udemy.com/aws-certified-solutions-architect-associate/learn/v4/t/lecture/2050670?start=0
Situation: Running a DEV environment with OS on root file system and DB on a second partition. Moving to production, we want to move from a standard Magnetic volume to an IO2 volume to improve performance.

Create New Instance with 2 volumes

  •  root volume = GP2 (SSD, 8GB)
  • Second volume = Magnetic (1GB)

Display the attached drives

lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdb    202:16   0   1G  0 disk

The root drive has been mounted at /, however the second volume (xvdb) has not been mounted.

Make the Filesystem / Format the drive

If restoring from a snapshot, don’t do this! It will wipe the drive!
mkfs -t ext4 /dev/xvdb
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 9ee51e53-f5a6-419c-ae77-29f8d6f12592
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

Mount the Additional Drive

mkdir /mynewdrive
mount /dev/xvdb /mynewdrive
lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdb    202:16   0   1G  0 disk /mynewdrive

Create a test file

cd /mynewdrive
echo "Test test test" > test.html
cat test.html
Test test test

Unmount and detach the drive

Unmount from the instance

cd /
umount /dev/xvdb

Detach using the dashboard

Dashbord > Volumes > Desired Volume > Actions > Detach Volume > “Are you sure” > [Yes, Detach]

It is also possible to detach a MOUNTED volume using the ‘Force Detach’ option.

This process takes several minutes, so be patient. It should be ready when the State changes from In Use to Available.
This took forever. I tried to force it, but it said it was already available. After refreshing my screen I saw it had actually detached, so I don’t know how long this actually took 🙁

Create a Snapshot

Dashboard > Volumes > select Volume, Actions > Create Snapshot

  • Name = MyNewDrive
  • Description = MyNewDrive
  • [Create]

Again, this will take several minutes. <i>Okay, maybe 1 this time</i>

Create a New Volume

Dashoard > Snapshots > Select Snapshot > Actions > Create Volume

  • Volume Type = Provisioned IOPS (IO2)
  • Size = 4GB (Smallest available – note this is 4x larger than our snapshot.
  • IOPS = 100 (50 IOPS Max per GB, this could go to 200, eh?)
  • [Create Volume]

This was almost instantaneous!

Attach the New Volume

Dashboard > Volumes > Select Volume > Action > Attach Volume > Select Instance > [Attach]

lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdf    202:80   0   4G  0 disk

Check for existing files before mounting!

file -s /dev/xvdf
/dev/xvdf: Linux rev 1.0 ext4 filesystem data, UUID=9ee51e53-f5a6-419c-ae77-29f8d6f12592 (needs journal recovery) (extents) (large files) (huge files)

If it was empty, it would just say ‘Data’. I’ll need to test this.

Mount the filesystem

mount /dev/xvdf /mynewdrive
cd /mynewdrive
ls
lost+found  test.html
df -f
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        489M   60K  488M   1% /dev
tmpfs           497M     0  497M   0% /dev/shm
/dev/xvda1      7.8G  1.2G  6.6G  15% /
/dev/xvdf       976M  1.3M  908M   1% /mynewdrive

As suspected, the new volume is the size of the snapshot / original drive (1 GB) and not the actual size of the block device (4GB)

Exam Tips – Part 1

  • Unmount the drive: umount /dev/drive
  • Detach the volume
  • Create a snapshot
  • Create a new volume from the snapshot using the desired drive type
  • Attach the new volume
  • Check the new volume for a filesystem
  • Mount the new volume.

Part 2

https://www.udemy.com/aws-certified-solutions-architect-associate/learn/v4/t/lecture/7325738?start=0

Seems like something is missing from the start of this video.  Volume appears to be attached to an instance, but the instance was stopped before creating the snapshot.

It is best practice to stop the instance before creating a snapshot. While you can do it ‘on the fly’ this is the best way to ensure the data is application consistent.

This lesson seems to be showing a different chain of events

  • Stop the instance
  • Detach the volume
  • Create the snapshot
    • You can delete the ‘old volume’ at this time, it is no longer needed and can be recreated if required.
  • Create the new volume from the snapshot
  • Attach the new volume
  • Restart the Instance
  • Mount the new volume to the desired folder

Exam Tips – Part 2

  • EBS Volumes can be changed on the fly (except for Magnetic Standard)
  • Best practice to stop the EC2 instance then change the volume.
  • You can change volume types by taking a snapshot then using the snapshot to create a new volume.
  • If you change a volume on the fly, you must wait 6 hours before making another change.
  • You can scanle EBS volumes UP only!  (You cannot downsize!)
  • Volumes must be in the same AZ as the EC2 Instance.
    • There is no magic button to make this happen, so pay attention!

 

LEAVE A COMMENT