Enlarging the root or var partition

This article describes how to increase the size of the root (/) or var (/var) partition when Airlock Gateway is operated on virtualized platforms or cloud instances.

Supported scenarios

  • Enlarging an LVM partition after hypervisor disk growth
  • Reallocating space from /var to / (root) on LVM
  • Enlarging partitions on non-LVM cloud images
  • Enlarging an LVM partition using a new virtual disk

Preconditions and safety

  • Back up your configuration and take a VM snapshot where possible.
  • Expect a reboot for some paths.
  • For online rescan after hypervisor resize, use the following command:
  •  
    Terminal box
    echo 1 > /sys/class/block/sda/device/rescan
  • For non-LVM cloud images, only partition/filesystem growth is applicable.
  • Ensure the filesystem you intend to shrink has enough free space. The amount to be reallocated must be smaller than the available free space on /var to ensure the shrink can succeed.
  • Shrinks may require downtime and an fsck.

Enlarging an LVM partition after hypervisor disk growth

  1. Identify the LVM partition to grow (EFI vs. BIOS may differ). On most installations, the target is the last partition with the lvm flag set (e.g., /dev/sda3):
  2.  
    Terminal box
    parted /dev/sda print
  3. Grow the partition to the new end of disk:
  4.  
    Terminal box
    parted /dev/sda resizepart 3 100%
  5. Refresh the PV to use the new partition size:
  6.  
    Terminal box
    pvresize /dev/sda3
  7. Choose one of the following, depending on which partition you need to enlarge.
  8. To enlarge /var:

  9.  
    Terminal box
    lvresize --resizefs /dev/vg.01/lv_var /dev/sda3
  10. To enlarge / (root):

  11.  
    Terminal box
    lvresize --resizefs /dev/vg.01/lv_root /dev/sda3
  12. Verify the result by checking the LV sizes with lvdisplay and confirming the updated filesystem usage with df -h:
  13.  
    Terminal box
    lsblk
    lvdisplay /dev/vg.01/lv_var
    df -h /
    df -h /var

Reallocating space from /var to / (root) on LVM

Before starting, ensure that all services using the /var partition are stopped. The /var partition must be unmounted before the shrink operation. Perform the following steps on the system console, as network access is not available in single-user mode.

  1. Switch to single-user mode:
  2.  
    Terminal box
    init 1
  3. Unmount the /var partition:
  4. Determine how much space should be reallocated from /var to / (e.g., 2 GB).
  5. Shrink the /var LV and its filesystem by that amount:
  6.  
    Terminal box
    lvresize --resizefs --size -2G /dev/vg.01/lv_var
  7. Note: If fsck reports issues that it cannot fix, resolve them before retrying.

  8. Extend the root LV and its filesystem by the same amount:
  9.  
    Terminal box
    lvresize --resizefs --size +2G /dev/vg.01/lv_root
  10. Reboot the system to restart all services and ensure stable operation:
  11.  
    Terminal box
    reboot
  12. Verify the result by checking the LV sizes with lvdisplay and confirming the updated filesystem usage with df -h:
  13.  
    Terminal box
    lvdisplay /dev/vg.01/lv_var /dev/vg.01/lv_root
    df -h / /var

Enlarging partitions on non-LVM cloud images

  1. Grow the partition to use the new end of disk (e.g., the first partition):
  2.  
    Terminal box
    parted /dev/sda resizepart 1 100%
  3. Grow the filesystem:
  4.  
    Terminal box
    resize2fs /dev/sda1
  5. Verify the result by inspecting the partition layout with lsblk and confirming the updated filesystem usage with df -h:
  6.  
    Terminal box
    lsblk
    df -h

Enlarging an LVM partition using a new virtual disk

In the following example commands, the newly added disk is identified by the device name /dev/sdb. On your system, the device name may differ (e.g., /dev/vdb, /dev/nvme0n1, or similar). Adjust the commands accordingly.

  1. Create a new PV and extend the existing VG:
  2.  
    Terminal box
    pvcreate /dev/sdb
    vgextend vg.01 /dev/sdb
  3. Extend the target LV and its filesystem by directly consuming the new PV choosing one of the following two options, depending on which partition you want to enlarge.
    • To enlarge /var:
    •  
      Terminal box
      lvresize --resizefs /dev/vg.01/lv_var /dev/sdb
    • To enlarge / (root):
    •  
      Terminal box
      lvresize --resizefs /dev/vg.01/lv_root /dev/sdb
  4. Alternatively, you can also specify the amount of additional space to allocate to the target LV and its filesystem (e.g., as in the following, 50 GB).

    • To enlarge /var:
    •  
      Terminal box
      lvextend -r -L +50G /dev/vg.01/lv_var
    • To enlarge / (root):
    •  
      Terminal box
      lvextend -r -L +50G /dev/vg.01/lv_root
  5. Verify the result by checking the LV sizes with lvdisplay and confirming the updated filesystem usage with df -h.
  6.  
    Terminal box
    pvs
    vgs
    lvs
    df -h / /var