{"id":1486,"date":"2020-05-29T16:46:23","date_gmt":"2020-05-29T14:46:23","guid":{"rendered":"https:\/\/leeryanrs.com\/?p=1486"},"modified":"2020-05-29T16:46:23","modified_gmt":"2020-05-29T14:46:23","slug":"extending-an-xfs-partition-on-centos","status":"publish","type":"post","link":"https:\/\/leeryanrs.com\/?p=1486","title":{"rendered":"Extending an XFS partition on Centos"},"content":{"rendered":"\n<p>I came across the need to extend a partition on a Centos VM deployed in Azure which was not running LVM, but XFS. This seems to be a common way of how the templates are deployed in Azure.<\/p>\n\n\n\n<p>I won&#8217;t go into detail on how you increase the disk space on the virtualization layer, I&#8217;ll leave that to you since it&#8217;s different for every platform and a fairly basic task. <\/p>\n\n\n\n<p>This example is for increasing \/dev\/sda2.  Let&#8217;s say you&#8217;ve increased your disk from 32GB to 64GB, however when issuing the below command to list your disks, you still see it at 32GB!<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df -h\n\n<strong>Resulting Output -<\/strong> \n\nFilesystem Size Used Avail Use% Mounted on\nudev 1.5G 0 1.5G 0% \/dev\ntmpfs 291M 33M 259M 12% \/run\n<strong>\/dev\/sda2 32G 3.9G 32G 11% \/<\/strong>\ntmpfs 1.5G 4.0K 1.5G 1% \/dev\/shm\ntmpfs 5.0M 0 5.0M 0% \/run\/lock\ntmpfs 1.5G 0 1.5G 0% \/sys\/fs\/cgroup\n\/dev\/vda1 472M 171M 277M 39% \/boot\ntmpfs 291M 0 291M 0% \/run\/user\/0<\/pre>\n\n\n\n<p>From here, you&#8217;ll want to run the below command to see that the OS is recognizing the increase space and just hasn&#8217;t allocated it &#8211; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">fdisk -l\n\n<strong>Resulting Output - <\/strong>\n\nDisk \/dev\/vda: 64 GiB, 42949672960 bytes, 83886080 sectors<\/pre>\n\n\n\n<p>Now that we have confirmed the OS is seeing the extra space, lets assign it to the partition we need &#8211;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1) fdisk -l \/dev\/sda\n2) p (This will print the existing partition table)\n3) d (This will enter delete mode to remove the partition)\n4) 2 (This is the partition number we want to delete)\n5) p (This will print the partition table again to confirm)\n6) n (Wizard to create new partition)\n7) p (This selects type of partition, in our case P for primary)\n8) 2 (Re use the partition number we had previously)\n9) First sector - just press enter to accept the default\n10) Last sector - same as above, this will ensure its assigned all available free space on that disk \n11) w - this will write the partition <\/pre>\n\n\n\n<p>After completing the above steps, you will be given a warning about the device or resource being busy, don&#8217;t worry this is completely fine. One more command before we reboot &#8211; <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">partprobe<\/pre>\n\n\n\n<p>This will synchronize the partition to the kernel however fail due to requiring a reboot to take effect. Reboot now and execute the final step once back up &#8211;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">xfs_growfs \/<\/pre>\n\n\n\n<p>This will now assign all the free space available and we should be fine!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across the need to extend a partition on a Centos VM deployed in Azure which was not running LVM, but XFS. This seems to be a common way of how the templates are deployed in Azure. I won&#8217;t go into detail on how you increase the disk space on the virtualization layer, I&#8217;ll [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,15],"tags":[25,27,30],"class_list":["post-1486","post","type-post","status-publish","format-standard","hentry","category-linux","category-server","tag-azure","tag-centos","tag-disk"],"_links":{"self":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/1486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1486"}],"version-history":[{"count":0,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/1486\/revisions"}],"wp:attachment":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}