MOUNT.CONF(5)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1, nixpkgs unstable

πŸ’… MOUNT.CONF(5) πŸ’…

okay so bestie, this is the manual page for mount.conf(5) β€” yes the 5 means "file formats" section, we love a file format moment πŸ’–. It's literally the root file system mount configuration file and it's kind of the main character of your boot process, no cap.


✨ SYNOPSIS ✨

/.mount.conf

that's it. that's the file. it lives at the root of your root fs and it's giving "tiny file, huge responsibilities" πŸŽ€


🌸 DESCRIPTION 🌸

So during the bootup process, the FreeBSD kernel is gonna try to mount the root file system using the logic in the vfs_mountroot() function in src/sys/kern/vfs_mountroot.c. Like, that's the whole vibe. And the root mount logic goes a little something like this:

  1. The kernel will synthesize in memory a config file with default directives for mounting the root file system. The logic for this is in vfs_mountroot_conf0(). yes bestie, it's making a little config file out of thin air, iconic.
  2. The kernel will first mount devfs(4) as the root file system.
  3. Next, the kernel will parse the in-memory config file created in step 1 and try to mount the actual root file system. See "FILE FORMAT" for the format of the config file.
  4. When the actual root file system is mounted, devfs(4) will be re-mounted on the /dev directory.
  5. If a /.mount.conf file does not exist in the root file system which was just mounted, the root mount logic stops here. that's it, we're done, go home.
  6. If a /.mount.conf file exists in the root file system which was just mounted, this file will be parsed, and the kernel will use this new config file to try to re-mount the root file system. See "FILE FORMAT" for the format of the config file.
  7. If the new root file system has a /.mount directory, the old root file system will be re-mounted on /.mount.
  8. The root mount logic will go back to step 4. yes, it loops. it's recursive. it's giving "we will keep doing this until one of us gives up" πŸ’€

The root mount logic is recursive, and step 8 will be repeated as long as each new root file system which is mounted has a /.mount.conf file. so like… it can go forever if you let it. be normal about it 🫢


πŸ¦‹ FILE FORMAT πŸ¦‹

The kernel parses each line in .mount.conf and then tries to perform the action specified on that line as soon as it is parsed. no buffering, no waiting, it's immediate, it's eager, it's a Leo.

  • # β€” a line beginning with a # is a comment and is ignored. we love a silent supporter.
  • {FS}:{MOUNTPOINT} {OPTIONS} β€” the kernel will try to mount this in an operation equivalent to:
mount -t {FS} -o {OPTIONS} {MOUNTPOINT} /

If this is successfully mounted, further lines in .mount.conf are ignored. If all lines in .mount.conf have been processed and no root file system has been successfully mounted, then the action specified by .onfail is performed. so like, first success wins, and if nobody wins… .onfail gets the aux cord 😭

  • .ask β€” when the kernel processes this line, a mountroot> command-line prompt is displayed. At this prompt, the operator can enter the root mount. it's giving "we tried everything, you try, bestie" πŸ™ˆ
  • .md file β€” create a memory backed md(4) virtual disk, using file as the backing store. yes, a whole disk, in memory, out of a file. slay.
  • .onfail [panic|reboot|retry|continue] β€” if after parsing all the lines in .mount.conf the kernel is unable to mount a root file system, the .onfail directive tells the kernel what action to perform. pick your fighter: panic, reboot, retry, or continue πŸ’…
  • .timeout N β€” before trying to mount a root file system, if the root mount device does not exist, wait at most N seconds for the device to appear before trying to mount it. If .timeout is not specified, the default timeout is 3 seconds. so yeah, it'll wait, but only 3 seconds by default. it has boundaries.

πŸ’œ EXAMPLES πŸ’œ

mkay so the following example .mount.conf will direct the kernel to try mounting the root file system first as an ISO CD9660 file system on /dev/cd0, then if that does not work, as an ISO CD9660 file system on /dev/cd1, and then if that does not work, as a UFS file system on /dev/ada0s1a. If that does not work, a mountroot> command-line prompt will be displayed where the operator can manually enter the root file system to mount. Finally if that does not work, the kernel will panic. dramatic? yes. correct? also yes.

.onfail panic
.timeout 3
cd9660:/dev/cd0 ro
.timeout 0
cd9660:/dev/cd1 ro
.timeout 3
ufs:/dev/ada0s1a
.ask

The following example .mount.conf will direct the kernel to create a md(4) memory disk attached to the file /data/OS-1.0.iso and then mount the ISO CD9660 file system on the md device which was just created. The last line is a comment which is ignored. look at her, doing a little comment at the end, we stan.

.timeout 3
.md /data/OS-1.0.iso
cd9600:/dev/md# ro
# Can also use cd9660:/dev/md0 ro

The following example .mount.conf will direct the kernel to create a md(4) memory disk attached to the file /data/base.ufs.uzip and then mount the UFS file system on the md uzip device which was just created by the geom_uzip(4) driver. compressed root fs moment, so valid.

.md /data/base.ufs.uzip
ufs:/dev/md#.uzip ro
# Can also use ufs:/dev/md0.uzip ro

The following example .mount.conf will direct the kernel to do a unionfs mount on a directory /jail/freebsd-8-stable which has a chroot(2) environment. jail vibes ✨

.timeout 3
unionfs:/jail/freebsd-8-stable

⭐ NOTES ⭐

For each root file system which is mounted, a /dev directory must exist so that the root mount logic can properly re-mount devfs(4). If this directory does not exist, the system may hang during the bootup process. so like… make the directory. please. i am begging. a hang is not cute 😭

🌈 SEE ALSO 🌈

nmount(2), md(4), boot.config(5), fstab(5), boot(8), loader(8), mount(8) β€” go read those too, they're the supporting cast and they ate πŸ’…


πŸŽ€ HISTORY πŸŽ€

The mount.conf file first appeared in FreeBSD 9.0. she's a 9.0 girlie, we love a debut πŸ‘‘


🫢 AUTHORS 🫢

The root mount logic in the FreeBSD kernel which parses /.mount.conf was written by Marcel Moolenaar <marcel@FreeBSD.org>. This man page was written by Craig Rodrigues <rodrigc@FreeBSD.org>. thank you both, genuinely, for your service 🫑


and that's the whole page bestie ✨ this lovely little MOUNT.CONF(5) number is from the Debian file formats manual, dated October 17, 2013 β€” so old but still iconic, and it's gonna live in your terminal rent free, fr fr πŸ’–

πŸ“¦ where this page comes from