{"id":382,"date":"2023-05-12T16:42:35","date_gmt":"2023-05-12T14:42:35","guid":{"rendered":"https:\/\/gilbert.busana.lu\/?p=382"},"modified":"2023-05-12T16:59:24","modified_gmt":"2023-05-12T14:59:24","slug":"expand-a-vm-disk-in-proxmox-ubuntu-vm","status":"publish","type":"post","link":"https:\/\/www.homeserver.lu\/?p=382","title":{"rendered":"Expand a VM disk in Proxmox (Ubuntu VM)"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>Disclaimer: this is a very risky operation!\nMake sure you have one or more backups of your data!\nUse on your own risk!<\/code><\/pre>\n\n\n\n<p>This tutorial will guide you in increasing the space of your virtual disk. Three steps are required:<br>1. increase the VM disk size in Proxmox<br>2. change the partition table to reflect the changes in Ubuntu<br>3. resize your file system in Ubuntu<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Resizing VM disk size in Proxmox<\/h2>\n\n\n\n<p> 1.1 Open the Proxmox webinterface, select the VM for which you want to modify a disk size and select the <em>hardware<\/em> tab. Write down the VM ID (example: 103) and the harddisk identifier (example: scsi0).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM-1024x369.png\" alt=\"\" class=\"wp-image-385\" width=\"638\" height=\"230\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM-1024x369.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM-300x108.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM-768x276.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM-624x225.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/ProxMox-VM.png 1328w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><figcaption class=\"wp-element-caption\">Proxmox: Identify the hard disk identifier (scsi0) and the VM ID (103)<\/figcaption><\/figure>\n<\/div>\n\n\n<p>1.2 In the Proxmox VM\/LC tree, select the parent node. Open the node <em>shell<\/em>. Resize the VM size using the following command in the Proxmox node&#8217;s shell. This step can be done online (VM running) or offline (VM shut down).<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>qm resize [VM_ID] [DISK_IDENTIFIER] +[SIZE_INCREASE]G<\/code><\/pre><\/div>\n\n\n\n<p>Example:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>qm resize 103 scsi0 +2000G<\/code><\/pre><\/div>\n\n\n\n<p>1.3 Verify that the hardware tab reflects the executed changes in the VM disk size. If you try to add more space than there is available space left on the hard drive, you will get an error (zfs error: cannot set property for &#8216;vm-103-disk0&#8217;: size is greater than available space).<\/p>\n\n\n\n<p>Now that your virtual disk has the desired size, we need to change the partition table so that your Ubuntu will see it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Enlarge the partition in the virtual disk<\/h2>\n\n\n\n<p>2.1 Find the disk name of the disk whose partition you want to change inside your VM. <\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>lsblk<\/code><\/pre><\/div>\n\n\n\n<p>My disk (sdb) now has 13.7 TB. You can notice that the partition (sdb1) does not use all the available space yet.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/21.png\" alt=\"\" class=\"wp-image-430\" width=\"537\" height=\"172\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/21.png 1012w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/21-300x97.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/21-768x247.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/21-624x201.png 624w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\" \/><figcaption class=\"wp-element-caption\">Current partition scheme<\/figcaption><\/figure>\n<\/div>\n\n\n<p>2.2 Before unmounting the disk, make sure that no service uses the corresponding disk. In my case, I preferred to shutdown the Apache service to make sure that no user activity intervenes on the disk.<\/p>\n\n\n\n<p>2.3 Unmount all filesystems of the disk on which you want to change the partition table.  We want to change the partition table of <em>sdb<\/em>, so we have to unmount <em>sdb1<\/em> (which is the only partition on this disk).<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>umount \/dev\/sdb1<\/code><\/pre><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/23.png\" alt=\"\" class=\"wp-image-432\" width=\"540\" height=\"172\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/23.png 1018w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/23-300x95.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/23-768x244.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/23-624x199.png 624w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/><figcaption class=\"wp-element-caption\">Check that the partition has been unmounted (\/data should not be listed anymore)<\/figcaption><\/figure>\n<\/div>\n\n\n<p>2.4 We will be using <em>fdisk<\/em> to repartition the disk.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"771\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/241-1024x771.png\" alt=\"\" class=\"wp-image-426\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/241-1024x771.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/241-300x226.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/241-768x578.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/241-624x470.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/241.png 1464w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">fdisk command options<\/figcaption><\/figure>\n<\/div>\n\n\n<p>You can run <em>fdisk -l<\/em> to list all the partitions available.<\/p>\n\n\n\n<p>Inside <em>fdisk<\/em>, you can use the following commands:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/242-707x1024.png\" alt=\"\" class=\"wp-image-423\" width=\"474\" height=\"686\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/242-707x1024.png 707w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/242-207x300.png 207w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/242-768x1112.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/242-624x903.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/242.png 858w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><figcaption class=\"wp-element-caption\">fdisk commands<\/figcaption><\/figure>\n<\/div>\n\n\n<p>Run the following command to start modifying your partition. Make sure to use the disk (<em>sdb<\/em>) and not the partition name (<em>sdb1<\/em>)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>fdisk \/dev\/sdb<\/code><\/pre><\/div>\n\n\n\n<p>2.5 Now delete the current partition scheme (that&#8217;s scary, isn&#8217;t it?) using the &#8220;d&#8221;-command. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/25d.png\" alt=\"\" class=\"wp-image-428\" width=\"282\" height=\"90\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/25d.png 486w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/25d-300x96.png 300w\" sizes=\"auto, (max-width: 282px) 100vw, 282px\" \/><figcaption class=\"wp-element-caption\">fdisk delete partition<\/figcaption><\/figure>\n<\/div>\n\n\n<p>2.6 Create the new partition using the &#8220;n&#8221; command. We kept the default values and did not remove the ext4 signature.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"248\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/26n-1024x248.png\" alt=\"\" class=\"wp-image-421\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/26n-1024x248.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/26n-300x73.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/26n-768x186.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/26n-624x151.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/26n.png 1388w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>2.7 Now you need to write the new partition scheme to the disk using the &#8220;w&#8221; command.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/27w.png\" alt=\"\" class=\"wp-image-418\" width=\"413\" height=\"114\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/27w.png 706w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/27w-300x83.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/27w-624x173.png 624w\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" \/><figcaption class=\"wp-element-caption\">Write the partition scheme<\/figcaption><\/figure>\n<\/div>\n\n\n<p>2.8 Now check that the modifications have been saved, using <em>lsblk<\/em>.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>lsblk<\/code><\/pre><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"329\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/281-1024x329.png\" alt=\"\" class=\"wp-image-410\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/281-1024x329.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/281-300x96.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/281-768x247.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/281-624x201.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/281.png 1026w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">lsblk output (the partition shows the full space)<\/figcaption><\/figure>\n<\/div>\n\n\n<p>You will notice that the filesystem still does not yet see the whole space that is available. Use <em>df -h<\/em>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"259\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/282-1024x259.png\" alt=\"\" class=\"wp-image-416\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/282-1024x259.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/282-300x76.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/282-768x194.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/282-624x158.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/282.png 1154w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Output of df -h (the file system does not reflect the whole available space)<\/figcaption><\/figure>\n<\/div>\n\n\n<p>So let&#8217;s resize the file system inside the partition <em>sdb1<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Resize the file system<\/h2>\n\n\n\n<p>Run the <em>resize2fs<\/em> command on the newly created partition.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>resize2fs \/dev\/sdb1<\/code><\/pre><\/div>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"132\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/31-1024x132.png\" alt=\"\" class=\"wp-image-413\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/31-1024x132.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/31-300x39.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/31-768x99.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/31-624x81.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/31.png 1144w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Output of resize2fs \/dev\/sdb1<\/figcaption><\/figure>\n<\/div>\n\n\n<p><em>df<\/em> -h now reflects the changes:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"260\" src=\"https:\/\/gilbert.busana.lu\/wp-content\/uploads\/2023\/05\/32-1024x260.png\" alt=\"\" class=\"wp-image-412\" srcset=\"https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/32-1024x260.png 1024w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/32-300x76.png 300w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/32-768x195.png 768w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/32-624x159.png 624w, https:\/\/www.homeserver.lu\/wp-content\/uploads\/2023\/05\/32.png 1156w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">output of df -h (the file system now uses all available space)<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Additional links<\/h2>\n\n\n\n<p>If you need further information on this topic, consult the following webpages:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/pve.proxmox.com\/wiki\/Resize_disks\" target=\"_blank\">Proxmox Wiki: Resize disks<\/a><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.wundertech.net\/how-to-increase-vm-disk-size-in-proxmox\/\" target=\"_blank\">How to Increase VM Disk Size in Proxmox<\/a><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.msp360.com\/resources\/blog\/linux-resize-partition\/\" target=\"_blank\">Resize partitions in Linux<\/a><br><a href=\"https:\/\/superuser.com\/questions\/971000\/why-df-vs-lsblk-command-have-different-results\" target=\"_blank\" rel=\"noreferrer noopener\">W<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/superuser.com\/questions\/971000\/why-df-vs-lsblk-command-have-different-results\" target=\"_blank\">hy df and lsblk command have different results?<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will guide you in increasing the space of your virtual disk. Three steps are required:1. increase the VM disk size in Proxmox2. change the partition table to reflect the changes in Ubuntu3. resize your file system in Ubuntu 1. Resizing VM disk size in Proxmox 1.1 Open the Proxmox webinterface, select the VM [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8,28],"tags":[],"class_list":["post-382","post","type-post","status-publish","format-standard","hentry","category-proxmox","category-vm"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=382"}],"version-history":[{"count":60,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/382\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}