With its advanced features that allow for performance tuning and optimization, XFS is probably the best file system around for the data center. However, XFS also has a set of specific management tools. In this article, you'll read how to use them.
Before storing files on your XFS file system, you need to mount it. Several mount options are available for XFS. Among the most important options is the allocation size (allocsize). This option specifies how much data to allocate for each file that you want to write. By using this parameter, you can avoid fragmentation and thus get a higher level of performance out of the file system. The default value of 64 KB does well for average workloads, but if you are putting large files on the file system, it can make sense to increase the allocsize parameter considerably. For instance, a 512 MB allocsize is good for multimedia solutions, such as Internet broadcasting. Valid values reach from 4 KB to 1 GB, with power of 2 increments.
The second option that is wise to use on mounting the file system is rather generic. It is called noatime, and makes sure that the access time of files is not modified every time a file is accessed. It is a good idea to use this parameter in writing-intensive environments, since writing a new access time to the file system every time a file is accessed has a high performance price.
A third important mount option is the barrier option. This is important if you want to make sure that files are written properly to hard disk. On modern disk systems, a file is not written directly to the hard drive, but to a write cache instead. When the file has been written to these in-memory buffers, the file system is informed that the file has been written, whereas in fact it isn't. If at that moment the server crashes, the modifications to the file will get lost. When using the barrier option, you can force the file system to write modifications to on-disk write buffers instead of in-memory write buffers. thus ensuring that the file really is written to disk. There's only one condition for this action. Your disk must have a cache that can be used for writing files; however, on almost all modern hard drives that is the case.
Once mounted, you will see that many file system utilities have an XFS alternative. For instance, if you use man –k xfs to search the man pages for all commands that relate to XFS, you'll see that there are many commands available. Some commands are not too hard. If you have worked with fsck, you will also be able to find your way in xfs_repair to repair the XFS file system. And if you have resized a file system before, you'll find it's not too hard to resize an XFS file system using xfs_growfs. Some utilities are rather special, and you'll find some information on them in the rest of this article.Real-time copy
When creating an XFS file system, you can specify that a real-time section must be created as well. Files that are written to this section are written there without using the disk cache mechanism, which helps you in preventing file system corruption. If you want, you can copy files to that section directly, using the xfs_rtcp command. When using this command, you can even specify that a fixed extend size must be used. For the rest, xfs_rtcp works like an ordinary file copy command. Xfsdump
You have probably worked with tar to create backups before. When using XFS, the xfsdump command is the most appropriate way of creating backups. The most important distinction is that xfsdump will backup all XFS attributes as well, whereas this is not the case for backup utilities like tar that don't understand XFS metadata.
Using xfsdump is not very hard. It backs up files and all their attributes to a storage media, a regular file or standard output. Once backed up there, you can restore files using the xfsrestore command. Using xfsdump really isn't too hard. For example, you can use the following command to dump your complete root file system to tape:
Xfsdump –v trace –f /dev/tape /
If you are familiar with using tar, you'll notice similarities between the two commands. As mentioned, if you want to make sure that all XFS specific attributes are backed up as well, better use xfsdump.Xfs_freeze
For other file systems it is rather uncommon to freeze access to the file system. XFS, however, allows this through the xfs_freeze command. Freezing access to a file system is useful if you want to make a snapshot using your volume manager. It makes sure that nothing is written to the file system for a given moment. To "unfreeze" the file system later, use xfs_freeze again. This switches access to the file system back on. Summary
In this article you've learned how to mount an XFS file system with specific options. Using these options is a good idea if you want to get the maximum performance out of your file system. You've also learned about some very specific XFS file system management commands. About the author: Sander van Vugt is an author and independent technical trainer, specializing in Linux since 1994. Vugt is also a technical consultant for high-availability (HA) clustering and performance optimization, as well as an expert on SUSE Linux Enterprise Desktop 10 (SLED 10) administration.