Expanding Linux Partition
Written by:
Will Kruss
on
16 February 2023 04:57 PM
|
|
If your partition is GPT it should expand automatically upon ordering your disk upgrade. Know how to expand Linux Partition Note: This article is NOT for expanding SATA space. To expand SATA space please click here. If you are uncertain about doing this we are happy to do this for you, doing it incorrectly could permanently damage your data, please lodge a ticket with support. If you have upgraded your NVME/Flash space, you may also need to expand the partition to make that space usable. First, login to your VPS via SSH Type: df -h This will report a size for /dev/mapper/VolGroup00-LogVol00 slightly less than the size allocated (e.g. 9.8GB for a 10GB allocation). If this does not (e.g. you have upgraded to 20GB but it still shows 9.8GB) then you need to resize your partition Now you need to determine if your disks are set to GPT or MBR. To do that: Type: fdisk -l /dev/sda If it says: WARNING GPT at the start then you are trying to expand a GPT partition. If not, then your partition is MBR. If your partition is GPT it should have been expanded automatically upon ordering your disk upgrade. If it wasn't it's most likely your root password in our system doesn't match your current root password. In this case please update your stored password and then contact support to have your partition expanded. If your partition is MBR and /dev/sda4 is not listed then please continue. If /dev/sda4 is listed then you need to contact support to convert your disk type to GPT to support increasing your LVM partition. Expanding MBR Type: fdisk -l You will see a device list e.g.: Device Boot Start End Blocks Id System Take note of the last existing LVM partition (in this case /dev/sda2) We need to create a new partition, in our example, the new partition will be partition number 3 (e.g. /dev/sda3) Type: fdisk /dev/sda This will create the new partition. Now we have to set it to the correct mode, still in fdisk type: t We have now created the new partition and written it to the partition table.
You can do that by: 1. Rebooting the server 2. Running the command: # partx -a -v /dev/sdX Where sdX is the actual drive (sda, sdb, sdc, etc). The flag -v means "verbose output", -a means "Update all partitions". Once partitions re-synced, SSH back into the VPS (if required) and type: vgextend VolGroup00 /dev/sda3 (where 3 is the new partition number) This will perform an online resize of the logical volume adding the new partition to it, and thus expanding the disk space available. Once complete type: df -h The results should confirm the increase in available space. | |
|