How to resize an ext4 and XFS root partition on CentOS cloud servers

por | 2 diciembre, 2021
  1. Run the below command to check the current root disk capacity# lsblk linuxresize1
    You can see in the above output that the / is mounted on /dev/vda3 and its size is 247G. But the total disk is 300G in this server.
  2. The first step you need to do to expand the disk space is to install the necessary tools. Run the below command to install cloud utils.
    On Ubuntu / Debian system, run the below command:# apt -y install cloud-guest-utils gdisk On CentOS system, run the below command:# yum -y install cloud-utils-growpart gdisk linuxresize2
  3. Now run the below command to extend your partition and it will resize partition 3 on /dev/vda.# growpart /dev/vda 3 linuxresize3
  4. Again, run the below command to Validate the changes and you can see here that /dev/vda3 is extended to 297G.# lsblk linuxresize4
  5. Now run the below command to resize / partition to fill all space.
    For ext4 file system, run the below command:# resize2fs /dev/vda3 For XFS file system, run the below command:# xfs_growfs / linuxresize5
  6. You can verify the new size using the below command.# df -hT | grep /dev/vda linuxresize6