Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d Add support for mounting zfs filesystems to mountal...



details:   https://anonhg.NetBSD.org/src/rev/e72847972f09
branches:  trunk
changeset: 747919:e72847972f09
user:      haad <haad%NetBSD.org@localhost>
date:      Mon Oct 05 22:39:27 2009 +0000

description:
Add support for mounting zfs filesystems to mountall script. ZFS configuration
is stored in /etc/zpool.cache and it is automatically loaded to kernel from
filesystem. Filesystems are then configured accordingly to their properties
loaded from cache file.

diffstat:

 etc/rc.d/mountall |  38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r 5a34826e6ea4 -r e72847972f09 etc/rc.d/mountall
--- a/etc/rc.d/mountall Mon Oct 05 22:32:58 2009 +0000
+++ b/etc/rc.d/mountall Mon Oct 05 22:39:27 2009 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: mountall,v 1.6 2008/12/01 14:47:14 tsutsui Exp $
+# $NetBSD: mountall,v 1.7 2009/10/05 22:39:27 haad Exp $
 #
 
 # REQUIRE: mountcritremote named ypbind
@@ -9,8 +9,40 @@
 $_rc_subr_loaded . /etc/rc.subr
 
 name="mountall"
-start_cmd="echo 'Mounting all filesystems...'; mount -a"
-stop_cmd="echo 'Unmounting all filesystems...'; umount -a"
+start_cmd="mountall_start"
+stop_cmd="mountall_stop"
+
+mountall_start()
+{
+       echo 'Mounting all filesystems...'
+       if [ -f /etc/zfs/zpool.cache ]; then
+               # Get ZFS module loaded (and thereby, zvols created).
+               zfs list > /dev/null 2>&1
+               # Mount file systems noted in fstab.
+               mount -a
+               # Mount ZFS file systems.
+               zfs mount -a
+       else
+               # Mount file systems noted in fstab.
+               mount -a
+       fi
+}
+
+mountall_stop()
+{
+       echo 'Unmounting all filesystems...'
+       if [ -f /etc/zfs/zpool.cache ]; then
+               # Unmount ZFS file systems.
+               zfs unmount -a
+               # Unmount file systems noted in fstab.
+               umount -a
+               # Unload ZFS module, so disk devices are closed.
+               modunload zfs
+       else
+               # Otherwise, just deal with fstab.
+               umount -a
+       fi
+}
 
 load_rc_config $name
 run_rc_command "$1"



Home | Main Index | Thread Index | Old Index