How to Resize XFS File Systems on Linux

You can easily resize the XFS file systems on Linux with the xfs_growfs command. The process is straightforward, but make sure you follow the appropriate approach. Follow the article and learn how.

Linux file system contains a structured collection of files on a partition or disk. Data is stored in a hierarchical structure of folders, subfolders, and files. There are many file systems on Linux like EXT, EXT2, EXT3, JFS, Btrfs, and XFS. For now, let’s focus on XFS.

In this tutorial, we will walk through how to resize the XFS file system on Linux. First, let’s  have a brief introduction to the XFS file system. 

Understanding the XFS System File

The XFS file system is a high-performance 64-bit journaling file system supported by most Linux distributions (Linux Mint, Ubuntu, etc.). Remember,  some use XFS as a default file system.

XFS by design is developed for parallel I/O processing. XFS enables extreme scalability of I/O threads, size of files, and file system bandwidth. It allows data consistency by employing metadata journaling and supporting write barriers. 

Some of its features are:

  • Seamless capacity
  • Brilliant journaling
  • Robust allocation groups
  • Striped allocation
  • Extend-based allocation 
  • Superb variable-sized blocks
  • Delayed allocation
  • Direct I/O
  • Snapshots
  • Sparse files

Resizing file systems is different from resizing partitions, which makes more space on the physical volume. Remember, resizing file systems can potentially lead to data loss of that partition or disk; it’s always a good idea to have a backup.

Resizing Without LVM

Resize XFS File Systems without lvm

Here, we are going to resize without LVM. LVM dictates the term Logical Volume Manager for those who don’t know. It usually features the ability to allocate disks. Alongside that, other activities like striping, mirroring, and also resizing logical volumes are also supported.

With LVM, the concerned hard drive or even the set of hard drives is seamlessly allocated. The allocation is done to either one or more physical volumes. The LVM physical volumes are allowed to be positioned on other block devices. The same might again effortlessly spawn two or more disks.

Here, the physical disks are combined into Logical disks. But remember, /boot partition stands as an exception. This is primarily because the bootloader cannot read it.

How to Resize XFS File Systems on Linux

Now that you’ve got enough information, let’s start learning the best possible ways to resize the XFS file system on Linux. Remember, the steps are the same on most of the Linux distros with the XFS file system.

Step 1: View the Logical Volume

To get the information about the available partition, use the lsblk command. For that, launch the Terminal by using the “Ctrl+Alt+T” command. After that, invoke the following command:

$ lsblk
viewing logical volume

Step 2: Alter the Partition to the Existing Storage or Mounted Storage

Use the following command to make a partition to the desired disk or existing partition. It is important to extend the partition because the same will not be effective if you use the same size repeatedly.

$ sudo fdisk /dev/sda1

Step 3: Create XFS File System (On the Partition/Logical Volume)

The next step is selecting the required Logical Volume. In our case, it is dev/sda1; the same may vary for yours. From there, create an XFS file system for that partition using the following command. 

$ sudo mkfs.xfs /dev/sda1 -f
Create XFS File System (On the Partition/Logical Volume)

The created XFS file system will be helpful later on. This assists when extending the same in the future. If you already have an XFS file system in that partition, you do not need to re-run the command again.

Resizing the XFS File Systems

If you don’t already know, an XFS file system can be resized using the xfs_growfs tool. The concerned XFS file system usually provides it. Note that XFS file systems can only grow in size, so they can not be shrunk.

Check Size of Current Logical Volume

Kick-start the process by checking the current size of the selected partition. You can do that by launching the Terminal and invoking the following command:

$ df -h
Check Size of Current Logical Volume

This will help you see and grab an idea about the partition size.

Resize XFS File Systems

You’re now ready to resize the file system. The process is simple; make sure you follow the right approach. Launch the Terminal and invoke the xfs_growfs command together with the -d flag. Make sure to mention the size and mount point.

This command will help grow the size of a file system. Here is the required syntax:

$ sudo xfs_growfs -d size mount-point

Here, the -d size flag is employed if and when you want to increase the size by a certain number. Suppose you want it to be 10 GB; you’ll need to pass the value. However, if you’re willing to grow the file system to full size, simply use the -d flag.

The xfs_growfs Command: Crucial Options

Some options with the xfs_growfs command are:

  • -d: The -d flag, as already mentioned, helps expand the data sections of the file system to the maximum size of the partition.
  • -d [size]: Specify the size you want to extend the file system to. The [size] argument stands for the number of file system blocks
  • -m [maxpct]: Specify the new value for the maximum percentage of space in the file system.

Verify the Changes

Before drawing the curtains, make sure to do a final verification. You can assure that the changes have been successfully made by the using the following command:

$ df  -h
Resize XFS File

That’s how you resize XFS file systems on Linux. We created the successful extended XFC file system. The above tutorial works for most Linux distros. Enjoy!

If this guide helped you, please share it.

Leave a Reply
Related Posts