{"id":499,"date":"2017-09-03T02:15:52","date_gmt":"2017-09-03T02:15:52","guid":{"rendered":"http:\/\/wiki.thomasandsofia.com\/?p=499"},"modified":"2017-09-03T20:17:25","modified_gmt":"2017-09-03T20:17:25","slug":"upgrading-ebs-volume-types","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=499","title":{"rendered":"Upgrading EBS Volume Types (33-34)"},"content":{"rendered":"<h1>Main Menu<\/h1>\n<ul>\n<li><a href='p1'>Part 1 &#8211; Changing an EBS Volume Type<\/a>\n<ul>\n<li>Mounting an Additional EBS Volume\n<ul>\n<li><a href='lsblk'>View the attached EBS Volumes (lsblk)<\/a><\/li>\n<li><a href='mkfs'>Make the Filesystem \/ Format the drive (mkfs)<\/a><\/li>\n<li><a href='mount'>Mount the additional filesystem (mount)<\/a><\/li>\n<\/li>\n<\/ul>\n<\/li>\n<li>Upgrading the Drive\n<ul>\n<li><a href='umount'>Unmount the Volume (umount)<\/a><\/li>\n<li><a href='snap'>Detach and Create the Snapshot<\/a><\/li>\n<li><a href='makevol'>Create a New Volume from the Snapshot<\/a><\/li>\n<li><a href='attachvol'>Attach the New Volume to the Instance<\/a><\/li>\n<li><a href='mountvol'>Mount the New Volume to the Instance<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Exam Tips &#8211; Part 1<\/li>\n<li>Part 2 &#8211; Best Practices<\/li>\n<li>Exam Tips &#8211; Part 2<\/li>\n<\/ul>\n<p><a name=\"#p1\"><\/a><\/p>\n<h1>Part 1<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/aws-certified-solutions-architect-associate\/learn\/v4\/t\/lecture\/2050670?start=0\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/aws-certified-solutions-architect-associate\/learn\/v4\/t\/lecture\/2050670?start=0<\/a><br \/>\nSituation: 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.<\/p>\n<h3>Create New Instance with 2 volumes<\/h3>\n<ul>\n<li>\u00a0root volume = GP2 (SSD, 8GB)<\/li>\n<li>Second volume = Magnetic (1GB)<\/li>\n<\/ul>\n<p><a name=\"lsblk\"><\/a><\/p>\n<h3>Display the attached drives<\/h3>\n<pre>lsblk<\/pre>\n<pre>NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\r\nxvda    202:0    0   8G  0 disk \r\n\u2514\u2500xvda1 202:1    0   8G  0 part \/\r\nxvdb    202:16   0   1G  0 disk<\/pre>\n<p>The root drive has been mounted at \/, however the second volume (xvdb) has not been mounted.<\/p>\n<p><a name=\"mkfs\"><\/a><\/p>\n<h3>Make the Filesystem \/ Format the drive<\/h3>\n<div class=\"warning\">If restoring from a snapshot, don&#8217;t do this! It will wipe the drive!<\/div>\n<pre>mkfs -t ext4 \/dev\/xvdb<\/pre>\n<pre>mke2fs 1.42.12 (29-Aug-2014)\r\nCreating filesystem with 262144 4k blocks and 65536 inodes\r\nFilesystem UUID: 9ee51e53-f5a6-419c-ae77-29f8d6f12592\r\nSuperblock backups stored on blocks: \r\n\t32768, 98304, 163840, 229376\r\n\r\nAllocating group tables: done                            \r\nWriting inode tables: done                            \r\nCreating journal (8192 blocks): done\r\nWriting superblocks and filesystem accounting information: done<\/pre>\n<p><a name=\"mount\"><\/a><\/p>\n<h3>Mount the Additional Drive<\/h3>\n<pre>mkdir \/mynewdrive\r\nmount \/dev\/xvdb \/mynewdrive\r\nlsblk<\/pre>\n<pre>NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\r\nxvda    202:0    0   8G  0 disk \r\n\u2514\u2500xvda1 202:1    0   8G  0 part \/\r\nxvdb    202:16   0   1G  0 disk \/mynewdrive<\/pre>\n<p><a name=\"test\"><\/a><\/p>\n<h3>Create a test file<\/h3>\n<pre>cd \/mynewdrive\r\necho \"Test test test\" &gt; test.html\r\ncat test.html<\/pre>\n<pre>Test test test<\/pre>\n<p><a name=\"umount\"><\/a><\/p>\n<h3>Unmount and detach the drive<\/h3>\n<h4>Unmount from the instance<\/h4>\n<pre>cd \/\r\numount \/dev\/xvdb<\/pre>\n<h4>Detach using the dashboard<\/h4>\n<p>Dashbord &gt; Volumes &gt; Desired Volume &gt; Actions &gt; Detach Volume &gt; &#8220;Are you sure&#8221; &gt; [Yes, Detach]<\/p>\n<p>It is also possible to detach a MOUNTED volume using the &#8216;Force Detach&#8217; option.<\/p>\n<p>This process takes several minutes, so be patient. It should be ready when the State changes from In Use to Available.<br \/>\n<i>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&#8217;t know how long this actually took \ud83d\ude41<\/i><\/p>\n<p><a name=\"snap\"><\/a><\/p>\n<h3>Create a Snapshot<\/h3>\n<p>Dashboard &gt; Volumes &gt; select Volume, Actions &gt; Create Snapshot<\/p>\n<ul>\n<li>Name = MyNewDrive<\/li>\n<li>Description = MyNewDrive<\/li>\n<li>[Create]<\/li>\n<\/ul>\n<p>Again, this will take several minutes. &lt;i&gt;Okay, maybe 1 this time&lt;\/i&gt;<\/p>\n<p><a name=\"makevol\"><\/a><\/p>\n<h3>Create a New Volume<\/h3>\n<p>Dashoard &gt; Snapshots &gt; Select Snapshot &gt; Actions &gt; Create Volume<\/p>\n<ul>\n<li>Volume Type = Provisioned IOPS (IO2)<\/li>\n<li>Size = 4GB (Smallest available &#8211; note this is 4x larger than our snapshot.<\/li>\n<li>IOPS = 100 (50 IOPS Max per GB, this could go to 200, eh?)<\/li>\n<li>[Create Volume]<\/li>\n<\/ul>\n<p>This was almost instantaneous!<\/p>\n<p><a name=\"attachvol\"><\/a><\/p>\n<h3>Attach the New Volume<\/h3>\n<p>Dashboard &gt; Volumes &gt; Select Volume &gt; Action &gt; Attach Volume &gt; Select Instance &gt; [Attach]<\/p>\n<pre>lsblk<\/pre>\n<pre>NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\r\nxvda    202:0    0   8G  0 disk \r\n\u2514\u2500xvda1 202:1    0   8G  0 part \/\r\nxvdf    202:80   0   4G  0 disk<\/pre>\n<p>Check for existing files before mounting!<\/p>\n<pre>file -s \/dev\/xvdf<\/pre>\n<pre>\/dev\/xvdf: Linux rev 1.0 ext4 filesystem data, UUID=9ee51e53-f5a6-419c-ae77-29f8d6f12592 (needs journal recovery) (extents) (large files) (huge files)<\/pre>\n<p><i>If it was empty, it would just say &#8216;Data&#8217;. I&#8217;ll need to test this.<\/i><\/p>\n<p><a name=\"mountvol\"><\/a><\/p>\n<h3>Mount the filesystem<\/h3>\n<pre>mount \/dev\/xvdf \/mynewdrive\r\ncd \/mynewdrive\r\nls<\/pre>\n<pre>lost+found  test.html<\/pre>\n<div class=\"notice\">\n<pre>df -f<\/pre>\n<pre>Filesystem      Size  Used Avail Use% Mounted on\r\ndevtmpfs        489M   60K  488M   1% \/dev\r\ntmpfs           497M     0  497M   0% \/dev\/shm\r\n\/dev\/xvda1      7.8G  1.2G  6.6G  15% \/\r\n\/dev\/xvdf       976M  1.3M  908M   1% \/mynewdrive<\/pre>\n<p>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)<\/p>\n<\/div>\n<p><a name=\"exam1\"><\/a><\/p>\n<h1>Exam Tips &#8211; Part 1<\/h1>\n<ul>\n<li>Unmount the drive: umount \/dev\/drive<\/li>\n<li>Detach the volume<\/li>\n<li>Create a snapshot<\/li>\n<li>Create a new volume from the snapshot using the desired drive type<\/li>\n<li>Attach the new volume<\/li>\n<li>Check the new volume for a filesystem<\/li>\n<li>Mount the new volume.<\/li>\n<\/ul>\n<p><a name=\"#p2\"><\/a><\/p>\n<h1>Part 2<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/aws-certified-solutions-architect-associate\/learn\/v4\/t\/lecture\/7325738?start=0\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/aws-certified-solutions-architect-associate\/learn\/v4\/t\/lecture\/7325738?start=0<\/a><\/p>\n<p>Seems like something is missing from the start of this video.\u00a0 Volume appears to be attached to an instance, but the instance was stopped before creating the snapshot.<\/p>\n<div class=\"notice\">It is best practice to stop the instance before creating a snapshot. While you can do it &#8216;on the fly&#8217; this is the best way to ensure the data is application consistent.<\/div>\n<p>This lesson seems to be showing a different chain of events<\/p>\n<ul>\n<li>Stop the instance<\/li>\n<li>Detach the volume<\/li>\n<li>Create the snapshot\n<ul>\n<li>You can delete the &#8216;old volume&#8217; at this time, it is no longer needed and can be recreated if required.<\/li>\n<\/ul>\n<\/li>\n<li>Create the new volume from the snapshot<\/li>\n<li>Attach the new volume<\/li>\n<li>Restart the Instance<\/li>\n<li>Mount the new volume to the desired folder<\/li>\n<\/ul>\n<p><a name=\"exam2\"><\/a><\/p>\n<h1>Exam Tips &#8211; Part 2<\/h1>\n<ul>\n<li>EBS Volumes can be changed on the fly (except for Magnetic Standard)<\/li>\n<li>Best practice to stop the EC2 instance then change the volume.<\/li>\n<li>You can change volume types by taking a snapshot then using the snapshot to create a new volume.<\/li>\n<li>If you change a volume on the fly, you must wait 6 hours before making another change.<\/li>\n<li>You can scanle EBS volumes UP only!\u00a0 (You cannot downsize!)<\/li>\n<li>Volumes must be in the same AZ as the EC2 Instance.\n<ul>\n<li>There is no magic button to make this happen, so pay attention!<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Main Menu Part 1 &#8211; Changing an EBS Volume Type Mounting an Additional EBS Volume View the attached EBS Volumes (lsblk) Make the Filesystem \/ Format the drive (mkfs) Mount the additional filesystem (mount) Upgrading the Drive Unmount the Volume (umount) Detach and Create the Snapshot Create a New Volume from the Snapshot Attach the ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=499\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-499","post","type-post","status-publish","format-standard","hentry","category-amazon-web-services-aws"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=499"}],"version-history":[{"count":19,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions"}],"predecessor-version":[{"id":518,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions\/518"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}