Expand LVM on Disk and Extend XFS Partition on CentOS 7.7

Mindwatering Incorporated

Author: Tripp W Black

Created: 07/30 at 10:10 AM

 

Category:
Linux
Configuration

Task:
Root mount on CentOS 7.7 has fallen below 3 GB free out of 14 GB. We need to expand the LV / logical volume to the additional disk space provided.


Prerequisites:
- Confirm the last back-up is good.
- Stop the app services running on the machine as needed.


Steps:
1. Attach the VM to the gparted ISO.
- In the vSphere web client, select the VM server and click Launch Remote Console.

- Click the CD icon, and choose CD/DVD (SATA) Settings. In the dialog, under This CD/DVD drive is configured to use the following, select the appropriate location for the GParted CD/ISO.
In our case, we switched from the local Mac CD/DVD ROM, via Choose a remote disk image, selected the appropriate datastore, opened an ISO folder, and selected the gparted-live-0.250-3.i686.iso, and clicked Open. Before closing the dialog, click the Connect At Power On checkbox.

Leave the Remote Console Running if desired. We need a terminal after the next step.

2. Shut down the VM, and expand the disk.
In the vSphere web client,
- Right click the VM and choose --> Power --> Restart Guest OS
- Right click the VM and choose Edit Settings
- Edit the appropriate disk. For us, the correct disk was Disk 1, our VM's "system disk", named /dev/sda.
In our case, we increased the size of the disk from 16 GB to 22 GB, clicked the OK button to save.

3. Use GPARTED to expand the LV.
Perform the following:
- At the GPARTED boot screen, click enter so you don't wait for the selection of which boot option.
- Click quickly through 3 times the keyboard and language settings to accept the US defaults.
- GPARTED automatically starts.

In the GPARTED program:
- In the upper right corner, select the disk. In our case the first disk /dev/sda, was already selected.
- Select the LVM.
- - If you see a Lock icon, choose Partition --> Deactivate on the file menu to unlock the partition.
- Click the Resize icon, and drag the right size to 100% of the space available. In our case we increased from 16 GB to 22 GB. Click the green Check button to Apply the change. Confirm successful in the dialog.
- Exit the program using the dark close icon or the Exit menu option.
- Click the icon to Reboot on the "desktop".
- Bring up the Remote Console and uncheck the Connect CD/DVD Drive, and the Connect at Power On checkboxes.
In addition, we change the ISO to use the local client CD/DVD ROM so that the VM is not bound to the ISO.

- If you took so long that the GPARTED boot screen is back on, just go to the vSphere web client and click the power option, Power --> Reset.

4. Confirm the VM started okay.
- The normal CentOS boot screen started?
- - Occasionally, the OS would want to run a check disk, if so let it, and wait.
- Login to the server once the login is available by terminal console or GUI, if installed.
- Confirm any service applications started okay.

5. Expand the Disk.
Open a terminal if you are not already staring at one.
$ sudo su
<enter the admin pwd>

Confirm the LVM shows the bigger size:
# pvscan
<view output>

Expand the LVM partition for the device mount to use 100% of the space now added:
# lvextend -l +100%FREE /dev/mapper/centos-root
<view output>

Confirm that space is available:
# lvs
<view output>

Verify the filesystem format is xfs:
# df -T
<view output>

Grow the LVM partition's filesystem. Note that you use the actual mount point, not the device for this command.
# xfs_growfs /
<view output>

Confirm:
# df -hP
<view output>



previous page