Bug 153666 - [rc.d][patch] mount filesystems from fstab over zfs datasets (early)
Summary: [rc.d][patch] mount filesystems from fstab over zfs datasets (early)
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 9.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-01-04 00:00 UTC by swell.k
Modified: 2022-10-17 12:40 UTC (History)
0 users

See Also:


Attachments
a.diff (1.66 KB, patch)
2011-01-04 00:00 UTC, swell.k
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description swell.k 2011-01-04 00:00:23 UTC
Provide a way to mount zfs datasets before fstab(5) but...

- unlike rc.d/mountlate do it more early before starting daemons or
  anything that may use them

- unlike rc.d/mountcritlocal allows to mount /boot dataset more early
  and not fail if filesystem module cannot be loaded

- unlike mounting datasets from fstab use zfs properties like noatime,
  noexec, mountpoint, etc

So, the workaround in conf/122036 may not be suitable for all cases.
And my solution tries to solve remaining integration issues of

  zfs mount -a vs. fstab

because even if one considers zfs mount superior and ditches fstab there
are still filesystems not managed by zfs(8).

Another way to solve it and which is easier to understand is smth like

  zfs_root=YES

that runs rc.d/zfs before rc.d/mountcritlocal. This way all datatesets
not marked by canmount=(off|noauto) should be mounted before fstab.

Fix: Note, rc.d/root allows us to create directories if they do not exist.
How-To-Repeat: 1. create a zfsroot system

     $ zpool create \
         -O mountpoint=/ \
         -O atime=off \
         -O compression=on \
         tank gptid/A-B-C-D-E

     # create uncompressed dataset containing /boot,
     # e.g. for multiboot using grub2
     $ zfs create -o compression=off tank/boot
     $ zpool set bootfs=tank/boot

     $ zfs create -o atime=on tank/var
     [...]
     $ zfs list -o name,mountpoint
     NAME               MOUNTPOINT
     tank               /
     tank/var           /var

     $ echo 'zfs_enable=YES' >>/etc/rc.conf

2. add fstab entries that depends on a zfs dataset

     # needs tmpfs.ko from tank/boot
     # needs /var/run from tank/var
     $ echo 'nil /var/run tmpfs rw' >>/etc/fstab

3. try to boot

     Copyright (c) 1992-2010 The FreeBSD Project.
     Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
             The Regents of the University of California. All rights reserved.
     FreeBSD is a registered trademark of The FreeBSD Foundation.
     FreeBSD 9.0-CURRENT-201012 #0: Tue Dec  7 20:28:03 UTC 2010
         root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
     [...]
     Trying to mount root from zfs:tank []...
     Setting hostuuid: 76445d7f-1786-11e0-aa8f-525400123456.
     Setting hostid: 0xe5f49767.
     No suitable dump device was found.
     Entropy harvesting: interrupts ethernet point_to_point kickstart.
     Starting file system checks:
     Mounting local file systems:mount: /var/run: No such file or directory
     .
     Mounting /etc/fstab filesystems failed,  startup aborted
     ERROR: ABORTING BOOT (sending SIGTERM to parent)!
     Jan  3 22:11:53 init: /bin/sh on /etc/rc terminated abnormally, going to single user mode
     Enter full pathname of shell or RETURN for /bin/sh:

but if /var/run exists boot fails with another error

     Mounting local file systems:mount: nil : Operation not supported by device
     .
     Mounting /etc/fstab filesystems failed,  startup aborted
     ERROR: ABORTING BOOT (sending SIGTERM to parent)!
     Jan  3 22:16:46 init: /bin/sh on /etc/rc terminated abnormally, going to single user mode
     Enter full pathname of shell or RETURN for /bin/sh:

4. apply the patch or just install mountzfsbeforelocal script
5. configure and try again

     $ echo 'zfs_mount_before_fstab="tank/boot tank/var"' >>/etc/rc.conf

     Copyright (c) 1992-2010 The FreeBSD Project.
     Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
             The Regents of the University of California. All rights reserved.
     FreeBSD is a registered trademark of The FreeBSD Foundation.
     FreeBSD 9.0-CURRENT-201012 #0: Tue Dec  7 20:28:03 UTC 2010
         root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
     [...]
     Trying to mount root from zfs:tank []...
     Setting hostuuid: 94a90edd-1784-11e0-8702-525400123456.
     Setting hostid: 0xb22ca790.
     No suitable dump device was found.
     Entropy harvesting: interrupts ethernet point_to_point kickstart.
     Starting file system checks:
     Mounting local file systems:WARNING: TMPFS is considered to be a highly experimental feature in FreeBSD.
     .
     [...]
     Mon Jan  3 21:59:08 UTC 2011

     FreeBSD/amd64 (qemu.local) (ttyu0)

     login:
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:28 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:40:39 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>