How to expand disk space in CentOS 7?
To expand the disk space of CentOS 7, you can follow these steps:
- To begin, check the disk status in the system. You can run the following command to view the mounted disks and their sizes:
- display the disk space usage of file systems
- Adjust the disk size to the desired size on a virtual machine or physical machine. This step can be completed using a disk partition tool on the virtualization platform or physical machine.
- Update the disk partition to reflect the changes made. You can run the following command to rescan the disk partition:
- refresh partitions
- Use the following command to view available disk partitions:
- Display the list of disks.
- To expand a partition, use the following command (assuming /dev/sda1 is the partition you want to extend):
- Partition the device /dev/sda.
- In the fdisk interface, press the ‘p’ key to print the partition table and determine the partition you want to extend. Then press the ‘d’ key to delete that partition. Press the ‘n’ key to create a new primary partition. Follow the prompts to set the starting sector to the original partition’s starting sector and the ending sector to the new partition’s ending sector. Finally, press the ‘w’ key to save the changes and exit.
- Run the following command to rescan the disk:
- rescan partitions
- Expand the filesystem using the following command (assuming /dev/sda1 is the partition that needs to be expanded):
- Adjust the size of /dev/sda1 file system.
- This will automatically adjust the file system size to fit the new partition size.
- Finally, run the following command again to check if the disk space has been successfully expanded:
- Display the disk space usage in a human-readable format.
Please ensure that important data is backed up before proceeding with the above operations, and proceed with caution to avoid accidental deletion or damage to data.