Disk expansion in CentOS 7 can be done in a few steps. The operation steps are given below:
Step 1: Checking the Disk Size.
The first step is to check the size of the disk you want to expand. This step allows you to proceed with the expansion process.
To check the disk size, use the following command:
df -h
This command shows the size and used space of all file systems.
Step 2: Expanding the Disk.
There are several methods for expanding a disk, but here we will explain how to expand a disk using (Logical Volume Manager).
Expand the virtual machine’s disk on the host machine, then use LVM to expand the disk if running CentOS 7.
The steps for expanding a disk with LVM are listed below:
Step 3: Changing the Disk Partition Size.
Before expanding the disk, you need to change the size of the disk partition.
To change the size of the disk partition, follow these steps:
- First, use the fdisk command to identify the disk you want to change the size of the partition.
sudo fdisk /dev/sda
Here, /dev/sda is the name of the disk you want to expand. After running the command, a list of disk partitions will be displayed.
- Next, use the p command to show the partition table and display a list of disk partitions.
- Create a new partition using the n command and enter the value you want to expand its size.
- Save the changes using the w command.
- After this operation, the disk needs to be re-read. You can use the “partprobe” command for this.
Step 4: Re-defining Physical and Logical Partitions.
After expanding the disk size, you need to re-define physical and logical partitions. To do this, follow these steps:
- First, run the following command to re-detect the physical volume:
sudo pvresize /dev/sdaX
Note that “/dev/sdaX” is the name of the physical partition you want to make changes to.
- Then, run the following command to re-define the logical volume:
sudo lvextend -l +100%FREE /dev/mapper/VolGroup00-LogVol00
Here, “/dev/mapper/VolGroup00-LogVol00” is the name of the logical partition you want to make changes to.
- Finally, run the following command to resize the file system:
sudo resize2fs /dev/mapper/VolGroup00-LogVol00
Here, “/dev/mapper/VolGroup00-LogVol00” is the name of the file system you want to resize.
Step 5: Checking the Disk Expansion Process.
After completing the disk expansion process, use the following command to check the new disk size:
df -h
This command will display the available disk space on the system in a human-readable format. Make sure that the new disk size is reflected in the output.
By following these steps, you can complete the disk expansion process on CentOS 7.
Share this article