Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: /
Date: Wed, 27 Mar 2019 11:54:26
Message-Id: 1553687634.4e46cfcd6f50560a9e8c31163663940a99875e0c.whissi@gentoo
1 commit: 4e46cfcd6f50560a9e8c31163663940a99875e0c
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 27 11:53:54 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 27 11:53:54 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=4e46cfcd
7
8 ZFS: Change hostid handling
9
10 No need to deal with hostid value: We assume that /etc/hostid exists if ZFS
11 is used. So just copy that existing file.
12
13 If file is missing tell user that kernel command-line parameter "spl_hostid=<hostid>"
14 must be used. Same is true when generated initramfs is used for multiple systems.
15
16 Closes: https://bugs.gentoo.org/531192
17 Closes: https://bugs.gentoo.org/616738
18 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
19
20 gen_initramfs.sh | 26 ++++++++++++--------------
21 genkernel | 23 +++++++++++++++++++----
22 2 files changed, 31 insertions(+), 18 deletions(-)
23
24 diff --git a/gen_initramfs.sh b/gen_initramfs.sh
25 index da5ffcf..7c41c2c 100755
26 --- a/gen_initramfs.sh
27 +++ b/gen_initramfs.sh
28 @@ -116,20 +116,6 @@ append_base_layout() {
29 date -u '+%Y%m%d-%H%M%S' > ${TEMP}/initramfs-base-temp/etc/build_date
30 echo "Genkernel $GK_V" > ${TEMP}/initramfs-base-temp/etc/build_id
31
32 - # The ZFS tools want the hostid in order to find the right pool.
33 - # Assume the initramfs we're building is for this system, so copy
34 - # our current hostid into it.
35 - # We also have to deal with binary+endianness here: glibc's gethostid
36 - # expects the value to be in binary using the native endianness. But
37 - # the coreutils hostid program doesn't show it in the right form.
38 - local hostid
39 - if file -L "${TEMP}/initramfs-base-temp/bin/sh" | grep -q 'MSB executable'; then
40 - hostid="$(hostid)"
41 - else
42 - hostid="$(hostid | sed -E 's/(..)(..)(..)(..)/\4\3\2\1/')"
43 - fi
44 - printf "$(echo "${hostid}" | sed 's/\([0-9A-F]\{2\}\)/\\x\1/gI')" > ${TEMP}/initramfs-base-temp/etc/hostid
45 -
46 mkdir -p "${TEMP}/initramfs-base-temp/etc/mdev/helpers"
47 install -m 644 -t "${TEMP}/initramfs-base-temp/etc" /usr/share/genkernel/mdev/mdev.conf
48 install -m 755 -t "${TEMP}/initramfs-base-temp/etc/mdev/helpers" /usr/share/genkernel/mdev/helpers/nvme
49 @@ -516,6 +502,18 @@ append_zfs(){
50 fi
51 done
52
53 + if [ -f "/etc/hostid" ]
54 + then
55 + local _hostid=$(hostid)
56 + print_info 1 "$(getIndent 2)zfs: >> Embedding hostid '${_hostid}' into initramfs..."
57 + cp -a /etc/hostid "${TEMP}/initramfs-zfs-temp/etc" 2> /dev/null \
58 + || gen_die "Failed to copy /etc/hostid"
59 +
60 + echo "${_hostid}" > "${TEMP}/.embedded_hostid"
61 + else
62 + print_info 2 "$(getIndent 2)zfs: /etc/hostid not found; You must use 'spl_hostid' kernel command-line parameter!"
63 + fi
64 +
65 copy_binaries "${TEMP}/initramfs-zfs-temp" /sbin/{mount.zfs,zdb,zfs,zpool}
66
67 cd "${TEMP}/initramfs-zfs-temp/"
68
69 diff --git a/genkernel b/genkernel
70 index c4ce4f8..25e9ca9 100755
71 --- a/genkernel
72 +++ b/genkernel
73 @@ -363,10 +363,25 @@ then
74 isTrue "${DMRAID}" && print_warning 1 'add "dodmraid" for dmraid support'
75 isTrue "${MDADM}" && print_warning 1 'add "domdadm" for MDRAID support'
76 isTrue "${DMRAID}" && print_warning 1 ' or "dodmraid=<additional options>"'
77 - isTrue "${ZFS}" && print_warning 1 'add "dozfs" for ZFS volume management support'
78 - isTrue "${ZFS}" && print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>" to force booting from a specific dataset'
79 - isTrue "${ZFS}" && print_warning 1 'If importing ZFS pool is slow, add dozfs=cache or dozfs=force to kernel commandline.'
80 - isTrue "${ZFS}" && print_warning 1 '"man genkernel" explains "dozfs" in detail.'
81 +
82 + if isTrue "{ZFS}"
83 + then
84 + print_warning 1 'add "dozfs" for ZFS volume management support'
85 + print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>" to force booting from a specific dataset'
86 + print_warning 1 ''
87 + if [ -f "${TEMP}/.embedded_hostid" ]
88 + then
89 + local _hostid=$(cat "${TEMP}/.embedded_hostid")
90 + print_warning '1' "Hostid '${_hostid}' is embedded into initramfs."
91 + print_warning '1' "If you will use this initramfs for a different system you MUST set 'spl_hostid=<hostid>' parameter to overwrite embedded hostid!"
92 + else
93 + print_warning '1' "No hostid embedded into initramfs. You MUST set 'spl_hostid=<hostid>' parameter to provide hostid for ZFS!"
94 + fi
95 + print_warning 1 ''
96 + print_warning 1 'If importing ZFS pool is slow, add dozfs=cache or dozfs=force to kernel commandline.'
97 + print_warning 1 '"man genkernel" explains "dozfs" in detail.'
98 + fi
99 +
100 isTrue "${BTRFS}" && print_warning 1 'add "dobtrfs" for Btrfs device scanning support'
101 isTrue "${ISCSI}" && print_warning 1 'add at least "iscsi_initiatorname=<initiator name> iscsi_target=<target name> and iscsi_address=<target ip>" for iscsi support'