In this video, Kevin Dankwardt discusses the features of a variety of Linux file systems. Special features of ext4, XFS, and Vtrfs are examined. Kevin discusses how features such as performance and journaling can be used to distinguish file systems.
- [Instructor] File system types. Linux has lots of kinds of file systems. Some of those are pseudo kind of file systems like proc and sysfs, but there's many kinds of file systems for disk file systems. The recent Linux kernel, for example, has 95 different calls to register_filesystem(), which is the function that code uses to register the different parts of the API to support being a file system.
So, XFS would register a file system, and exd4 would, and exd2 would, and so forth. So there's lots of kinds of file systems in the kernel. For disk-based file systems, there's a lot of ways that file systems can differ from each other. For example, if a file system supports journaling. A journal is writing what you're going to do. I'm going to change this sector. Then, after you're done changing that sector, then you can say I wrote it.
The good thing about a journal is you say what you're going to do, so you have a list of what you're working on, and if you lose power, when we come back up, we can look at the journal to see what we're working on to see what part of the disk maybe is corrupted. Without a journal, when you come back up, you just know you're potentially writing somewhere. You have to check the whole system. That file system check can take hours on a big system without journaling. Journaling can greatly speed up file system checks.
File systems can differ in their data structures on how fast they are for working with files. Kind of a fundamental there. Turns out some file systems are faster than others if you're using a lot of small files, and some file systems are faster than others if you're using a lot of large files. So, depending on your application, you might choose a file system. Some file systems can support much larger file systems than others. Some file systems use 64 bits for sizes for things.
Some use 32 bits. Some file systems support copy-on-write, so when you make a copy, it doesn't actually change anything. It just re-maps those pages. There's a lot of fancy attributes that a file can have. Files could be compressed. Files could be encrypted. One of the most popular file system for Linux is ext4. That's been the standard for Linux systems for quite a while now. It's the successor to ext2 and ext3, which were very common.
Ext4 does support journaling, and it's got lots of options. If you check the man page for ext4, you can see some of them. For example, huge_file allows an individual file to be bigger than two terabytes, or the max_batch_time allows for the kernel code for ext4 to wait a little while in case there's more requests and write those as a chunk. That can improve performance. Btrfs is pretty new. It's been worked on for years, and some people love it.
I've used it, and I haven't had any problems yet. Btrfs has lots of features. You can snapshot it. It supports copy-on-write, so when you copy a file with the right option, the reflinks option, it doesn't actually make a copy. It just maps all the pages to the new name. You can have compressed files. You can resize the file system. It even supports multiple disks or partitions like LVM natively in the file system.
XFS has been around for years. It was the standard file system on SGI's IRIX UNIX system, and it was ported to Linux years ago. It is now the default for Red Hat 7. When we do journaling, we can journal that we're writing to the file, and we can journal that we're writing to the other information about a file. The metadata. So, XFS also journals metadata.
XFS supports defragging and enlarging while the file system is mounted and being used. You don't have to unmount it and do it offline. XFS has its own special utilities for doing backups and restores, instead of using the kind of general purpose ones. XFS was originally designed to support large average file sizes. For example, if your typical file was a gigabyte, maybe you're doing video applications, XFS was a great choice.
Linux also has what are known as FUSE file systems, or file systems implemented in user space. All these other file systems, ext4 and XFS and so forth, are code in the Linux kernel, and that means that there's a certain amount of privilege to get that code executing. Typically, to mount one of those kind of file systems, you're usually root. The user space file systems are kind of like ordinary user code, and potentially any user can use these.
There's lots of these. They're, in general, like other file systems, designed to give you what looks like a file system, directory and files and so forth. But they can be a convenient interface that looks like a file system for other data. For example, SSHFS lets you look at a directory on a remote system that you can SSH to like it's a local directory, without using NFS.
The Gmail file system uses your Gmail account to hold the data and looks like a file system. As you read and write files behind the scenes, it sends and reads email. The gphotofs makes the files on a digital camera look like a file system and so forth. Linux supports encrypted file systems, but maybe even better, disk partition encryption.
We'll look at that more later. One of the nice things about this LUKS disk encryption is you can have multiple keys, so different people can get to a partition without having the same key. You can even encrypt swap devices, because we're encrypting a partition, not a file system. You probably want to encrypt your swap partition, as well, because there might be proprietary information that got written out to disk in the swap device.
There was an encrypted file system type that was kind of popular, eCryptfs, but Red Hat, for example, doesn't support that anymore.
- Partitioning storage
- Creating, mounting, and unmounting file systems
- Formatting file systems
- Making volumes with LVM
- Adding storage security
- Managing swap spaces
- Backing up and recovering Linux storage systems
- Working with networked file systems like NFS and SSHFS