The Fast File System


The OpenBSD file system, the Fast File System (FFS), is a direct descendant of the file system shipped with BSD4.4. Even today one of the original people who worked on BSD is still making improvements to the file system, and those improvements are frequently imported into OpenBSD. FFS is sometimes called UFS for UNIX File System, and many system utilities call FFS partitions UFS. This Fast File System made its way back into AT&T UNIX; from there, it slipped into many other commercial versions of UNIX. If a UNIX vendor doesn't specifically state that they have a "new and improved file system," they're almost certainly using FFS.

FFS is designed to be fast and reliable. OpenBSD ships FFS configured to be as widely useful as possible on each architecture, but you can choose to optimize it for trillions of small files or a half-dozen 30GB files, if you choose. You don't have to know a huge amount about FFS's internals, but you must know about inodes, blocks, and fragments.

Files are broken up into blocks and fragments. Blocks are large chunks of data, while fragments are smaller chunks. Generally, a file fills as many blocks as possible and uses a fragment or two for leftover touches of data. As a file grows, the system allocates additional blocks for the information.

Inodes contain very basic information about the file, including a list of the blocks and fragments that the file uses but also the permissions and size of the file. Information in an inode is called metadata, which is a fancy word for "data about data." Inodes index the file on disk.

FFS Mount Options

Unlike the Windows or Macintosh file systems, FFS partitions can be treated in several different ways depending on how they're mounted. The manner in which a partition is mounted is called the mount type. You can change the mount options on a standard partition by entering the appropriate options to the fourth column in its /etc/fstab entry.

Read-Only Mounts

If you only want to look at the contents of a partition, and not write to it, you can mount the partition as read-only (or "rdonly"). This is unquestionably the safest way to mount a disk and one of the useless most of the time. The purpose of disks is to store data that you enter, after all!

Many systems administrators mount the root partition, and perhaps even /usr, as read-only to minimize any potential system damage from a loss of power or an intruder. Even if you lose the physical hard drive due to a power surge or some other hardware failure, the data on the platters remains intact. That's the advantage of read-only mounts; the disadvantage is that it makes maintenance far more difficult. Read-only mounts are also useful when you're trying to read a damaged file system that you do not want to damage further.

Read-Write Mounts

You can read to the disk. You can write to the disk. Read-write mounts are abbreviated "rw." This is the standard mount, but I recommend that you use soft updates instead if your architecture supports it.

Soft Update Mounts

Soft update, or "softdep," mounts organize and arrange disk writes so that the file system metadata on the disk remains consistent, and it comes close to giving the performance of an "async" mount with the reliability of a "sync" mount. While that doesn't mean that all the data will be written to disk — a power failure at the wrong moment will still lose datat — using soft updates will prevent a lot of problems. It's not the default only because some older, smaller architectures do not have enough memory to support it. On i386, I strongly recommend enabling soft updates for all your FFS partitions.

Synchronous Mounts

Synchronous (or "sync") mounts are the old-fashioned way of mounting a file system. When a disk is synchronously mounted you can read from it as fast as the disk can feed data to the operating system, but writes run more slowly. The kernel will write a chunk of data to the disk, wait to receive a confirmation from the disk that the data has actually been accepted and written to the disk, and then will tell the program that requested the data write that the data is on disk.

Synchronous mounts provide the greatest data integrity in the case of a crash, but they are slow in terms of computer speed. Consider using synchronous mounting when you want to be truly pedantic about data integrity, but in most cases it's overkill.

Asynchronous Mounts

For faster data writing at a much higher risk of data loss, mount your partitions asynchronously ("async"). When a disk is asynchronously mounted, the kernel sends data to the disk and immediately tells the program that the write was successful without waiting for the disk to confirm that the data was written. As you can probably imagine, a data loss or system failure will result in corrupt data and confused software. Asynchronous mounts are fine on disposable machines, but don't use them when you care about your data.

No Access Time Mounts

FFS records the last time a file was accessed, meaning the last time it was executed or read by any means. These updates consume a small but measurable amount of time and disk performance. By mounting your disks "noatime" you can conserve that shred of time. In most cases, if you're using this option, you should invest in a faster disk instead.

On machines where power is a concern, however, noatime is very useful — the hard disk and the screen are the two most power-hungry devices on a laptop, and if you can reduce the amount of time your laptop's hard drive spins you will extend battery life.

No Device Nodes Mounts

Using a "nodev" mount tells the system to not interpret any device nodes on the file system. This is useful for security reasons, and is especially useful if you have hard drives from a different operating system on the computer. For example, on your dual-boot OpenBSD/Linux computer, you do not want to accidentally try to access a Linux device node instead of your native OpenBSD device node! In most cases, there is no reason to have a device node on any partition except that containing the root file system.

Noexec Mounts

The "noexec" mount option prevents any binaries from being executed on the partition. Mounting /home noexec can help prevent users from installing and running their own programs, but for it to be effective, be sure to also noexec mount any shared areas (such as /tmp).

Nosuid Mounts

The "nosuid" option disallows setuid behavior from programs on this file system. Many partitions should not have setuid files, and this is an easy way to disrupt them. Like noexec mounts, you must carefully place this option on all user-writable directories for it to be effective.

Noauto Mounts

The "noauto" mount isn't actually a mount, but a way of marking partitions that should not be automatically mounted at boot time. I frequently create /etc/fstab entries for my floppy and CD-ROM drives, but the system should not attempt to mount these at boot. The boot will hang if a partition the system needs is not available, and I don't want my computer to refuse to complete the booting process just because there is no CD-ROM in the tray!

Using FFS Mount Options

You can specify multiple mount options in a comma-separated list on a partition's /etc/fstab entry. Here's an entry with several options for reference.

 /dev/wd0g /home ffs rw,softdep,nodev,nosuid,noexec 1 2 

You can also specify these options when you mount partitions on the command line, as we'll discuss shortly.

What's Mounted Now?

How can you determine what file systems are mounted on your system and how they are mounted? Start by running mount(8) without any options, which will give you a list of all mounted file systems.

 # mount /dev/wd0a on / type ffs (local, softdep) /dev/wd0g on /home type ffs (local, nodev, noexec, nosuid, softdep) /dev/wd0d on /tmp type ffs (local, nodev, nosuid, softdep) /dev/wd0f on /usr type ffs (local, nodev, softdep) /dev/wd0e on /var type ffs (local, nodev, noexec, nosuid, softdep) 1 /dev/cd0c on /mnt type cd9660 (local, read-only) # 

This is also a quick way to get the device names for your partitions. In addition to the /etc/fstab entries we saw earlier, we have a 1 CD-ROM mounted. If you're using NFS, MFS, or other file systems, they will also show up here.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net