WEIGEL FORUM
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login

    Live resize root partition on Linux Server (VM)

    Linux
    1
    1
    8
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DerMeldosD
      DerMeldos
      last edited by

      Most virtual hypervisors (like Proxmox or VMWare) allow resizing VM storage on the fly.
      However, if you don’t want to reboot your server while resizing, you can resize your root partition “live”.

      Assuming your drive has been already resized on the hypervisor side (e.g. from 20GB to 40GB), you need to follow the following steps to ensure the OS knows about the increased storage capacity.

      Step 1
      Check your current partition size and drive by using df -h and fdisk -l /dev/sda command (assuming your drive is sda):

      97d5c935-8d39-4add-8bf1-24621f9ebea7-image.png

      As you can see, the root partition / and the drive total capacity are around 20GB.

      Step 2
      Now you need to rescan your block device sda with the following command:

      $ echo 1 > /sys/block/sda/device/rescan

      And check again drive capacity by using fdisk -l /dev/sda command:

      b24b16af-ae18-40a2-ab32-9d470e7ae343-image.png

      Now your drive has 40GB capacity, but your root partition still uses only 20GB. To resize the root partition, you need to run fdisk /dev/sda:

      $ fdisk /dev/sda

      Now press “p” to print the current partition layout.

      This operation can be dangerous, so please follow the following steps with caution!

      Step 3
      Now delete your primary partition /dev/sda1 by pressing the d key.

      Step 4
      Create a new partition by pressing the n key and pressing 1 for the partition number.

      Step 5
      Use the default value of Fist sector and Last sector

      Step 6
      Do not remove the existing signature! Press n to avoid removal.

      Step 7
      : Now press the w key to save the partition table.

      6520b051-ab87-46e2-bd72-d3fc86e07c20-image.png

      Step 8
      Type resize2fs / command and check your current root patition capacity by using df -h:

      $ resize2fs /
      $ df -h

      c4645511-50e8-48cc-9f5f-01c0adb95a69-image.png

      Your root partition / has been now resized.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB | Contributors