From owner-freebsd-rc@FreeBSD.ORG Tue Jan 4 00:00:24 2011 Return-Path: Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7F56106566B for ; Tue, 4 Jan 2011 00:00:24 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 63AE88FC0A for ; Tue, 4 Jan 2011 00:00:24 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p0400OWA082840 for ; Tue, 4 Jan 2011 00:00:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p0400O5G082835; Tue, 4 Jan 2011 00:00:24 GMT (envelope-from gnats) Resent-Date: Tue, 4 Jan 2011 00:00:24 GMT Resent-Message-Id: <201101040000.p0400O5G082835@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-rc@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Anonymous Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A101106564A for ; Mon, 3 Jan 2011 23:53:22 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 054F78FC08 for ; Mon, 3 Jan 2011 23:53:21 +0000 (UTC) Received: by gwj21 with SMTP id 21so6795639gwj.13 for ; Mon, 03 Jan 2011 15:53:21 -0800 (PST) Received: by 10.100.142.9 with SMTP id p9mr6869170and.220.1294098801120; Mon, 03 Jan 2011 15:53:21 -0800 (PST) Received: from localhost ([199.48.147.41]) by mx.google.com with ESMTPS id c30sm28744970anc.0.2011.01.03.15.53.16 (version=SSLv3 cipher=RC4-MD5); Mon, 03 Jan 2011 15:53:20 -0800 (PST) Message-Id: <86pqsd7dfg.fsf@gmail.com> Date: Tue, 04 Jan 2011 02:52:35 +0300 From: Anonymous To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: misc/153666: [rc.d][patch] mount filesystems from fstab over zfs datasets (early) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2011 00:00:24 -0000 >Number: 153666 >Category: misc >Synopsis: [rc.d][patch] mount filesystems from fstab over zfs datasets (early) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-rc >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Jan 04 00:00:23 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Anonymous >Release: FreeBSD 9.0-CURRENT amd64 >Organization: >Environment: zfsroot >Description: 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. >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: >Fix: Note, rc.d/root allows us to create directories if they do not exist. --- a.diff begins here --- Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf (revision 216917) +++ etc/defaults/rc.conf (working copy) @@ -57,6 +57,7 @@ # ZFS support zfs_enable="NO" # Set to YES to automatically mount ZFS file systems +zfs_mount_before_fstab="" # List of ZFS datasets to mount before fstab(5) gptboot_enable="YES" # GPT boot success/failure reporting. Index: etc/rc.d/mountzfsbeforelocal =================================================================== --- etc/rc.d/mountzfsbeforelocal (revision 0) +++ etc/rc.d/mountzfsbeforelocal (revision 0) @@ -0,0 +1,33 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: mountzfsbeforelocal +# REQUIRE: root +# BEFORE: mountcritlocal + +. /etc/rc.subr + +name="mountzfsbeforelocal" +rcvar="zfs_enable" +start_cmd="mountzfsbeforelocal_start" +stop_cmd="mountzfsbeforelocal_stop" +required_modules="zfs" + +mountzfsbeforelocal_start() +{ + for fs in $zfs_mount_before_fstab; do + zfs mount $fs + done +} + +mountzfsbeforelocal_stop() +{ + for fs in $zfs_mount_before_fstab; do + zfs umount $fs + done +} + +load_rc_config $name +run_rc_command "$1" Index: etc/rc.d/Makefile =================================================================== --- etc/rc.d/Makefile (revision 216917) +++ etc/rc.d/Makefile (working copy) @@ -20,7 +20,7 @@ jail \ kadmind kerberos keyserv kldxref kpasswdd \ ldconfig local localpkg lockd lpd \ - mixer motd mountcritlocal mountcritremote mountlate \ + mixer motd mountcritlocal mountcritremote mountlate mountzfsbeforelocal \ mdconfig mdconfig2 mountd moused mroute6d mrouted msgs \ named natd netif netoptions \ newsyslog nfsclient nfscbd nfsd \ --- a.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: