{"id":5079,"date":"2019-09-23T02:49:05","date_gmt":"2019-09-23T02:49:05","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=5079"},"modified":"2019-09-23T02:49:05","modified_gmt":"2019-09-23T02:49:05","slug":"resize-ebs-volume-without-rebooting-in-aws","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2019\/09\/23\/resize-ebs-volume-without-rebooting-in-aws\/","title":{"rendered":"Resize EBS volume without rebooting in AWS"},"content":{"rendered":"<p>So you need to resize an 8GB boot Disk in AWS after the EC2 is created. In this article we resize the EBS volume without rebooting.<\/p>\n<p><!--more--><\/p>\n<p>1. Modify volume in AWS EC2 UI<br \/>\nAfter login to AWS console, navigate to EC2 -&gt; Elastic Block Store -&gt; Volumes. Click on the volume that you wist to resize, then select Actions -&gt; Modify Volume. It will open a popup.<\/p>\n<p>Enter the new size in the size field. Lets says we are resizing from 8 GB to 30 GB.<br \/>\nClick Modify button<br \/>\nClick Yes button in the confirm popup.<br \/>\nNow the volume has been resized, but it won&#8217;t reflect in the system. We need to do some more steps to make it work.<\/p>\n<p>2. Resize the partition<br \/>\nLets ssh into the machine.<\/p>\n<p>List block devices attached to the machine.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># lsblk\nNAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nloop0     7:0    0 88.5M  1 loop \/snap\/core\/7270\nloop1     7:1    0   18M  1 loop \/snap\/amazon-ssm-agent\/1455\nloop2     7:2    0   89M  1 loop \/snap\/core\/7713\nxvda    202:0    0    8G  0 disk\n\u2514\u2500xvda1 202:1    0    8G  0 part \/\n<\/pre>\n<p>You can see that xvda1 is still 8 GB. Lets increase the partition to disk size.<\/p>\n<p>Install cloud-guest-utils<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># apt install cloud-guest-utils\n<\/pre>\n<p>Grow the partition<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># growpart \/dev\/xvda 1\n<\/pre>\n<p>Let&#8217;s check the partition size (you can see \/dev\/xvda1 is now 30 GB):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># lsblk\nNAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT\nloop0     7:0    0 88.5M  1 loop \/snap\/core\/7270\nloop1     7:1    0   18M  1 loop \/snap\/amazon-ssm-agent\/1455\nloop2     7:2    0   89M  1 loop \/snap\/core\/7713\nxvda    202:0    0   30G  0 disk\n\u2514\u2500xvda1 202:1    0   30G  0 part \/\n<\/pre>\n<p>3. Resize the file system<br \/>\nCheck the file system size. (Still it shows only 8 GB)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># df -h\nFilesystem      Size  Used Avail Use% Mounted on\nudev            481M     0  481M   0% \/dev\ntmpfs            99M  840K   98M   1% \/run\n\/dev\/xvda1      7.7G  6.9G  805M  90% \/\ntmpfs           492M     0  492M   0% \/dev\/shm\ntmpfs           5.0M   24K  5.0M   1% \/run\/lock\ntmpfs           492M     0  492M   0% \/sys\/fs\/cgroup\n\/dev\/loop0       89M   89M     0 100% \/snap\/core\/7270\n\/dev\/loop1       18M   18M     0 100% \/snap\/amazon-ssm-agent\/1455\n\/dev\/loop2       90M   90M     0 100% \/snap\/core\/7713\ntmpfs            99M     0   99M   0% \/run\/user\/1000\n<\/pre>\n<p>Resize the filesystem<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># resize2fs \/dev\/xvda1\nresize2fs 1.44.1 (24-Mar-2018)\nFilesystem at \/dev\/xvda1 is mounted on \/; on-line resizing required\nold_desc_blocks = 1, new_desc_blocks = 4\nThe filesystem on \/dev\/xvda1 is now 7864059 (4k) blocks long.\n<\/pre>\n<p>Check after resizing<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># df -h\nFilesystem      Size  Used Avail Use% Mounted on\nudev            481M     0  481M   0% \/dev\ntmpfs            99M  840K   98M   1% \/run\n\/dev\/xvda1       30G  6.9G   23G  24% \/\ntmpfs           492M     0  492M   0% \/dev\/shm\ntmpfs           5.0M   24K  5.0M   1% \/run\/lock\ntmpfs           492M     0  492M   0% \/sys\/fs\/cgroup\n\/dev\/loop0       89M   89M     0 100% \/snap\/core\/7270\n\/dev\/loop1       18M   18M     0 100% \/snap\/amazon-ssm-agent\/1455\n\/dev\/loop2       90M   90M     0 100% \/snap\/core\/7713\ntmpfs            99M     0   99M   0% \/run\/user\/1000\n<\/pre>\n<p>The disk is now resized.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you need to resize an 8GB boot Disk in AWS after the EC2 is created. In this article we resize the EBS volume without rebooting.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-5079","post","type-post","status-publish","format-standard","hentry","category-aws"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=5079"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5079\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=5079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=5079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=5079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}