Overview
This article demonstrates how to expand a Linux VM partition when the root drive has run out of space. The process involves increasing the virtual disk size in the hypervisor and then extending the partition within the Linux operating system to utilize the additional space.
In this article, we will show how to incorporate extra space into an existing Linux Partition.
This is used when a Linux-based virtual machine and the root drive have run out of space in an existing partition inside a single VM hard disc. To actually increase the space of the Linux root drive, we will perform a simple tweak inside the Linux OS to add extra space to the partition that needs it.
Steps
1. Shut down the VM from the Hypervisor
2. Right-click the VM and select Edit Settings, and change Hard Disk size to the desired size (90 in this example)
3. Start the VM from the hypervisor
4. Log in to the VM console as root
5. Execute the command below to check the disk space :
fdisk -l
| Note: The fdisk command provides disk partitioning functions and using it with the -l switch lists information about your disk partitions. |
6. Execute the command below to initialize the expanded space and mount it.
fdisk /dev/sda
The following will be prompted:
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.7. Enter ‘n’ in the next line to create a new partition.
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
8. Assign the partition number you wish based on your existing partition numbering.
9. In the next line, choose code ‘8e’ to select the LINUX OS
10. Next, enter ‘w’ to proceed further.
Created a new partition 3 of type 'Linux' and of size 74 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
11. Restart the VM and log back in as root
12. Type fdisk -l and you'll notice another partition is present.
13. Now we need to create physical & logical volumes. Execute the following command to create a physical volume.
pvcreate /dev/sda3
[root@tmplt-centos8 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.14. Execute the command below to get the name of the current Volume Group
vgdisplay
15. Execute the following command to extend the Volume Group with /dev/sda3
vgextend <VG NAME> /dev/sda3
vgextend cl /dev/sda3
16. Execute the following command to get the Logical Volume path.
lvdisplay
17. Execute the command below to extend the Logical Volume with /dev/sda3
lvextend <LV_PATH> /dev/sda3
lvextend /dev/cl/root /dev/sda3
18. Execute the following command to update the Logical Volume
xfs_growfs /dev/cl/root
19. Check for the disk space changes by running the following command: df -h
Comments
0 comments
Please sign in to leave a comment.