Re: VFS: Unable to mount root fs on unknown-block(0,0)

2023-11-29 Thread Peter Maydell
On Wed, 29 Nov 2023 at 15:08, 泰宇周  wrote:
>
> I tried to use febootstrap to make a roofs image for qemu-kvm.
> It reported that
>
> [1.766919] Kernel panic - not syncing: VFS: Unable to mount root fs 
> on unknown-block(0,0)

When the kernel tells you it can't mount the root filesystem,
the interesting part of the log is the part above this line,
which you haven't given us. There the kernel will tell you
what block devices it has found and what filesystems it
tried to load them with.

The problem generally is either:
  * wrong command line (i.e. you asked the kernel to look for
the rootfs in the wrong place)
 * the kernel doesn't have a driver for that block device in it
 * the kernel doesn't have a driver for that filesystem in it

In this case, you seem to be using a distro kernel. Those
are generally pretty stripped down with almost all their
device and filesystem drivers kept in an initrd. You haven't
told QEMU to load an initrd, and the kernel doesn't have the
drivers to directly mount the rootfs.

You should probably try passing the initrd to QEMU as well
as the kernel (-initrd argument).

thanks
-- PMM



access physical drive

2023-11-29 Thread txunum _
I cannot access a physical drive. When I try to I always get this permission 
denied message. I also have tried to run it as administrator but won't work.

$ qemu-img convert -f raw -O vhd .\\PhysicalDrive1 SDXC.vhd
C:\msys64\ucrt64\bin\qemu-img.exe: Could not open '\\.\PhysicalDrive1': Could 
not open device: Permission denied


VFS: Unable to mount root fs on unknown-block(0,0)

2023-11-29 Thread 泰宇周
I tried to use febootstrap to make a roofs image for qemu-kvm.

I frist generated a roofs with command

febootstrap -i coreutils -i vim centos79 centos_7.9 
[url]https://mirrors.163.com/centos/7/os/x86_64/[/url]

After that, I got a directory as following

> tree centos_7.9/ -L 1
centos_7.9/
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib64
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var

Then, I created a qemu image and copied all file from centos_7.9 to the image.

qemu-img create centos79.img 1g
mkfs.ext4 centos79.img
mkdir mnt_dir
sudo mount -o loop centos79.img mnt_dir
cp centos_7.9/* mnt_dir
umount mnt_dir

However, when I run 

qemu-system-x86_64 -kernel /boot/vmlinuz-`uname -r` \
-hda=centos79.img \
-append "root=/dev/sda console=ttyS0" \
-enable-kvm -nographic

or 

qemu-system-x86_64 -kernel /boot/vmlinuz-`uname -r` \
-drive file=centos79.img \
-append "root=/dev/hda console=ttyS0" \
-enable-kvm -nographic


It reported that

[1.766919] Kernel panic - not syncing: VFS: Unable to mount root fs on 
unknown-block(0,0)
[1.767906] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.14.0-3.1.0.kwai+ 
#10
[1.767906] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
0.5.1 01/01/2011
[1.767906] Call Trace:
[1.767906]  dump_stack_lvl+0x34/0x48
[1.767906]  panic+0xfb/0x2cd
[1.767906]  mount_block_root+0x28c/0x29f
[1.767906]  prepare_namespace+0x13b/0x16a
[1.767906]  kernel_init_freeable+0x17f/0x1a4
[1.767906]  ? rest_init+0xc0/0xc0
[1.767906]  kernel_init+0x16/0x130
[1.767906]  ret_from_fork+0x22/0x30
[1.767906] Kernel Offset: disabled
[1.767906] ---[ end Kernel panic - not syncing: VFS: Unable to mount 
root fs on unknown-block(0,0) ]---


What should I do to fix this?