This commit is contained in:
Till Breithaupt 2024-07-17 07:17:34 +08:00 committed by GitHub
commit 231e8a8de1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 2 deletions

View File

@ -50,6 +50,24 @@ find_zfs_block_devices() {
done < /proc/self/mountinfo
}
find_add_zpool_mps() {
local dev
local mp
local fstype
local _
numfields="$(awk '{print NF; exit}' /proc/self/mountinfo)"
if [ "$numfields" = "10" ] ; then
fields="_ _ _ _ mp _ _ fstype dev _"
else
fields="_ _ _ _ mp _ _ _ fstype dev _"
fi
# shellcheck disable=SC2086
while read -r ${fields?} ; do
[ "$fstype" = "zfs" ] || continue
[ "$dev" = "$1" ] && echo "$mp"
done < /proc/self/mountinfo
}
array_contains () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
@ -75,6 +93,14 @@ check() {
# shellcheck disable=SC2154
if [[ -n "$hostonly" ]]; then
if [ -f @sysconfdir@/default/zfs ]; then
. @sysconfdir@/default/zfs
if [ -n "$ZFS_INITRD_ADDITIONAL_DATASETS" ]; then
for add_zpool in $ZFS_INITRD_ADDITIONAL_DATASETS; do
add_mps+=$(find_add_zpool_mps "$add_zpool")
done
fi
fi
for mp in \
"/" \
"/etc" \
@ -87,7 +113,8 @@ if [[ -n "$hostonly" ]]; then
"/usr/sbin" \
"/usr/lib" \
"/usr/lib64" \
"/boot";
"/boot" \
"${add_mps[@]}";
do
mp=$(readlink -f "$mp")
mountpoint "$mp" >/dev/null 2>&1 || continue

View File

@ -64,7 +64,8 @@ install() {
# -o ensures there is no error upon absence of these files
inst_multiple -o -H \
"@sysconfdir@/zfs/zpool.cache" \
"@sysconfdir@/zfs/vdev_id.conf"
"@sysconfdir@/zfs/vdev_id.conf" \
"@sysconfdir@/default/zfs"
# Synchronize initramfs and system hostid
if ! inst_simple -H @sysconfdir@/hostid; then

View File

@ -922,6 +922,15 @@ mountroot()
ZFS_RPOOL="${pool}"
fi
# We need to import additional zpools which aren't under root zpool, before mount_fs()
for add_zpool in $ZFS_INITRD_ADDITIONAL_DATASETS; do
add_zpool_base="${add_zpool%%/*}"
if [ "$add_zpool_base" != "$ZFS_RPOOL" ]
then
import_pool "${add_zpool_base}"
fi
done
# ----------------------------------------------------------------
# P R E P A R E R O O T F I L E S Y S T E M