initramfs fails to mount ext4 root partition or provide user intervention (even when ext4 module is available in the image)

Bug #309762 reported by Marques Johansson
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
klibc (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Jaunty by Marques Johansson

Bug Description

Binary package hint: initramfs-tools

The init scripts in initramfs do not mount an ext4 root partition, this leaves the user stuck at an (initram) prompt at a point that is too late for the user to correct matters. There are a few TODO notes in the local script that mention that there is not error handling when the FSTYPE detection or root mount fails. This should be addressed.

When dropped to the (initram) I was able to "modprobe ext4; mount /dev/sda1 /root", but attempting to run "exec init", resulted in a Kernel Panic.

The init local script had continued running past the root mount failure, so commands like these:
mount -n --bind /root/dev /dev/.static/dev
mount -n --move /dev /root/dev
mount -n --move /proc /root/proc
mount -n --move /sys /root/sys
had already been attempted before I could intervene and manually mount root. Running them myself, and trying to finish off the local script (which ends with something like "exec run-init .... </root/dev/console > /root/dev/console ... " resulted in a kernel panic that /root/dev/console could not be found.

I don't know why the ext4 mount was not successfully mounted, but I was able to work around this by adding a /etc/initramfs-tools/scripts/local-bottom/custom_mount_ext4 script:
#! /bin/sh
modprobe ext4
mount /dev/sda1 /root
mount /dev/disk/by-uuid/..... /root

I also copied this script to local-top. I am mounting it twice and in both locations because I'm not sure which 'mount' command worked or when the device file is available. The first attempt I made at this workaround was to do "modprobe ext4; mount /dev/sda1 /root" from local-top (see bug #309758). That gave the error that /dev/sda1 was not a device file - I suppose that is created by a script run later. It existed by the time I got the (initramfs) prompt.

Tags: ext4

Related branches

Revision history for this message
Marques Johansson (marques) wrote :

I believe in one of the conditions where I tried to work from the (initram) prompt the error I received when trying to move on to the root partitions /sbin/init was that ~ "(null) was an invalid runlevel".

Revision history for this message
Marques Johansson (marques) wrote :

It would be nice if it detected that it did not mount /root and then gave you a notice about that and gave you a shell with the instruction to 'type exit once /root is mounted to continue the start-up process'

Revision history for this message
Marques Johansson (marques) wrote :

In my list of commands that I issued to behave like the "local" init script, I referred to /mnt a few times where I meant to say /root. I didn't make this error at the console.

Revision history for this message
DiegoCG (diegocg) wrote :

The problem is that fstype doesn't detect a ext4 filesystem. It detects it as ext3, and tries to mount the rootfs with "mount -t ext3...", which fails because ext3 can't mount a ext4 filesystem.

The problem is in scripts/local:

========================
get_fstype ()
{
        local FS FSTYPE FSSIZE RET
        FS="${1}"

        # vol_id has a more complete list of file systems,
        # but fstype is more robust
        eval $(fstype "${FS}" 2> /dev/null)
========================

fstype pass ext3 as filesystem there.

It turns out that the "unreliable" vol_id detects the ext4 properly, while fstype does not...

Revision history for this message
feiy (eshangrao) wrote :

i got the bug two:

ubuntu jaunty
kernel:2.28.4

Revision history for this message
Martijn vdS (martijn) wrote :

I also see this on my system

Changed in initramfs-tools:
status: New → Confirmed
Revision history for this message
Martijn vdS (martijn) wrote :

Workaround: boot with the 'break=mount' option, mount the fs on /root yourself, and exit the shell. Booting should continue normally.

Revision history for this message
Bowmore (bowmore) wrote :

Confirm this bug.
I've tried the break=mount option too without success. I can mount an ext3 volume but still not an ext4.

$ mount /dev/sda1 /root
results in (obvious as ext3 defaults):
EXT3-fs: sda1: couldn't mount because of unsupported optional features (40)
mounting /dev/sda1 on /root failed: Invalid argument

$ mount /dev/sda1 -t ext4 /root
results in (sda1 is ext4):
mounting /dev/sda1 on /root failed: No such device

In my case I made a conversion ext3 to ext4 using this guide
http://kernelnewbies.org/Ext4
that is,
$ tune2fs -O extents,uninit_bg,dir_index /dev/sda1
$ fsck -pf /dev/sda1

uname -r
2.6.28-3-generic

So I guess it's up to what ext4 features you activate that makes the ext4 device mountable or not in the initramfs shell. However, I can boot up another Jaunty system an mount this "sda1" device there with success so the device itself is ok.

Revision history for this message
Marques Johansson (marques) wrote :

see Bug #309758 about adding the ext4 module to your initramfs image first. I gave some workarounds in there.. Basically, you have to get ext4 and it's dependent modules in the initramfs image, and you have to get the scripts to 'modprobe ext4' before you can mount the partition.

description: updated
description: updated
Revision history for this message
Bowmore (bowmore) wrote :

Sorry, but that update of the initramfs image made my sda1 unbootable.
Error 24: Attempt to access block outside partition.

What I did was, I chrooted the device and updated the initramfs image acc to bug #309758. Then at reboot error 24 was issued. I fscked the device with no error! It's still mountable from another system. So one way here might be (or is a must) to update the image before the ext3 to ext4 conversion. I'll give it a try.

Revision history for this message
Daniel Swarbrick (pressureman) wrote :

Just to confirm, the custom_mount_ext4 script is only needed in local-bottom.

Also, the `modprobe ext4` is not needed, since it's compiled into the kernel now. However, it's probably wise to using `-t ext4` as the mount option.

#! /bin/sh
mount -t ext4 /dev/sda1 /root
mount -t ext4 /dev/disk/by-uuid/...... /root

Works like a charm for me.

Revision history for this message
Bowmore (bowmore) wrote :

Works like a charm here too.

Brought up a second system successfully with ext4. The first try (error 24) showed up to be a misconfiguration in the grub's menu.lst and is now up and running as well.

The "script custom_mount_ext4" implemented in local-bottom only.
The "modprobe ext4" not used.

Revision history for this message
Daniel Swarbrick (pressureman) wrote :

An even simpler solution is to append rootfstype=ext4 to kopt in /boot/grub/menu.list, eg.

# kopt=root=UUID=24c707be-c824-4781-89bd-25ed9dba54f8 ro rootfstype=ext4

Then just run "sudo update-grub". No custom initramfs scripts needed.

Revision history for this message
Michael Marley (mamarley) wrote :

I can confirm that this works.

Revision history for this message
Cleber Santz (clebersantz) wrote :

Same error here ( using kernel 2.6.28-4, ext4 and grub2 ), solved adding rootfstype=ext4

Revision history for this message
kede (kede) wrote :

confirmed, rootfstype=ext4 works.

Revision history for this message
Colin Watson (cjwatson) wrote :

Hmm, odd, ext4 is supposed to be supported in klibc's fstype which should obviate the need for this. I'll investigate once I get installer support going.

Revision history for this message
Colin Watson (cjwatson) wrote :

I think this is fixed in klibc 1.5.15.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package klibc - 1.5.14-1~exp1ubuntu2

---------------
klibc (1.5.14-1~exp1ubuntu2) jaunty; urgency=low

  * 20_ext4.patch: Backport Theodore Ts'o's patch from 1.5.15 to fix
    ext4/ext4dev probing (LP: #309762).

 -- Colin Watson <email address hidden> Thu, 08 Jan 2009 13:53:41 +0000

Changed in klibc:
status: Confirmed → 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.