{"id":9883,"date":"2026-08-04T17:17:56","date_gmt":"2026-08-04T16:17:56","guid":{"rendered":"https:\/\/www.kevinmaschke.com\/?p=9883"},"modified":"2026-08-04T17:17:58","modified_gmt":"2026-08-04T16:17:58","slug":"expand-linux-vm-disk-filesystem-without-rebooting","status":"publish","type":"post","link":"https:\/\/www.kevinmaschke.com\/en\/expand-linux-vm-disk-filesystem-without-rebooting\/","title":{"rendered":"How to Expand a Linux VM Disk and Filesystem Without Rebooting"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Ever found yourself in the position were you were running out of space on a Linux server and needed to expand the storage but couldn\u2019t reboot the server? This article aims to explain <strong>how to increase the size of the <code>root<\/code> partition without rebooting<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Expanding the virtual disk is usually easy<\/strong>, but making the operating system use that additional space requires changes inside the guest. The good news is that <strong>most modern <a href=\"https:\/\/www.kevinmaschke.com\/en\/tag\/linux-en\/\" data-type=\"post_tag\" data-id=\"1695\">Linux<\/a> distributions support online filesystem expansion<\/strong>, allowing you to increase available storage without rebooting the server or interrupting running applications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide explains the general process and covers the most common Linux VM storage layouts across platforms such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>KVM \/ QEMU<\/li>\n\n\n\n<li><a href=\"https:\/\/www.kevinmaschke.com\/en\/tag\/vmware-en\/\" data-type=\"post_tag\" data-id=\"568\">VMware<\/a> ESXi<\/li>\n\n\n\n<li>Microsoft Hyper-V<\/li>\n\n\n\n<li>Xen<\/li>\n\n\n\n<li><a href=\"https:\/\/www.kevinmaschke.com\/en\/tag\/virtualbox-en\/\" data-type=\"post_tag\" data-id=\"566\">VirtualBox<\/a><\/li>\n\n\n\n<li>Cloud providers using VirtIO, SCSI, or NVMe disks<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The exact commands depend on your disk layout, filesystem, and storage technology.<\/p>\n\n\n\n<h2 id=\"understanding-the-storage-stack\" class=\"wp-block-heading\">Understanding the Storage Stack of a Linux VM<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is important to understand where the available space exists. A virtual machine disk has multiple layers:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Hypervisor\n    |\n    \u2193\nVirtual Disk (VMDK\/QCOW2\/VHDX\/VHD)\n    |\n    \u2193\nLinux Block Device (\/dev\/sda, \/dev\/vda, \/dev\/nvme0n1)\n    |\n    \u2193\nPartition \/ LVM \/ RAID\n    |\n    \u2193\nFilesystem (ext4, XFS, Btrfs)\n    |\n    \u2193\nMounted Directory (\/)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Increasing the virtual disk only changes the first layer. For example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Before<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Virtual disk: 50GB\n\n\/dev\/vda\n\u2514\u2500\u2500 \/dev\/vda1\n        \u2514\u2500\u2500 ext4 filesystem (50GB)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>After<\/strong> expanding the disk:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Virtual disk: 100GB\n\n\/dev\/vda\n\u2514\u2500\u2500 \/dev\/vda1\n        \u2514\u2500\u2500 ext4 filesystem (50GB)\n\nUnused space: 50GB<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The additional storage is not automatically available. The partition and filesystem still need to be expanded before Linux can use the extra capacity.<\/p>\n\n\n\n<h2 id=\"pre-requisites\" class=\"wp-block-heading\">Pre-requisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before making any changes make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Administrative access to the virtual machine hypervisor.<\/li>\n\n\n\n<li>Permission to resize the virtual disk on the hypervisor. <\/li>\n\n\n\n<li>SSH access to the virtual machine. <\/li>\n\n\n\n<li>A recent snapshot or backup. <\/li>\n\n\n\n<li>Knowledge of the current storage layout.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"1-check-the-current-disk-layout\" class=\"wp-block-heading\">1. Check the Current Disk Layout<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Identify how the system is currently configured<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Start with <code>lsblk<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lsblk\n\nNAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS\nvda    252:0    0   50G  0 disk\n\u251c\u2500vda1 252:1    0    1G  0 part \/boot\n\u2514\u2500vda2 252:2    0   49G  0 part \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This shows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The disk (<code>vda<\/code>) is 50GB.<\/li>\n\n\n\n<li>The root partition (<code>vda2<\/code>) is only 49GB.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Check filesystem usage:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# df -h\n\nFilesystem      Size  Used Avail Use% Mounted on\n\/dev\/vda2        49G   43G  4.0G  92% \/\n\/dev\/vda1       974M  120M  854M  13% \/boot<\/pre>\n\n\n\n<h2 id=\"2-expand-the-virtual-disk\" class=\"wp-block-heading\">2. Expand the Virtual Disk<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>first step is done at the hypervisor<\/strong> level. Increase the virtual disk size to the desired final capacity. For example, if the current disk is 50GB and you need an additional 50GB, resize the virtual disk to 100GB.<\/p>\n\n\n\n<div data-wp-context=\"{ &quot;autoclose&quot;: true, &quot;accordionItems&quot;: [] }\" data-wp-interactive=\"core\/accordion\" role=\"group\" class=\"wp-block-accordion is-layout-flow wp-block-accordion-is-layout-flow\">\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-1&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading has-background\" style=\"background-color:#3e3e8324\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-1-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" data-wp-on--keydown=\"actions.handleKeyDown\" id=\"accordion-item-1\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><span class=\"wp-block-accordion-heading__toggle-title\">VMware<\/span><\/button><\/h3>\n\n\n\n<div inert aria-labelledby=\"accordion-item-1\" data-wp-bind--inert=\"!state.isOpen\" id=\"accordion-item-1-panel\" role=\"region\" class=\"wp-block-accordion-panel has-background is-layout-flow wp-block-accordion-panel-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<p class=\"wp-block-paragraph\">Increase the disk size:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Virtual Machine \u2192 Edit Settings \u2192 Hard Disk \u2192 Increase Capacity<\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-2&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading has-background\" style=\"background-color:#3e3e8324\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-2-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" data-wp-on--keydown=\"actions.handleKeyDown\" id=\"accordion-item-2\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><span class=\"wp-block-accordion-heading__toggle-title\">Microsoft Hyper-V<\/span><\/button><\/h3>\n\n\n\n<div inert aria-labelledby=\"accordion-item-2\" data-wp-bind--inert=\"!state.isOpen\" id=\"accordion-item-2-panel\" role=\"region\" class=\"wp-block-accordion-panel has-background is-layout-flow wp-block-accordion-panel-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<p class=\"wp-block-paragraph\">Powershell:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Resize-VHD <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\n  -Path &quot;LinuxServer01.vhdx&quot; <\/code>\n  -SizeBytes 100GB<\/pre>\n<\/div>\n<\/div>\n\n\n\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-3&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading has-background\" style=\"background-color:#3e3e8324\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-3-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" data-wp-on--keydown=\"actions.handleKeyDown\" id=\"accordion-item-3\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><span class=\"wp-block-accordion-heading__toggle-title\">VirtualBox (new total size in MB)<\/span><\/button><\/h3>\n\n\n\n<div inert aria-labelledby=\"accordion-item-3\" data-wp-bind--inert=\"!state.isOpen\" id=\"accordion-item-3-panel\" role=\"region\" class=\"wp-block-accordion-panel has-background is-layout-flow wp-block-accordion-panel-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">VBoxManage modifymedium disk LinuxServer01.vdi --resize 102400<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Because:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">100GB \u00d7 1024MB = 102400MB<\/pre>\n<\/div>\n<\/div>\n\n\n\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-4&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading has-background\" style=\"background-color:#3e3e8324\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-4-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" data-wp-on--keydown=\"actions.handleKeyDown\" id=\"accordion-item-4\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><span class=\"wp-block-accordion-heading__toggle-title\">KVM\/QEMU<\/span><\/button><\/h3>\n\n\n\n<div inert aria-labelledby=\"accordion-item-4\" data-wp-bind--inert=\"!state.isOpen\" id=\"accordion-item-4-panel\" role=\"region\" class=\"wp-block-accordion-panel has-background is-layout-flow wp-block-accordion-panel-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<p class=\"wp-block-paragraph\"><code>qemu-img resize<\/code> is different. Without a <code>+<\/code> prefix it sets the <strong>final size<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">qemu-img resize linux-server.qcow2 100G<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With a <code>+<\/code> prefix it adds space:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">qemu-img resize linux-server.qcow2 +50G<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Both result in:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">50GB + 50GB = 100GB<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For a running VM:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">virsh blockresize linux-server \/var\/lib\/libvirt\/images\/linux-server.qcow2 100G\n<\/pre>\n<\/div>\n<\/div>\n\n\n\n<div data-wp-class--is-open=\"state.isOpen\" data-wp-context=\"{ &quot;id&quot;: &quot;accordion-item-5&quot;, &quot;openByDefault&quot;: false }\" data-wp-init=\"callbacks.initAccordionItems\" data-wp-on-window--hashchange=\"callbacks.hashChange\" class=\"wp-block-accordion-item is-layout-flow wp-block-accordion-item-is-layout-flow\">\n<h3 class=\"wp-block-accordion-heading has-background\" style=\"background-color:#3e3e8324\"><button aria-expanded=\"false\" aria-controls=\"accordion-item-5-panel\" data-wp-bind--aria-expanded=\"state.isOpen\" data-wp-on--click=\"actions.toggle\" data-wp-on--keydown=\"actions.handleKeyDown\" id=\"accordion-item-5\" type=\"button\" class=\"wp-block-accordion-heading__toggle\"><span class=\"wp-block-accordion-heading__toggle-icon\" aria-hidden=\"true\">+<\/span><span class=\"wp-block-accordion-heading__toggle-title\">Xen<\/span><\/button><\/h3>\n\n\n\n<div inert aria-labelledby=\"accordion-item-5\" data-wp-bind--inert=\"!state.isOpen\" id=\"accordion-item-5-panel\" role=\"region\" class=\"wp-block-accordion-panel has-background is-layout-flow wp-block-accordion-panel-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<p class=\"wp-block-paragraph\">The exact command depends on the Xen storage backend. For example, with an LVM-backed virtual disk:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lvextend -L +50G \/dev\/vg\/vm-disk<\/pre>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">At this point, <strong>the hypervisor disk is larger, but Linux has not necessarily detected the change<\/strong> yet.<\/p>\n\n\n\n<h2 id=\"3-rescan-the-disk-from-linux\" class=\"wp-block-heading\">3. Rescan the Disk From Linux<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After resizing the virtual disk, Linux may not immediately detect the additional capacity.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lsblk\n\nNAME   SIZE TYPE MOUNTPOINTS\nvda     50G disk\n\u251c\u2500vda1   1G part \/boot\n\u2514\u2500vda2  49G part \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The disk is still showing the old size. So we need to rescan the device.<\/p>\n\n\n\n<h3 id=\"rescan-depending-on-the-device-type\" class=\"wp-block-heading\">Rescan depending on the device type.<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For <strong>SCSI<\/strong> disks:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo1 > \/sys\/class\/block\/sda\/device\/rescan\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <strong>VirtIO<\/strong> disks:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo1 > \/sys\/class\/block\/vda\/device\/rescan\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For <strong>NVMe<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nvme rescan\n<\/pre>\n\n\n\n<h3 id=\"verify\" class=\"wp-block-heading\">Verify<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the new size after scanning the device.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lsblk\n\nNAME   SIZE TYPE MOUNTPOINTS\nvda    100G disk\n\u251c\u2500vda1   1G part \/boot\n\u2514\u2500vda2  49G part \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Linux now sees the additional storage. But the partition has not increased yet.<\/p>\n\n\n\n<h2 id=\"4-determine-your-storage-type\" class=\"wp-block-heading\">4. Determine Your Storage Type<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The expansion procedure depends on how the disk is configured.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Common layouts include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standard partitions<\/li>\n\n\n\n<li>LVM<\/li>\n\n\n\n<li>Software RAID<\/li>\n\n\n\n<li>ZFS<\/li>\n\n\n\n<li>Encrypted volumes<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The most common Linux setups are standard partitions and LVM.<\/p>\n\n\n\n<h3 id=\"traditional-partitions\" class=\"wp-block-heading\">Traditional partitions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/dev\/vda1 \u2192 \/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tools:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>fdisk<\/li>\n\n\n\n<li>parted<\/li>\n\n\n\n<li>resize2fs<\/li>\n\n\n\n<li>xfs_growfs<\/li>\n<\/ul>\n\n\n\n<h3 id=\"lvm\" class=\"wp-block-heading\">LVM<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/dev\/vda\n \u2514\u2500\u2500 partition\n      \u2514\u2500\u2500 volume group\n            \u2514\u2500\u2500 logical volume \/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Tools:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pvresize<\/li>\n\n\n\n<li>lvextend<\/li>\n\n\n\n<li>resize2fs<\/li>\n\n\n\n<li>xfs_growfs<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">LVM is usually the easiest layout to expand.<\/p>\n\n\n\n<h3 id=\"other-storage-technologies\" class=\"wp-block-heading\">Other storage technologies<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some environments use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>RAID<\/li>\n\n\n\n<li>ZFS<\/li>\n\n\n\n<li>Btrfs<\/li>\n\n\n\n<li>encrypted volumes<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These require their own expansion procedures.<\/p>\n\n\n\n<h2 id=\"5-expanding-an-lvm-root-filesystem\" class=\"wp-block-heading\">5. Expanding an LVM Root Filesystem<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">LVM is common in enterprise Linux distributions and many cloud images. <\/p>\n\n\n\n<h3 id=\"check-lvm-disk\" class=\"wp-block-heading\">Check LVM disk<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether LVM is being used:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lsblk\n\nNAME                 SIZE TYPE MOUNTPOINTS\nvda                   50G disk\n\u2514\u2500vda2                50G part\n  \u2514\u2500ubuntu--vg-root   50G lvm  \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After expanding the virtual disk to 100GB and rescanning:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lsblk\n\nNAME                 SIZE TYPE MOUNTPOINTS\nvda                  100G disk\n\u2514\u2500vda2               100G part\n  \u2514\u2500ubuntu--vg-root   50G lvm  \/<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The disk and partition are now larger, but the logical volume still uses the original 50GB.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check volume groups:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# vgdisplay\n\n  VG Name               ubuntu-vg\n  VG Size               98.00 GiB\n  Alloc PE \/ Size       49.00 GiB\n  Free PE \/ Size        49.00 GiB<\/pre>\n\n\n\n<h3 id=\"resize-the-physical-volume\" class=\"wp-block-heading\">Resize the physical volume<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# pvresize \/dev\/vda2\n\nPhysical volume \"\/dev\/vda2\" changed\n1 physical volume(s) resized or updated<\/pre>\n\n\n\n<h3 id=\"extend-the-logical-volume\" class=\"wp-block-heading\">Extend the logical volume<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# lvextend -l +100%FREE \/dev\/ubuntu-vg\/root\n\nSize of logical volume ubuntu-vg\/root changed from 49.00 GiB to 98.00 GiB.\nLogical volume ubuntu-vg\/root successfully resized.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lvextend -L +50G \/dev\/mapper\/root<\/pre>\n\n\n\n<h3 id=\"grow-the-filesystem\" class=\"wp-block-heading\">Grow the filesystem<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For ext4:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# resize2fs \/dev\/ubuntu-vg\/root\n\nresize2fs 1.46.5 (30-Dec-2021)\nFilesystem at \/dev\/ubuntu-vg\/root is mounted on \/; on-line resizing required\nThe filesystem on \/dev\/ubuntu-vg\/root is now 25690112 (4k) blocks long.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For XFS:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# xfs_growfs \/\n\ndata blocks changed from 12845056 to 25690112<\/pre>\n\n\n\n<h3 id=\"verify-1\" class=\"wp-block-heading\">Verify<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# df -h \/\n\nFilesystem                   Size Used Avail Use%\n\/dev\/mapper\/ubuntu--vg-root   98G  43G   51G  46% \/<\/pre>\n\n\n\n<h2 id=\"6-expanding-a-traditional-partition\" class=\"wp-block-heading\">6. Expanding a Traditional Partition<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some Linux installations use a simple partition layout without LVM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@server01:~# fdisk -l \/dev\/vda\n\nDevice      Start     End        Sectors    Size\n\/dev\/vda1   2048      96471039   96468991   46G\n\/dev\/vda2   96471040  104857599  8386559    4G<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The important value is the Start sector.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When recreating the partition, this start sector must remain identical. A mistake here can corrupt the filesystem and make it inaccessible.<\/p>\n\n\n\n<h3 id=\"disable-swap-if-required\" class=\"wp-block-heading\">Disable Swap (If Required)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If swap is a dedicated partition (\u26a0\ufe0f Make sure that your system can stay online for a bit without swap):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">swapoff -a<\/pre>\n\n\n\n<h3 id=\"delete-partitions\" class=\"wp-block-heading\">Delete Partitions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Reconfigure the partitions using <code>fdisk<\/code>. First we delete the two existing partitions. Run <code>fdisk \/dev\/vda<\/code> and then use <code>d<\/code> to delete partition 2, and then delete partition 1:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@prod-deb-01:~# fdisk \/dev\/vda\n\nCommand (m for help): d\nPartition number (1,2, default 2):\n\nPartition 2 has been deleted.\n\nCommand (m for help): d\nSelected partition 1\nPartition 1 has been deleted.\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f <strong>Important:<\/strong> This process modifies the partition table. The existing partitions are deleted and recreated with new boundaries. The data is preserved only because the partitions are recreated with the exact same starting sectors. Always verify the start sector before writing changes and ensure you have a working backup or snapshot.<\/p>\n\n\n\n<h3 id=\"recreate-partitions\" class=\"wp-block-heading\">Recreate Partitions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Then we recreate our partitions. Since we had 4GB of swap space we want to keep at least the same amount for the new swap partition (you could increase it too if you wanted).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First recreate <code>\/dev\/vda1<\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Press <code>n<\/code> to create a new partition.<\/li>\n\n\n\n<li>Enter <code>p<\/code> to create a primary partition.<\/li>\n\n\n\n<li>We can press <code>Enter<\/code> to accept the default value of 2048 for the first sector.<\/li>\n\n\n\n<li>Then enter a size for the partition. You can enter a value in GB, so if we are increasing the disk to 100 GB, we subtract our 4 GB for swap, and enter <code>+96G<\/code> for 96 GB.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Command (m for help): n\nPartition type\n   p   primary (0 primary, 0 extended, 4 free)\n   e   extended (container for logical partitions)\nSelect (default p): p\nPartition number (1-4, default 1): 1\nFirst sector (2048-209715199, default 2048):\nLast sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199): +96G\n\nCreated a new partition 1 of type 'Linux' and of size 96 GiB.\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, we recreate the swap partition:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Press <code>n<\/code> and then <code>p<\/code> to create a new primary partition.<\/li>\n\n\n\n<li>Press <code>Enter<\/code> to accept the default value for &#8220;First sector&#8221;.<\/li>\n\n\n\n<li>We can also press <code>Enter<\/code> again to accept the default value for &#8220;Last sector&#8221;.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Command (m for help): n\nPartition type\n   p   primary (1 primary, 0 extended, 3 free)\n   e   extended (container for logical partitions)\nSelect (default p): p\nPartition number (2-4, default 2): 2\nFirst sector (201328640-209715199, default 201328640):\nLast sector, +sectors or +size{K,M,G,T,P} (201328640-209715199, default 209715199):\n\nCreated a new partition 2 of type 'Linux' and of size 4 GiB.\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Since <strong>this partition is going to be used for swap space<\/strong>, we need to change the partition type using <code>fdisk<\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Press <code>t<\/code>.<\/li>\n\n\n\n<li>We then press 2 to select the second partition.<\/li>\n\n\n\n<li>If you want to see the list of available partition types, press <code>L<\/code>, otherwise enter <code>82<\/code> to select <code>Linux swap \/ Solaris<\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Command (m for help): t\nPartition number (1,2, default 2): 2\nPartition type (type L to list all types): L\n\n 0  Empty           24  NEC DOS         81  Minix \/ old Lin bf  Solaris\n 1  FAT12           27  Hidden NTFS Win 82  Linux swap \/ So c1  DRDOS\/sec (FAT-\n 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS\/sec (FAT-\n 3  XENIX usr       3c  PartitionMagic  84  OS\/2 hidden or  c6  DRDOS\/sec (FAT-\n 4  FAT16 &lt;32M      40  Venix 80286     85  Linux extended  c7  Syrinx\n 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data\n 6  FAT16           42  SFS             87  NTFS volume set db  CP\/M \/ CTOS \/ .\n 7  HPFS\/NTFS\/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility\n 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt\n 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access\n a  OS\/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R\/O\n b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD\/OS          e4  SpeedStor\n c  W95 FAT32 (LBA) 52  CP\/M            a0  IBM Thinkpad hi ea  Rufus alignment\n e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs\n f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT\n10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12\/16\/\n11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux\/PA-RISC b\n12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor\n14  Hidden FAT16 &lt;3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor\n16  Hidden FAT16    63  GNU HURD or Sys af  HFS \/ HFS+      f2  DOS secondary\n17  Hidden HPFS\/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS\n18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE\n1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto\n1c  Hidden W95 FAT3 75  PC\/IX           bc  Acronis FAT32 L fe  LANstep\n1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT\nPartition type (type L to list all types): 82\n\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>fdisk<\/code> should informs us that we have changed the partition type:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Changed type of partition 'Linux' to 'Linux swap \/ Solaris'.\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After that, we save using the <code>w<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Command (m for help): w\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You may get a message like this before exiting:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">The partition table has been altered.\nCalling ioctl() to re-read partition table.\nRe-reading the partition table failed.: Device or resource busy\n\nThe kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).\n<\/pre>\n\n\n\n<h3 id=\"refresh-the-kernel-partition-table-without-rebooting\" class=\"wp-block-heading\">Refresh the Kernel Partition Table Without Rebooting<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We can tell the kernel about the new partitions using <code>partprobe<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@prod-deb-01:~# partprobe\n<\/pre>\n\n\n\n<h3 id=\"resize-the-filesystem\" class=\"wp-block-heading\">Resize the Filesystem<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once the partition has been expanded:<\/p>\n\n\n\n<h4 id=\"ext-4\" class=\"wp-block-heading\">ext4<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">resize2fs \/dev\/vda2\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">resize2fs 1.47.0\nFilesystem at \/dev\/vda2 is mounted on \/; on-line resizing required\nThe filesystem on \/dev\/vda2 is now 39062500 blocks long.\n<\/pre>\n\n\n\n<h4 id=\"xfs\" class=\"wp-block-heading\">XFS<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">xfs_growfs \/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">meta-data=\/dev\/vda2\ndata blocks changed from 12800000 to 39062500\n<\/pre>\n\n\n\n<h4 id=\"btrfs\" class=\"wp-block-heading\">BTRFS<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">btrfs filesystem resize max \/<\/pre>\n\n\n\n<h3 id=\"initialise-new-swap-location-of-dev-vda-2\" class=\"wp-block-heading\">Initialise new swap location of <code>\/dev\/vda2<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Since we recreated the <code>swap<\/code> partition, we need to initialise it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@prod-deb-01:~# mkswap \/dev\/vda2\nSetting up swapspace version 1, size = 4193276 KiB\nno label, UUID=c55c25a2-a386-4653-8455-4d9030586dd2\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, we edit <code>\/etc\/fstab<\/code> and replace the old <code>UUID<\/code> with the new one returned by the <code>mkswap<\/code> command. The line to change has no value for &#8220;mount point&#8221; and has &#8220;type&#8221; set to swap.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \/etc\/fstab: static file system information.\n#\n# Use 'blkid' to print the universally unique identifier for a\n# device; this may be used with UUID= as a more robust way to name devices\n# that works even if disks are added and removed. See fstab(5).\n#\n# &lt;file system> &lt;mount point>   &lt;type>  &lt;options>       &lt;dump>  &lt;pass>\nUUID=332f8fb5-ff1f-4297-b512-f2c93a277296 \/               ext4    errors=remount-ro 0       1\n\/dev\/fd0        \/media\/floppy0  auto    rw,user,noauto,exec,utf8 0       0\nUUID=c55c25a2-a386-4653-8455-4d9030586dd2       none    swap    sw      0       0\n<\/pre>\n\n\n\n<h4 id=\"re-enable-swap\" class=\"wp-block-heading\">Re-Enable <code>swap<\/code><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">After editing <code>\/etc\/fstab<\/code>, we need to enable swap again:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@prod-deb-01:~# swapon -a\n<\/pre>\n\n\n\n<h2 id=\"7-expanding-zfs-storage\" class=\"wp-block-heading\">7. Expanding ZFS Storage<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">ZFS uses a different approach. After increasing the virtual disk:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the pool:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">zpool status<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expand the device:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">zpool online -e pool_name device_name<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">zpool list<\/pre>\n\n\n\n<h2 id=\"8-verify-the-expansion\" class=\"wp-block-heading\">8. Verify the Expansion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the filesystem:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">df-h \/\n\nFilesystem      Size Used Avail Use%\n\/dev\/vda2       96G   43G   49G47% \/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the partition layout:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lsblk\n\nNAME   SIZE TYPE MOUNTPOINTS\nvda    100G disk\n\u251c\u2500vda1   1G part \/boot\n\u2514\u2500vda2  96G part \/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Confirm uptime:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">uptime14:32:51 up147 days,4:21,2 users, load average:0.05,0.02,0.00\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The server has been expanded without rebooting.<\/p>\n\n\n\n<h2 id=\"when-a-reboot-may-still-be-required\" class=\"wp-block-heading\">When a Reboot May Still Be Required<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Online expansion works on most modern Linux systems, but some situations may require downtime:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The kernel cannot reread the partition table.<\/li>\n\n\n\n<li>The root partition layout changes unexpectedly.<\/li>\n\n\n\n<li>Older filesystems are being used.<\/li>\n\n\n\n<li>Encrypted disks require additional steps.<\/li>\n\n\n\n<li>RAID metadata needs rebuilding.<\/li>\n\n\n\n<li>The hypervisor does not support online disk resizing.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. KVM \/ QEMU \/ libvirt<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>qemu-img<\/code> Documentation:<\/strong><a href=\"https:\/\/qemu-project.gitlab.io\/qemu\/tools\/qemu-img.html\" target=\"_blank\" rel=\"noreferrer noopener\">QEMU Utilities Documentation \u2013 <code>qemu-img<\/code><\/a>\n<ul class=\"wp-block-list\">\n<li>Covers offline disk creation and expansion syntax (<code>qemu-img resize<\/code>).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>virsh<\/code> Reference Manual:<\/strong><a href=\"https:\/\/www.libvirt.org\/manpages\/virsh.html\" target=\"_blank\" rel=\"noreferrer noopener\">libvirt Management Utilities \u2013 <code>virsh blockresize<\/code><\/a>\n<ul class=\"wp-block-list\">\n<li>Details how to resize a running virtual machine\u2019s block device via <code>virsh blockresize<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. VMware ESXi &amp; vSphere<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>VMware ESXi Disk Management Guide:<\/strong><a href=\"https:\/\/docs.vmware.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">VMware Docs \u2013 Increasing the Virtual Disk Size<\/a>\n<ul class=\"wp-block-list\">\n<li>Guides you through expanding capacity in vSphere\/ESXi Edit Settings.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. Microsoft Hyper-V<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Microsoft Learn PowerShell Module:<\/strong><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/module\/hyper-v\/resize-vhd?view=windowsserver2025-ps\" target=\"_blank\" rel=\"noreferrer noopener\">Microsoft Learn \u2013 <code>Resize-VHD<\/code><\/a>\n<ul class=\"wp-block-list\">\n<li>Details syntax and parameters for expanding <code>.vhdx<\/code> files online and offline.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. VirtualBox<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Oracle VirtualBox Manual:<\/strong><a href=\"https:\/\/www.google.com\/search?q=https:\/\/www.virtualbox.org\/manual\/ch08.html%23vboxmanage-modifymedium\" target=\"_blank\" rel=\"noreferrer noopener\">Oracle VM VirtualBox \u2013 <code>VBoxManage modifymedium<\/code><\/a>\n<ul class=\"wp-block-list\">\n<li>Official CLI reference for resizing virtual disk images (<code>--resize<\/code> parameter).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. Xen \/ XenServer \/ XCP-ng<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>XenServer Official Documentation:<\/strong><a href=\"https:\/\/docs.xenserver.com\/en-us\/xenserver\/8\/storage\/manage.html\" target=\"_blank\" rel=\"noreferrer noopener\">XenServer Storage Management Guide<\/a>\n<ul class=\"wp-block-list\">\n<li>Explains Virtual Disk Image (VDI) properties and storage repository expansion.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Xen Orchestra Documentation:<\/strong><a href=\"https:\/\/docs.xen-orchestra.com\/xo5\/manage_infrastructure\" target=\"_blank\" rel=\"noreferrer noopener\">Xen Orchestra Infrastructure &amp; Storage Management<\/a>\n<ul class=\"wp-block-list\">\n<li>Documentation for managing and resizing guest VDIs in modern Xen-based environments.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ever found yourself in the position were you were running out of space on a Linux server and needed to expand the storage but couldn\u2019t reboot the server? This article aims to explain how to &#8230;<\/p>\n","protected":false},"author":1,"featured_media":9895,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[410,207,412],"tags":[2943,2941,1695,2944,564,566,2817,568,2942],"class_list":["post-9883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","category-linux-en","category-virtualization","tag-hyper-v","tag-kvm","tag-linux-en","tag-storage","tag-ubuntu-en","tag-virtualbox-en","tag-virtualization","tag-vmware-en","tag-xen"],"acf":{"book_cover":null,"special_featured_image":null},"_links":{"self":[{"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/posts\/9883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/comments?post=9883"}],"version-history":[{"count":5,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/posts\/9883\/revisions"}],"predecessor-version":[{"id":9906,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/posts\/9883\/revisions\/9906"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/media\/9895"}],"wp:attachment":[{"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/media?parent=9883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/categories?post=9883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kevinmaschke.com\/en\/wp-json\/wp\/v2\/tags?post=9883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}