2015年6月3日

Kernel Panic VFS under QEMU - Reason and HowTo

I've translated my page "QEMU環境で、Kernel Panic VFS が発生する場合の対処法 (確定) "
(summarized)

[What happens]

Kernel Panic - not syncing: VFS: Unnable to mount root fs on unknown-block (0, 0)
will be displayed in boot time.

Environment:
QEMU guest. VirtIO enabled (for /dev/vda*)
Using udev.


---
If you run lilo and you see

Fatal:raid_setup:stat("/dev/sda1")
-> Check lilo.conf

Fatal: do_disk: stat /dev/vda: No such file or directory
-> Check /dev/vda exists.

Fatal: Illegal 'root=' specification: /dev/vda1
-> Check /dev/vda1 exists.

[Why it happens]

In setup environment, major number of /dev/vda* are 254.
After setup (and rebooted), major number of /dev/vda* are 253.
(Major number in other environment may differ in other environment.)

With "root=":
"device with (major, minor) number (254, 1)" will be used as /dev/vda1. (Or the number when "lilo" command used)
So, boot with DVD works, boot from HDD fails.
If rerun "lilo" command after HDD (or DVD with boot option) boot, system will boot from HDD.
(as new and correct major number will be stored.)

With "append=" or "addappend=":
"/dev/vda1"(as passed as option string) will be used.
So, system will boot even when major number is changed.


---
cf:
We have to enabel 9Pfs in kernel (build) config.

# Networking support / Plan 9 Resource Shareing Support (9P2000)
CONFIG_NET_9P=y

# File systems / Network File Systems
CONFIG_9P_FS=y # depends on CONFIG_NET_9P=y etc.

If CONFIG_9P_FS is disabled, it also cause Kernel Panic VFS.
(as system cannot recognize /dev/vda)

[How to resolve]

If using LILO:

Pass "root=/dev/vda1" option is important part of this how-to.
It seems to be a timing problem.
After LILO knows what the /dev/vda1 is and pass "root=..." as option, it works.
"append=" or "addappend=" in lilo.conf will work under same mechanism.

---
If you cannot boot the system, try boot options.

With setup DVD, when displayd "boot:"
type
huge.s root=/dev/vda1 ro
and hit Enter.


After boot, you will see normal login prompt.

cf: "root=/dev/vda1" should not contain any space characters.
Space character will separate options.
NG: root = /dev/vda1
(it means "root", "=" and "/dev/vda1" are passed)

From HDD boot, when you sea Linux splash screen (if bitmap set),
hit Tab and boot: prompt displayed,
type (if your label is "Linux")
Linux root=/dev/vda1 ro
and hit Enter.


---
Check /dev/vda and /dev/vda1 are exist.

Sample:
ls -l /dev/vda*
brw-rw---- 1 root disk 254, 0 (time) /dev/vda
brw-rw---- 1 root disk 254, 1 (time) /dev/vda1
...

In setup environment, also check /dev/vda in your /dev/vda1 partition.
Sample:
mount /dev/vda1 /mnt
ls -l /mnt/dev/vda*

If /mnt/dev/vda* aren't exist in setup environment,
create them with SAME major number as /dev/vda*.
Using same major number is needed for "lilo" command to work.
mknod /dev/vda b 254 0
mknod /dev/vda1 b 254 1
chmod 660 /dev/vda
chmod 660 /dev/vda1
chown root:disk /dev/vda
chown root:disk /dev/vda1

Just /dev/vda and /dev/vda1 are enogh.
(In boot time, udev will automatically create /dev/vda*)

---
Modify "/etc/lilo.conf".
Use "addappend=" instead of "root=" in image section.



Also you need to add disk= and modify boot= setting
to use virtual disk (/dev/vda*)

---
/etc/lilo.conf (Sample)
# I have /(root) and /boot in /dev/vda1.

lba32

# Add disk= line.
# If you have more than 7 partitions in /dev/vda, use 15, 31 or 63 for max-partitions.
disk = /dev/vda bios=0x80 max-partitions=7

# Change /dev/sda to /dev/vda
boot = /dev/vda

# Copy your append=, vga= ... from lilo.conf
append=" vt.default_utf8=0"prompt
timeout = 50
vga = normal

# Linux bootable partition config
# Copy your image= from lilo.conf
image = /boot/vmlinuz

#  Do NOT put spaces in each options.
# NG: addappend=" root = /dev/vda1"
addappend=" root=/dev/vda1"

label = Linux
read-only
# Linux bootable partition config ends

---
Save lilo.conf and call "lilo".
Check "Added Linux *" is displayed.


If using GRUB:

kernel /boot/vmlinuz root=/dev/vda1 ... may work. (Sorry, I've not tested.)
If it doesn't,this how-to will not work for you.

Search google with keyword "udev fix major number".


--- added ---
There are "/(root) or /boot on LVM" problems, but using LVM may be onother choice.
4.4.8. Persistent Device Numbers
Some applications work best if the block device always is activated with the same device (major and minor) number. You can specify these with the lvcreate and the lvchange commands by using the following arguments:
--persistent y --major major --minor minor
Use a large minor number to be sure that it has not already been allocated to another device dynamically.
LINUX ALLOCATED DEVICES (2.6+ version)
Select major number in "local/experimental use" range.
240-254 block LOCAL/EXPERIMENTAL USE
Allocated for local/experimental use. For devices not
assigned official numbers, these ranges should be
used in order to avoid conflicting with future assignments.
ref:
Installing Slackware on Logical volumes

0 件のコメント:

コメントを投稿