diff options
author | Turbo Fredriksson <[email protected]> | 2015-09-22 09:56:28 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-09-29 11:42:24 -0700 |
commit | 57732964d35616d6c93b8377b1ed72c485d9d73d (patch) | |
tree | db0d1ab021f7972f451dab29e714a8a797c899cc /contrib | |
parent | 45838e3a414a7a1a5fb49dc528dee1d22449599b (diff) |
Init script fixes
* Fix regression - "OVERLAY_MOUNTS" should have been "DO_OVERLAY_MOUNTS".
* Fix update-rc.d commands in postinst. Thanx to subzero79@GitHub.
* Fix make sure a filesystem exists before trying to mount in mount_fs()
* Fix local variable usage.
* Fix to read_mtab():
* Strip control characters (space - \040) from /proc/mounts GLOBALY,
not just first occurrence.
* Don't replace unprintable characters ([/-. ]) for use in the variable
name with underscore. No need, just remove them all together.
* Add check_boolean() to check if a user configure option is
set ('yes', 'Yes', 'YES' or any combination there of) OR '1'.
Anything else is considered 'unset'.
* Add a ZFS_POOL_IMPORT to the default config.
* This is a semi colon separated list of pools to import ONLY.
* This is intended for systems which have _a lot_ of pools (from
a SAN for example) and it would be to many to put in the
ZFS_POOL_EXCEPTIONS variable..
* Add a config option "ZPOOL_IMPORT_OPTS" for adding additional options
to "zpool import".
* Add documentation and the chance of overriding the ZPOOL_CACHE
variable in the config file.
* Remove "sort" from find_pools() and setup_snapshot_booting().
Sometimes not available, and not really necessary.
Signed-off-by: Turbo Fredriksson <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ned Bass <[email protected]>
Issue #3816
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/initramfs/scripts/zfs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs index 8cdef0b54..6a78a46d2 100644 --- a/contrib/initramfs/scripts/zfs +++ b/contrib/initramfs/scripts/zfs @@ -96,12 +96,11 @@ find_rootfs() find_pools() { local CMD="$*" - local pools + local pools pool pools=$($CMD 2> /dev/null | \ grep -E "pool:|^[a-zA-Z0-9]" | \ sed 's@.*: @@' | \ - sort | \ while read pool; do \ echo -n "$pool;" done) @@ -114,6 +113,11 @@ get_pools() { local available_pools npools + if [ -n "${ZFS_POOL_IMPORT}" ]; then + echo "$ZFS_POOL_IMPORT" + return 0 + fi + # Get the base list of availible pools. available_pools=$(find_pools "$ZPOOL" import) @@ -185,7 +189,7 @@ get_pools() import_pool() { local pool="$1" - local dirs dir ZFS_CMD ZFS_STDERR ZFS_ERROR + local dirs dir # Verify that the pool isn't already imported # Make as sure as we can to not require '-f' to import. @@ -223,7 +227,7 @@ import_pool() [ "$quiet" != "y" ] && zfs_log_begin_msg \ "Importing pool '${pool}' using defaults" - ZFS_CMD="${ZPOOL} import -N ${ZPOOL_FORCE}" + ZFS_CMD="${ZPOOL} import -N ${ZPOOL_FORCE} ${ZPOOL_IMPORT_OPTS}" ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)" ZFS_ERROR="$?" if [ "${ZFS_ERROR}" != 0 ] @@ -235,7 +239,7 @@ import_pool() [ "$quiet" != "y" ] && zfs_log_begin_msg \ "Importing pool '${pool}' using cachefile." - ZFS_CMD="${ZPOOL} import -c ${ZPOOL_CACHE} -N ${ZPOOL_FORCE}" + ZFS_CMD="${ZPOOL} import -c ${ZPOOL_CACHE} -N ${ZPOOL_FORCE} ${ZPOOL_IMPORT_OPTS}" ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)" ZFS_ERROR="$?" fi @@ -308,7 +312,11 @@ load_module_initrd() mount_fs() { local fs="$1" - local mountpoint ZFS_CMD ZFS_STDERR ZFS_ERROR + local mountpoint + + # Check that the filesystem exists + "${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1 + [ "$?" -ne 0 ] && return 1 # Need the _original_ datasets mountpoint! mountpoint=$(get_fs_value "$fs" mountpoint) @@ -378,7 +386,6 @@ mount_fs() decrypt_fs() { local fs="$1" - local ZFS_CMD ZFS_STDERR ZFS_ERROR # If the 'zfs key' command isn't availible, exit right here. "${ZFS}" 2>&1 | grep -q 'key -l ' || return 0 @@ -449,7 +456,6 @@ decrypt_fs() destroy_fs() { local fs="$1" - local ZFS_CMD ZFS_STDERR ZFS_ERROR [ "$quiet" != "y" ] && \ zfs_log_begin_msg "Destroying '$fs'" @@ -487,7 +493,6 @@ clone_snap() local snap="$1" local destfs="$2" local mountpoint="$3" - local ZFS_CMD ZFS_STDERR ZFS_ERROR [ "$quiet" != "y" ] && zfs_log_begin_msg "Cloning '$snap' to '$destfs'" @@ -526,7 +531,6 @@ clone_snap() rollback_snap() { local snap="$1" - local ZFS_CMD ZFS_STDERR ZFS_ERROR [ "$quiet" != "y" ] && zfs_log_begin_msg "Rollback $snap" @@ -616,7 +620,7 @@ setup_snapshot_booting() # already exists, destroy it. Recursivly if [ $(get_fs_value "${rootfs}_${snapname}" type) ]; then filesystems=$("${ZFS}" list -oname -tfilesystem -H \ - -r "${ZFS_BOOTFS}" | sort -r) + -r -Sname "${ZFS_BOOTFS}") for fs in $filesystems; do destroy_fs "${fs}" done @@ -675,9 +679,7 @@ setup_snapshot_booting() # This is the main function. mountroot() { - local snaporig - local snapsub - local destfs + local snaporig snapsub destfs pool POOLS # ---------------------------------------------------------------- # I N I T I A L S E T U P |