Reducing Size of /dev/centos/root XFS Filesystem on CentOS
When using the XFS filesystem, you may find yourself running out of space on your /dev/centos/root volume. However, XFS does not support online resizing, which means that you cannot directly reduce the size of an XFS filesystem. Despite this limitation, there are still ways to reduce the size of your /dev/centos/root volume.
Step 1: Free up space
Before you can reduce the size of your /dev/centos/root volume, you need to free up space. You can do this by removing unnecessary files and directories. Here are some commands that can help:
# Remove old kernels:
dnf remove $(rpm -qa | grep kernel | grep -v $(uname -r))
# Remove old logs:
find /var/log -type f -mtime +30 -exec rm {} \;
# Remove cached packages:
dnf clean all
Step 2: Unmount the filesystem
Once you have freed up space, you need to unmount the filesystem. Here's how:
# Unmount the filesystem:
umount /dev/centos/root
Step 3: Reduce the size of the logical volume
Now you can reduce the size of the logical volume. Here's how:
# Reduce the size of the logical volume:
lvreduce -L 10G /dev/mapper/centos-root
Replace "10G" with the new size that you want for your /dev/centos/root volume.
Step 4: Resize the filesystem
After reducing the size of the logical volume, you need to resize the filesystem. Here's how:
# Resize the filesystem:
xfs_growfs /dev/mapper/centos-root
Step 5: Remount the filesystem
Finally, you can remount the filesystem:
# Remount the filesystem:
mount /dev/centos/root
- XFS does not support online resizing, so you cannot directly reduce the size of an XFS filesystem.
- To reduce the size of your /dev/centos/root volume, you need to free up space, unmount the filesystem, reduce the size of the logical volume, resize the filesystem, and remount the filesystem.
- Use the "lvreduce" command to reduce the size of the logical volume, and the "xfs\_growfs" command to resize the filesystem.