{"id":774,"date":"2022-01-18T14:44:56","date_gmt":"2022-01-18T14:44:56","guid":{"rendered":"https:\/\/james-batchelor.com\/?p=774"},"modified":"2022-01-18T14:44:56","modified_gmt":"2022-01-18T14:44:56","slug":"increase-disk-size-on-gentoo-vm-instance","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2022\/01\/18\/increase-disk-size-on-gentoo-vm-instance\/","title":{"rendered":"Increase disk size on Gentoo VM Instance"},"content":{"rendered":"\n<p>There are occasions when the storage capacity of a virtual drive needs to be increased. In production environments a backup and re-install of an OS to a higher capacity provision may not be practical.<\/p>\n\n\n\n<p>Many of our systems deployed from OVA\u2019s use Gentoo as it\u2019s base OS for inexplicable reasons, here\u2019s how to increase the drive capacity of a VM instance running Gentoo and make the extra space usable\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Prework<\/h2>\n\n\n\n<p>SSH into the machine and identify the volume to benefit from the increase by entering<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df -h<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"201\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image.png\" alt=\"\" class=\"wp-image-776\"\/><\/a><\/figure><\/div>\n\n\n\n<p>In this scenario the <em>\/home<\/em> mount point requires the extra space, this is served by the <em>\/dev\/sda4<\/em> Filesystem.<\/p>\n\n\n\n<p>Now discover which disk this is on and where it sits in the layout of the disk (partition):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">fdisk -l<\/pre>\n\n\n\n<p>The virtual disk is detailed towards the end of the output, and is identified with sda, multiple disks will be lableled sdb, sdc etc.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"115\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-1.png\" alt=\"\" class=\"wp-image-777\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Along with the partition table at the end:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"135\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-778\"\/><\/a><\/figure><\/div>\n\n\n\n<p>\/dev\/sda4 is located towards the end of the disk as denoted by the start and end sectors, so will be able to increase the disk by adding extra storage onto what is effectively the end of the drive.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Increase Drive Capacity.<\/strong><\/h2>\n\n\n\n<p>Shut down the VM.<\/p>\n\n\n\n<p>At the hypervisor, edit the configuration of the VM and enter a new capacity.<\/p>\n\n\n\n<p>IM<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"257\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-3.png\" alt=\"\" class=\"wp-image-779\"\/><\/a><figcaption>Note: In VMware, Snapshots or Replications need to be removed in order to change the drive capacity.<\/figcaption><\/figure>\n\n\n\n<p>Start up the VM, restore any Replications (and wait for initial sync to complete)<\/p>\n\n\n\n<p><strong>Highly recommended to take a snapshot at this point.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Reconfigure Partitions<\/strong><\/h2>\n\n\n\n<p>SSH back into the machine, fdisk -l can be used again to sanity check that the drive now has increased capacity:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"132\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-4.png\" alt=\"\" class=\"wp-image-780\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Now to assign this extra capacity to the volume, edit the disk partitions by entering:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">fdisk \/dev\/sda<\/pre>\n\n\n\n<p>To refresh yourself on the current partition layout, enter <strong><em>p<\/em><\/strong> command to view, it also helps to have this on screen for the next steps\u2026<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"429\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-5.png\" alt=\"\" class=\"wp-image-781\"\/><\/a><\/figure><\/div>\n\n\n\n<p>As mentioned, here the goal is to increase <em>\/dev\/sda4<\/em>. To achieve this we need to remove this partition then re-add it to overlay the current structure but including the extra space. Sounds scary, but these changes aren\u2019t in place until we commit the changes later. Nevertheless a good time to check the recent snapshot has completed.<\/p>\n\n\n\n<p>Delete the current partition using command <strong><em>&#8220;d&#8221;<\/em><\/strong>, then entering partition number:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"311\" height=\"72\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-6.png\" alt=\"\" class=\"wp-image-782\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Again, can you the <strong><em>&#8220;p<\/em>&#8220;<\/strong> command to check its gone.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"128\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-7.png\" alt=\"\" class=\"wp-image-783\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Now create the new partition with the <strong><em>&#8220;n&#8221;<\/em><\/strong> command.<\/p>\n\n\n\n<p>Prompted for the first sector, enter the same value recorded on the original partition<\/p>\n\n\n\n<p>The last sector, enter the default value shown, this should be greater than the original partition as there\u2019s more storage available.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"73\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-8.png\" alt=\"\" class=\"wp-image-784\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Output will advise that partition is made, then ask if you want to remove the signature. Enter NO to keep it, as we want to keep the original partition intact.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"74\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-9.png\" alt=\"\" class=\"wp-image-785\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Finally, enter <strong><em>&#8220;w&#8221;<\/em><\/strong> command to write and commit the changes.<\/p>\n\n\n\n<p>Reboot the VM.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Assign new space.<\/strong><\/h2>\n\n\n\n<p>On restart, using <em>fdisk -l<\/em> will confirm the partition is bigger:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"496\" height=\"106\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-10.png\" alt=\"\" class=\"wp-image-786\"\/><\/a><\/figure><\/div>\n\n\n\n<p>However, <em>df -h<\/em> will not have increased:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"440\" height=\"171\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-11.png\" alt=\"\" class=\"wp-image-787\"\/><\/a><\/figure><\/div>\n\n\n\n<p>To use the extra space, we need to tell Gentoo that its available to use by entering:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">resize2fs \/dev\/sda4<\/pre>\n\n\n\n<p>Output should look like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"578\" height=\"90\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-13.png\" alt=\"\" class=\"wp-image-790\"\/><\/a><\/figure><\/div>\n\n\n\n<p>Now<em> df -h<\/em> will reflect the extra space and is ready to use:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"160\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/01\/image-12.png\" alt=\"\" class=\"wp-image-789\"\/><\/a><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>There are occasions when the storage capacity of a virtual drive needs to be increased. In production environments a backup and re-install of an OS to a higher capacity provision may not be practical. Many of our systems deployed from OVA\u2019s use Gentoo as it\u2019s base OS for inexplicable reasons, here\u2019s how to increase the &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2022\/01\/18\/increase-disk-size-on-gentoo-vm-instance\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Increase disk size on Gentoo VM Instance&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[338,334,336,335,337,221],"class_list":["post-774","post","type-post","status-publish","format-standard","hentry","category-servers","tag-fdisk","tag-gentoo","tag-increase-disk","tag-increase-storage","tag-vm","tag-vmware"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=774"}],"version-history":[{"count":3,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/774\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/774\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}