[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1033321: initramfs-tools-core: fsck.zfs missing from initrd when root filesystem on ZFS



Package: initramfs-tools-core
Version: 0.142
Severity: normal
Tags: patch

With a root filesystem on ZFS then mkinitramfs builds an initrd that
lacks fsck.zfs:

	testaroli# mkinitramfs -o /boot/initrd.img-$(uname -r)
	W: Couldn't identify type of root file system for fsck hook
	testaroli# zstdcat /boot/initrd.img-$(uname -r) | cpio -itv | grep fsck
	381518 blocks
	testaroli# 

I'm sure this patch will break more than it fixes, but at least it
worked for me and writing it here may help others in the short-term:

I edited /usr/share/initramfs-tools/hooks/fsck, located the code block:

	...
	if [ "${MNT_DIR}" = "/" ] || [ "${MNT_TYPE}" = "auto" ]; then
	    MNT_FSNAME="$(resolve_device "${MNT_FSNAME}")"
	    fstype() { "/usr/lib/klibc/bin/fstype" "$@"; }
	    if ! get_fstype "${MNT_FSNAME}"; then
	        echo "W: Couldn't identify type of $2 file system for fsck hook" >&2
	    fi
	    unset -f fstype
	else
	    ...

and replaced it with:

	...
	if [ "${MNT_DIR}" = "/" ] || [ "${MNT_TYPE}" = "auto" ]; then
	    mount | sed -rn "s@.* on $MNT_DIR type ([^ ]+) \\(.*@\\1@p"
	else
	    ...

(I.e. the body of the 'then' clause is replaced.)

After which rerunning the above test produced:

	testaroli# mkinitramfs -o /boot/initrd.img-$(uname -r)
	testaroli# zstdcat /boot/initrd.img-$(uname -r) | cpio -itv | grep fsck
	-rwxr-xr-x   1 root     root        55664 Feb 13 03:48 usr/sbin/fsck
	-rwxr-xr-x   1 root     root          762 Feb 25 23:32 usr/sbin/fsck.zfs
	381657 blocks
	testaroli# 

This might actually be *two* bugs in
two different packages (initramfs-tools-core because
/usr/share/initramfs-tools/hooks/fsck produces an ugly warning when
root filesysem is on ZFS; zfs-initramfs because it doesn't drop a
hook into /usr/share/initramfs-tools/hooks to get fsck.zfs included)
but certainly you know what is most appropriate better than I do.

-- System Information:
Debian Release: bookworm/sid
  APT prefers testing-security
  APT policy: (500, 'testing-security'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-6-amd64 (SMP w/2 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages initramfs-tools-core depends on:
ii  coreutils    9.1-1
ii  cpio         2.13+dfsg-7.1
ii  e2fsprogs    1.46.6-1
ii  klibc-utils  2.0.12-1
ii  kmod         30+20221128-1
ii  logsave      1.46.6-1
ii  udev         252.6-1

Versions of packages initramfs-tools-core recommends:
ii  busybox  1:1.35.0-4+b2
ii  zstd     1.5.4+dfsg2-3

Versions of packages initramfs-tools-core suggests:
pn  bash-completion  <none>

-- no debconf information


Reply to: