KB10120 - LINUX: Increase disc size

KB10120 - LINUX: Increase disc size

This describes how to increase the size of a disc inside a Linux machine (LVM). Maybe this is normal daily work for a Linux admin but I guess I will need this article once again in the future...


This article is for a single hard disc (a virtual one) that needs to be bigger than before... So the first step is to increase the size of this specific disc in Hyper-V or VMware or whatever Hypervisor.

After this you have to log in to the machine with root rights an do the following:

  1. The you have to identify the device name (In a single disc environment it should be "/dev/sda"
    Use the command "fdisk -l"
  2. Then you have to create a new primary partition with the command: "fdisk /dev/sda" (if you have to increase sdb change this command accordingly...)
    1. Press "p" to get the number of partitions
    2. Press "n" to create a new partition
    3. Press "p" to create a primary partition
    4. Press "Enter" two times to accept the given values
    5. Press the number for the next free partition number (if it’s the third partition press "3")
    6. Press "t" to select the system partition
    7. Press "Enter" or key in the number of a different partition then the given one
    8. Provide "8e" as hex code to change the partition to Linux LVM
    9. Press "w" to write the information back to the file system
  3. Reboot the machine
  4. With the command "fdisk -l" you should see the new partition
  5. Create a new physical volume "pvcreate /dev/sda3[4, 5, 6, 7, .... whatever the number of the new volume was]
  6. Determine the volume group name "vgdisplay | grep "VG Name""
  7. Determine the path "lvdisplay | grep Path"
  8. Add the new physical volume to the vgroup "vgextend -result from 6.- /dev/sda*"
  9. Extend the logical volume: "lvextend -l +100%FREE /dev/-result from 6.-/-result from 7.-"

Now it’s nearly done but with "df" you won’t see any free space so in the next step you have to expand the file system. To do this you have to determine the file system. You can do this with the command: "df -T"

  • Type: XFS
    xfs_growfs -filesystem path of the volume from the df -T command-
  • Type: EXT2
    ext2online -filesystem path of the volume from the df -T command-