Skip to content

Commit

Permalink
Allow use of pool GUID as root pool
Browse files Browse the repository at this point in the history
It's helpful if there are pools with same names,
but you need to use only one of them.

Main case is twin servers, meanwhile some software
requires the same name of pools (e.g. Proxmox).

Reviewed-by: Kash Pande <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: George Melikov <[email protected]>
Signed-off-by: Igor ‘guardian’ Lidin of Moscow, Russia
Closes openzfs#8052
  • Loading branch information
gmelikov authored and BrainSlayer committed Oct 28, 2018
1 parent eefdda1 commit 1cb5176
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion contrib/initramfs/scripts/zfs.in
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ import_pool()

# Verify that the pool isn't already imported
# Make as sure as we can to not require '-f' to import.
"${ZPOOL}" status "$pool" > /dev/null 2>&1 && return 0
"${ZPOOL}" get name,guid -o value -H 2>/dev/null | grep -Fxq "$pool" && return 0

# For backwards compatibility, make sure that ZPOOL_IMPORT_PATH is set
# to something we can use later with the real import(s). We want to
Expand Down Expand Up @@ -772,6 +772,7 @@ mountroot()
# root=zfs:<pool>/<dataset> (uses this for rpool - first part, without 'zfs:')
#
# Option <dataset> could also be <snapshot>
# Option <pool> could also be <guid>

# ------------
# Support force option
Expand Down Expand Up @@ -889,6 +890,14 @@ mountroot()
/bin/sh
fi

# In case the pool was specified as guid, resolve guid to name
pool="$("${ZPOOL}" get name,guid -o name,value -H | \
awk -v pool="${ZFS_RPOOL}" '$2 == pool { print $1 }')"
if [ -n "$pool" ]; then
ZFS_BOOTFS="${pool}/${ZFS_BOOTFS#*/}"
ZFS_RPOOL="${pool}"
fi

# Set elevator=noop on the root pool's vdevs' disks. ZFS already
# does this for wholedisk vdevs (for all pools), so this is only
# important for partitions.
Expand Down

0 comments on commit 1cb5176

Please sign in to comment.