]> git.proxmox.com Git - mirror_zfs.git/commitdiff
initramfs: Honor canmount=off
authorRichard Laager <rlaager@wiktel.com>
Fri, 24 Nov 2017 05:08:02 +0000 (23:08 -0600)
committerTony Hutter <hutter2@llnl.gov>
Tue, 5 Dec 2017 01:21:38 +0000 (17:21 -0800)
The initramfs script was not honoring canmount=off.  With this change,
it does.  If the administrator has asked that a filesystem not be
mounted, that should be honored.

As an exception, the initramfs script ignores canmount=off on the
rootfs.  The rootfs should not have canmount=off set either.  However,
mounting it anyway seems harmless because it is being asked for
explicitly.  The point of this exception is to avoid the risk of
breaking existing systems, just in case someone has canmount=off set on
their rootfs.

The initramfs still mounts filesystems with canmount=noauto.  This is
necessary because it is typical to set that on the rootfs so that it can
be cloned.  Without canmount=noauto, the clones' duplicate mountpoints
would conflict.

This is the remainder of the fix for:
https://github.com/zfsonlinux/pkg-zfs/issues/221

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Richard Laager <rlaager@wiktel.com>
Closes #6897

contrib/initramfs/scripts/zfs

index e66ed1d100fc285b3c7acd60e324d294fdbffac7..8770a2e8e1b7842d37e21ceac042ca9346629573 100644 (file)
@@ -317,6 +317,14 @@ mount_fs()
        "${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1
        [ "$?" -ne 0 ] && return 1
 
+       # Skip filesystems with canmount=off.  The root fs should not have
+       # canmount=off, but ignore it for backwards compatibility just in case.
+       if [ "$fs" != "${ZFS_BOOTFS}" ]
+       then
+               canmount=$(get_fs_value "$fs" canmount)
+               [ "$canmount" = "off" ] && return 0
+       fi
+
        # Need the _original_ datasets mountpoint!
        mountpoint=$(get_fs_value "$fs" mountpoint)
        if [ "$mountpoint" = "legacy" -o "$mountpoint" = "none" ]; then