]> git.proxmox.com Git - zfsonlinux.git/blob - zfs-patches/0016-Allow-use-of-pool-GUID-as-root-pool.patch
update/rebase to zfs-0.7.12 with patches from ZOL
[zfsonlinux.git] / zfs-patches / 0016-Allow-use-of-pool-GUID-as-root-pool.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: George Melikov <mail@gmelikov.ru>
3 Date: Wed, 24 Oct 2018 06:06:40 +0300
4 Subject: [PATCH] Allow use of pool GUID as root pool
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 It's helpful if there are pools with same names,
10 but you need to use only one of them.
11
12 Main case is twin servers, meanwhile some software
13 requires the same name of pools (e.g. Proxmox).
14
15 Reviewed-by: Kash Pande <kash@tripleback.net>
16 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
17 Signed-off-by: George Melikov <mail@gmelikov.ru>
18 Signed-off-by: Igor ‘guardian’ Lidin of Moscow, Russia
19 Closes #8052
20 ---
21 contrib/initramfs/scripts/zfs | 11 ++++++++++-
22 1 file changed, 10 insertions(+), 1 deletion(-)
23
24 diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs
25 index 86329e76..dacd71d2 100644
26 --- a/contrib/initramfs/scripts/zfs
27 +++ b/contrib/initramfs/scripts/zfs
28 @@ -193,7 +193,7 @@ import_pool()
29
30 # Verify that the pool isn't already imported
31 # Make as sure as we can to not require '-f' to import.
32 - "${ZPOOL}" status "$pool" > /dev/null 2>&1 && return 0
33 + "${ZPOOL}" get name,guid -o value -H 2>/dev/null | grep -Fxq "$pool" && return 0
34
35 # For backwards compatibility, make sure that ZPOOL_IMPORT_PATH is set
36 # to something we can use later with the real import(s). We want to
37 @@ -772,6 +772,7 @@ mountroot()
38 # root=zfs:<pool>/<dataset> (uses this for rpool - first part, without 'zfs:')
39 #
40 # Option <dataset> could also be <snapshot>
41 + # Option <pool> could also be <guid>
42
43 # ------------
44 # Support force option
45 @@ -889,6 +890,14 @@ mountroot()
46 /bin/sh
47 fi
48
49 + # In case the pool was specified as guid, resolve guid to name
50 + pool="$("${ZPOOL}" get name,guid -o name,value -H | \
51 + awk -v pool="${ZFS_RPOOL}" '$2 == pool { print $1 }')"
52 + if [ -n "$pool" ]; then
53 + ZFS_BOOTFS="${pool}/${ZFS_BOOTFS#*/}"
54 + ZFS_RPOOL="${pool}"
55 + fi
56 +
57 # Set elevator=noop on the root pool's vdevs' disks. ZFS already
58 # does this for wholedisk vdevs (for all pools), so this is only
59 # important for partitions.