Installing & Using XFS

Written by Net Llama! -  Last updated on 23-November-2003

XFS is the journaling filesystem (similar to ext3 & ResierFS) developed by SGI, and based on the XFS used in their proprietary IRIX UNIX OS.  XFS for Linux is fully open sourced under the GPL.  XFS provides rapid recovery from system crashes and the ability to support extremely large disk arrays.

XFS can be used for your root (/) filesystem, which means that you can completely migrate an existing Linux install to XFS.  Be aware that since XFS has not yet been merged into the official kernel source tree, you cannot install Linux onto an xfs formatted filesystem, but rather, you must copy existing data onto xfs formatted filesystems.

Also be aware that XFS will only work with 2.4.x kernels, and not 2.2.x.  At the time of this writing XFS can be used on all 2.4.x kernels up through 2.4.22 and all recent 2.6.x kernels as well.   XFS support is already in the 2.6.x kernel tree, and will be a standard part of the upcoming 2.6.x kernel release.

Additionally, note that the instructions provided below are meant for someone who is converting to XFS for the first time with a 2.4.21 kernel.  It is certainly possible to build more recent 2.4.x and 2.5.x kernels with XFS support as well, however I recommend going with the standardized packages & procedure noted below first, and then after you are successful, upgrading with the packages available in the subdirectories here.



1) Configure & build a working 2.4.21 kernel first!  Do not start playing with XFS until you know that you have a stable & functional 2.4.21 kernel.  Troubleshooting problems with XFS will be nearly impossible if the functionality of you kernel is unknown.  For kernel building help see the kernel compiling SxS here.

2)  Download the xfs kernel patch:
linux-xfs-1.3.1.patch.gz
3)  As root, place the patch tarball into /usr/src (this assumes that you have your 2.4.19 kernel source in /usr/src/linux), and uncompress:
gunzip linux-xfs-1.3.1.patch.gz

4)  Now patch the kernel source:
patch -p0 < linux-xfs-1.3.1.patch

5)  Build and install a new 2.4.19 kernel as normal (with filesystem support for whichever filesystem you are already using, ext2/3, reiserFS etc) and make sure to say "Y" to:
XFS filesystem support (CONFIG_XFS_FS)
Page Buffer support (CONFIG_PAGE_BUF)

6)  Reboot using the new XFS enabled kernel to verify that everything continues to work as expected with your pre-existing filesystems (ext2/3, ReiserFS etc).

7)  Now you will need to download & build/install the XFS command utilities:
acl, attr, dmapi, xfsdump, & xfsprogs
You can either obtain the source tarballs here:
ftp://oss.sgi.com/projects/xfs/Release-1.3.1/cmd_tars/
or you can obtain RPM and/or SRPMS here:
ftp://oss.sgi.com/projects/xfs/Release-1.3.1/cmd_rpms/
If you choose to use the RPMs or SRPMS, you will need to have an rpm version of at least 3.0.6 installed on your system.  You can determine which version of RPM that you have with the command:
rpm -q rpm

Additionally, if you go with the RPMs (rather than the SRPMS or tarballs), you will need the *-devel RPMs as well as the standard packages.
The order that you install these packages is bascially unimportant, however you must build & install these three first in this order:
1) xfsprogs
2) acl
3) xfsdump

8)  Now comes the fun part where you create xfs filesystems.  This is really no different of a process than creating an ext2/3 filesystem.  Use whichever partitioning tool you prefer (fdisck, cfdisk etc) to create a new Linux partition (type 83).  Then format it with the xfs filesystem.  In this example I am formating the first partition on my first SCSI drive:
mkfs.xfs /dev/sda1

9) Now you are ready to put data on that new xfs partition.  First mount the partition.  In this example I am mounting it at the arbitrary mount point of /mnt/tmp:

mount -t xfs /dev/sda1 /mnt/tmp

XFS allows you to put your entire root (/) filesystem onto an xfs formatted partition, so that is certainly an option.  However, its truly up to you,  which data you wish to have on xfs.  In this example, I am going to move /usr onto the xfs partition, /dev/sda1:

cp -a /usr/* /mnt/tmp

10) Once this completes (and it will most likely take anywhere from several minutes to a few hours depending on how much data you're moving around), take a look around in /mnt/tmp to verify that your data is truly there (you should see the exact same files, ownership and permissions in both places).  If you feel confident that the data has been successfully copied over, then you can prepare for rebooting with /usr on xfs.  First update /etc/fstab to mount the new xfs based /usr at bootup.  I originally had /usr mounted under / so I merely needed to add the following line.  
/dev/sda1    /usr    xfs    defaults    1    1
Depending on which data you opt to move to XFS, you may need to edit existing lines and/or add new lines.

11) Now move the original, old /usr somewhere else so that when you reboot the new xfs /usr will get mounted in its place:
mv /usr /usr-old

12) Now its time to reboot and use xfs:
shutdown -r now
If all goes well the system should bootup without a hitch.  You can verify that you are using xfs with the mount command:
[netllama@netllama /]$ mount
/dev/sda1 on /usr type xfs (rw)

13) Go ahead and delete the old ext2 based /usr:
rm -rf /usr-old

OK, you're done!  No more fscks!



An additional benefit of XFS, beyond the incredibly stability it provides is an entire set of new filesystem tools that are at your disposal:

xfs_growfs which will resize a partition on the fly
xfs_admin for labeling and renaming
xfs_check for error filesystem and inode correction
xfs_freeze to freeze a filesystem for snapshots
xfs_fsr to reallocate or defragment a filesystem
xfs_bmap to print block mapping for an XFS filesystem
xfs_db to debug an XFS filesystem
xfs_logprint to print the log of an XFS filesystem
xfsdump to back up a filesystem
xfsrestore to restore a filesystem

You can read more about these via their man pages, and also the XFS official webpage here.