initramfs-tools reports "can't identify type of root filesystem" when label is missing

Bug #2068077 reported by Brett Holman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

When I attempt to regenerate an initramfs for a new root filsystem, update-initramfs is unable to identify the filesystem type of this initramfs.

```
# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-5.15.0-1059-kvm
W: Couldn't identify type of root file system for fsck hook
W: mkconf: MD subsystem is not loaded, thus I cannot scan for arrays.
W: mdadm: failed to auto-generate temporary mdadm.conf file.
```

the mounted filesystem:
```
# cat /proc/mounts | grep xfs
/dev/sda1 / xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0
```

fstab:
```
# cat /etc/fstab | grep xfs
LABEL=cloudimg-rootfs / xfs defaults 0 1
```

cmdline:
```
BOOT_IMAGE=/boot/vmlinuz-5.15.0-1059-kvm root=PARTUUID=575c9681-fb9d-457c-a3b5-407dda61a919 ro console=tty1 console=ttyS0 panic=-1
```

The failure is in hooks/fsck when it calls resolve_device(). The function returns 1 and echos nothing because it has a LABEL, not a UUID or PARTUUID.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: initramfs-tools 0.140ubuntu13.4
ProcVersionSignature: Ubuntu 5.15.0-1059.64-kvm 5.15.149
Uname: Linux 5.15.0-1059-kvm x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Wed Jun 5 01:25:29 2024
PackageArchitecture: all
ProcEnviron:
 TERM=vt220
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=C.UTF-8
 SHELL=/bin/bash
SourcePackage: initramfs-tools
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Brett Holman (holmanb) wrote :
Revision history for this message
Benjamin Drung (bdrung) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. I failed to reproduce the issue. I took a jammy VM and added a label to the boot device:

```
sudo tune2fs -L somelabel /dev/vda3
```

Configured fstab to look for the label:

```
$ grep -w / /etc/fstab | grep -v ^#
LABEL=somelabel / ext4 errors=remount-ro 0 1
```

and successfully updated the initrd:

```
$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-6.5.0-35-generic
```

I checked the call from `resolve_device`:

```
$ blkid -l -t LABEL=somelabel -o device
/dev/vda3
```

Can you let mkinitramfs run with `set -x` to get some log messages?

Revision history for this message
Brett Holman (holmanb) wrote :

After digging in a little bit I noticed that this is just a case of a confusing error message. It turns out that the label was just missing from this filesystem. I'll update the bug title accordingly.

summary: - initramfs-tools can't identify root filesystem type
+ initramfs-tools reports "can't identify type of root filesystem" when
+ label is missing
Revision history for this message
Benjamin Drung (bdrung) wrote :

Suggestion:

```
diff --git a/hooks/fsck b/hooks/fsck
index f6348e81..5e5b6aae 100755
--- a/hooks/fsck
+++ b/hooks/fsck
@@ -44,6 +44,7 @@ _read_fstab_entry () {
 # Find a specific fstab entry and print its type (if found, and pass != 0)
 # $1=mountpoint
 get_fsck_type_fstab () {
+ local device
        eval "$(_read_fstab_entry "$1")"

        # Not found by default.
@@ -51,9 +52,9 @@ get_fsck_type_fstab () {
                # Ignore filesystem type for /, as it is not available and
                # therefore never used at boot time
                if [ "${MNT_DIR}" = "/" ] || [ "${MNT_TYPE}" = "auto" ]; then
- MNT_FSNAME="$(resolve_device "${MNT_FSNAME}")"
- if ! get_fstype "${MNT_FSNAME}"; then
- echo "W: Couldn't identify type of $2 file system for fsck hook" >&2
+ device="$(resolve_device "${MNT_FSNAME}")"
+ if ! get_fstype "${device}"; then
+ echo "W: Couldn't identify type of $2 file system '$MNT_FSNAME' for fsck hook" >&2
                        fi
                else
                        echo "${MNT_TYPE}"
```

This would change the error message to:

```
$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-6.8.0-22-generic
W: Couldn't identify type of root file system 'LABEL=foo' for fsck hook
```

Revision history for this message
Brett Holman (holmanb) wrote :

I haven't tested the diff, but this looks like an improvement to me. The new output message improves the messaging to the user with a clue that LABEL resolution is involved in fs type lookup and a possible source of the issue.

+1 thanks @bdrung

Benjamin Drung (bdrung)
Changed in initramfs-tools (Ubuntu):
importance: Undecided → Low
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.142ubuntu29

---------------
initramfs-tools (0.142ubuntu29) oracular; urgency=medium

  [ Jeffery To ]
  * Fix resume failure due to resume=UUID=... in certain cases (LP: #1769297)

  [ Benjamin Drung ]
  * resume: always write valid resume device to /sys/power/resume (LP: #1769297)
  * fsck: Mention file system name in failed identification warning
    (LP: #2068077)

 -- Benjamin Drung <email address hidden> Wed, 03 Jul 2024 13:55:55 +0200

Changed in initramfs-tools (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.