From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 53CA2138334 for ; Wed, 27 Mar 2019 11:54:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5E40DE08D1; Wed, 27 Mar 2019 11:54:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 20F1CE08D1 for ; Wed, 27 Mar 2019 11:54:24 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0B146335D08 for ; Wed, 27 Mar 2019 11:54:22 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 754ED520 for ; Wed, 27 Mar 2019 11:54:20 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1553687634.4e46cfcd6f50560a9e8c31163663940a99875e0c.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_initramfs.sh genkernel X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 4e46cfcd6f50560a9e8c31163663940a99875e0c X-VCS-Branch: master Date: Wed, 27 Mar 2019 11:54:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b0b73cde-714c-474d-a71f-3923efa07cd1 X-Archives-Hash: 3ce89d80862e88f37d4ddaded10ba1d4 commit: 4e46cfcd6f50560a9e8c31163663940a99875e0c Author: Thomas Deutschmann gentoo org> AuthorDate: Wed Mar 27 11:53:54 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Wed Mar 27 11:53:54 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=4e46cfcd ZFS: Change hostid handling No need to deal with hostid value: We assume that /etc/hostid exists if ZFS is used. So just copy that existing file. If file is missing tell user that kernel command-line parameter "spl_hostid=" must be used. Same is true when generated initramfs is used for multiple systems. Closes: https://bugs.gentoo.org/531192 Closes: https://bugs.gentoo.org/616738 Signed-off-by: Thomas Deutschmann gentoo.org> gen_initramfs.sh | 26 ++++++++++++-------------- genkernel | 23 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index da5ffcf..7c41c2c 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -116,20 +116,6 @@ append_base_layout() { date -u '+%Y%m%d-%H%M%S' > ${TEMP}/initramfs-base-temp/etc/build_date echo "Genkernel $GK_V" > ${TEMP}/initramfs-base-temp/etc/build_id - # The ZFS tools want the hostid in order to find the right pool. - # Assume the initramfs we're building is for this system, so copy - # our current hostid into it. - # We also have to deal with binary+endianness here: glibc's gethostid - # expects the value to be in binary using the native endianness. But - # the coreutils hostid program doesn't show it in the right form. - local hostid - if file -L "${TEMP}/initramfs-base-temp/bin/sh" | grep -q 'MSB executable'; then - hostid="$(hostid)" - else - hostid="$(hostid | sed -E 's/(..)(..)(..)(..)/\4\3\2\1/')" - fi - printf "$(echo "${hostid}" | sed 's/\([0-9A-F]\{2\}\)/\\x\1/gI')" > ${TEMP}/initramfs-base-temp/etc/hostid - mkdir -p "${TEMP}/initramfs-base-temp/etc/mdev/helpers" install -m 644 -t "${TEMP}/initramfs-base-temp/etc" /usr/share/genkernel/mdev/mdev.conf install -m 755 -t "${TEMP}/initramfs-base-temp/etc/mdev/helpers" /usr/share/genkernel/mdev/helpers/nvme @@ -516,6 +502,18 @@ append_zfs(){ fi done + if [ -f "/etc/hostid" ] + then + local _hostid=$(hostid) + print_info 1 "$(getIndent 2)zfs: >> Embedding hostid '${_hostid}' into initramfs..." + cp -a /etc/hostid "${TEMP}/initramfs-zfs-temp/etc" 2> /dev/null \ + || gen_die "Failed to copy /etc/hostid" + + echo "${_hostid}" > "${TEMP}/.embedded_hostid" + else + print_info 2 "$(getIndent 2)zfs: /etc/hostid not found; You must use 'spl_hostid' kernel command-line parameter!" + fi + copy_binaries "${TEMP}/initramfs-zfs-temp" /sbin/{mount.zfs,zdb,zfs,zpool} cd "${TEMP}/initramfs-zfs-temp/" diff --git a/genkernel b/genkernel index c4ce4f8..25e9ca9 100755 --- a/genkernel +++ b/genkernel @@ -363,10 +363,25 @@ then isTrue "${DMRAID}" && print_warning 1 'add "dodmraid" for dmraid support' isTrue "${MDADM}" && print_warning 1 'add "domdadm" for MDRAID support' isTrue "${DMRAID}" && print_warning 1 ' or "dodmraid="' - isTrue "${ZFS}" && print_warning 1 'add "dozfs" for ZFS volume management support' - isTrue "${ZFS}" && print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=" to force booting from a specific dataset' - isTrue "${ZFS}" && print_warning 1 'If importing ZFS pool is slow, add dozfs=cache or dozfs=force to kernel commandline.' - isTrue "${ZFS}" && print_warning 1 '"man genkernel" explains "dozfs" in detail.' + + if isTrue "{ZFS}" + then + print_warning 1 'add "dozfs" for ZFS volume management support' + print_warning 1 ' and either "root=ZFS" to use bootfs autodetection or "root=ZFS=" to force booting from a specific dataset' + print_warning 1 '' + if [ -f "${TEMP}/.embedded_hostid" ] + then + local _hostid=$(cat "${TEMP}/.embedded_hostid") + print_warning '1' "Hostid '${_hostid}' is embedded into initramfs." + print_warning '1' "If you will use this initramfs for a different system you MUST set 'spl_hostid=' parameter to overwrite embedded hostid!" + else + print_warning '1' "No hostid embedded into initramfs. You MUST set 'spl_hostid=' parameter to provide hostid for ZFS!" + fi + print_warning 1 '' + print_warning 1 'If importing ZFS pool is slow, add dozfs=cache or dozfs=force to kernel commandline.' + print_warning 1 '"man genkernel" explains "dozfs" in detail.' + fi + isTrue "${BTRFS}" && print_warning 1 'add "dobtrfs" for Btrfs device scanning support' isTrue "${ISCSI}" && print_warning 1 'add at least "iscsi_initiatorname= iscsi_target= and iscsi_address=" for iscsi support'