You can increase the XFS file size by mounting the XFS. However, you can’t decrease the file size. Furthermore, if you unmount the XFS file, it is not possible to extend the size. Let’s have a deeper look at the brief details about what XFS resize is and how you can use it.
What Is XFS Resize?
Before moving to the approaches, you can try to resize the XFS. Let’s understand the key parts of the XFS. An XFS file contains the following parts:
Data section: It contains the metadata of filesystems like directories, inodes, and indirect blocks. The data section includes the number of allocation groups of the same size. The system can handle the number of groups and sizes using mkfs.xfs.
Log Section: It is internal to the data section. This section contains the changes that need to be done to the filesystem’s metadata until the changes are done. In short, it works as a queue of tasks in the data section.
Real-Time Section: This section stores the data of real-time files. The real-time section becomes absent if we use the default option of mkfs.xfs. The data section contains the log section within itself. When we consider XFS resizing, it increases the size of the data section, log section, or real-time section as specified in the command.
How to Use the XFS Resize
To increase or expand the size of the XFS file, you can use the xfs_growfs command. Here is the exemplary syntax of this command:
In the provided syntax command, the following stands for:
- xfs_growfs: It grows the file size.
- Options: These are the additional options of the command.
- mount-point: It is a directory path to mount the file.
- size: It is the size that you want to increase.
The xfs_growfs command contains various options to perform the various tasks easily. Let’s check out these options:
Options | Description |
-d flag | Increases the file size to the largest possible size. |
-D size flag | Increases the file size to the given file size. |
-e size flag | Increases the file size in real-time. |
-L size flag | The log section increases to the given size. |
-m flag | Some space in filesystems is allocated to inodes. It specifies the size to be allocated for inodes in percentage. |
-n flag | Specifying the file size will not change. |
-r flag | Increases at the largest possible size to the real-time section. |
-R size flag | Real-time section increases at the given size. |
-t flag | Gives alternate mount table. |
-V flag | Gives version number. It is not necessary to give the mount-point option while checking the version. |
You can use the xfs_growfs command in the regular disk partitions. When it comes to increasing the filesystem’s size, there should be additional space for the filesystem to grow.
You need to use the alternate disk partition to increase the filesystem’s size. Logical volume managers handle all these increasing space operations. Let’s take an example to increase the size of XFS file systems:
xfs_growfs -d mount-point
You can use the -d option to increase the file size to the maximum. You can use the -d size to specify the file size.
If you want to verify that the system made the changes successfully, you can execute the following command:
Conclusion
In this guide, we explained everything you need to know about the approach that you can try for the XFS resize in Linux. The xfs_growfs command is convenient to use and contains various options to change the XFS easily. The BTRFS file system is similar to XFS. Make sure that you check out our website to know more about the BTRFS.