How do I increase the size of an existing disk in CentOS 7?
To expand an existing disk, you can follow these steps:
- First, use the lsblk command to view the disk and partition information in the system, and identify the names of the disk and partition that need to be resized. For example, suppose the disk to be resized is /dev/sdb and the partition is /dev/sdb1.
- Edit the disk partition table using the fdisk command. Run the following command:
- Run fdisk as a superuser on the device /dev/sdb.
- In fdisk, press the delete key (d) to remove a partition. If you want to delete multiple partitions, repeat this step. Then press the new key (n) to create a new partition.
- Choose the type of primary or logical partition at the prompt. Select the first available partition number according to the default option.
- Choose the starting and ending sectors of the partition as needed. Opt for the default option for the starting sector.
- Set the partition type to Linux LVM (type code 8e). Press the key “t”, select the partition number, and enter 8e.
- Finally, press the “w” key to save and exit fdisk.
- Run the command partprobe to reload the partition table.
- Refresh the partitions on /dev/sdb with sudo.
- Extend logical volume (LV).
- Use the lsblk command to locate the path of the logical volume you want to expand. Let’s say the logical volume you want to expand is /dev/VolGroup00/LogVol00.
- Use the lvextend command to extend the logical volume. For instance, to increase the logical volume by 10GB, you can run the following command:
sudo lvextend -L +10G /dev/VolGroup00/LogVol00 - Run the resize2fs command to adjust the size of the filesystem.
- Please resize the filesystem on /dev/VolGroup00/LogVol00 using the command sudo resize2fs.
- You have successfully expanded the existing disk now. You can use the “df -h” command to verify if the file system has been expanded.