Skip to content

Commit

Permalink
init/mount: print pretty name of root device when panics
Browse files Browse the repository at this point in the history
Given a wrong root device, current log may not give the pretty name
which is useful to locate root cause.

For example, there are 2 blk devs in a VM, /dev/vda which has 2 partitials
/dev/vda1 and /dev/vda2 and /dev/vdb which is blank. /dev/vda2 is the
right root dev. When set "root=/dev/vdb", we get error log:

[    0.635575] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,16)

It's not straightforward to find out the root cause as there is lack of
the root devive name therefore hard for people to get those info from the
device number, in the example, (254,16).

It is more comprehensive way to hint the root cause if pretty name is
given here, like:

[    0.559887] Kernel panic - not syncing: VFS: Unable to mount root fs on "/dev/vdb" or unknown-block(254,16)

Signed-off-by: Jianyong Wu <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
jongwu authored and brauner committed Oct 19, 2023
1 parent ddf9e2f commit 84d2b69
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion init/do_mounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void __init mount_root_generic(char *name, char *pretty_name, int flags)
for (i = 0, p = fs_names; i < num_fs; i++, p += strlen(p)+1)
printk(" %s", p);
printk("\n");
panic("VFS: Unable to mount root fs on %s", b);
panic("VFS: Unable to mount root fs on \"%s\" or %s", pretty_name, b);
out:
put_page(page);
}
Expand Down

0 comments on commit 84d2b69

Please sign in to comment.