linux kernel在初始化末尾会mount rootfs。有时会mount失败,出现类似下面的log:
[ 0.623289] /dev/root: Can't open blockdev [ 0.624045] VFS: Cannot open root device "" or unknown-block(0,0): error -6 [ 0.625312] Please append a correct "root=" boot option; here are the available partitions: [ 0.626789] fe00 20971520 vda [ 0.626793] driver: virtio_blk [ 0.628031] fe01 524288 vda1 dfb03d22-39d2-8546-8d5d-04de64008a17 [ 0.628035] [ 0.629595] fe02 20446191 vda2 83a251ae-6507-824a-b614-5e9619f1dded [ 0.629598] [ 0.631120] fe10 366 vdb [ 0.631123] driver: virtio_blk [ 0.632356] 1f00 131072 mtdblock0 [ 0.632359] (driver?) [ 0.633561] List of all bdev filesystems: [ 0.634278] ext3 [ 0.634280] ext4 [ 0.634636] ext2 [ 0.634992] squashfs [ 0.635357] vfat [ 0.635773] [ 0.636409] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [ 0.637919] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-g708283abf896 #187 [ 0.639271] Hardware name: linux,dummy-virt (DT) [ 0.640144] Call trace: [ 0.640616] dump_backtrace+0x90/0xe8 [ 0.641325] show_stack+0x18/0x24 [ 0.641959] dump_stack_lvl+0x48/0x60 [ 0.642691] dump_stack+0x18/0x24 [ 0.643333] panic+0x314/0x370 [ 0.643919] mount_root_generic+0x240/0x31c [ 0.644775] mount_root+0x164/0x2d4 [ 0.645438] prepare_namespace+0x6c/0x298 [ 0.646196] kernel_init_freeable+0x240/0x280 [ 0.647020] kernel_init+0x24/0x1e0 [ 0.647696] ret_from_fork+0x10/0x20 [ 0.648377] SMP: stopping secondary CPUs [ 0.649149] Kernel Offset: 0x51b71a800000 from 0xffff800080000000 [ 0.650290] PHYS_OFFSET: 0xffffdef400000000 [ 0.651082] CPU features: 0x00800000,8a0100a1,08004203 [ 0.652054] Memory Limit: none [ 0.652639] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
这个kernel提示比较明显,让你加"root="的kernel参数。这个错误一般检查一下root的参数即可解决。
也有时候出现下面的log
[ 0.625071] List of all partitions: [ 0.625723] fe00 20971520 vda [ 0.625727] driver: virtio_blk [ 0.626963] fe01 524288 vda1 dfb03d22-39d2-8546-8d5d-04de64008a17 [ 0.626966] [ 0.628489] fe02 20446191 vda2 83a251ae-6507-824a-b614-5e9619f1dded [ 0.628492] [ 0.630118] fe10 366 vdb [ 0.630121] driver: virtio_blk [ 0.631351] 1f00 131072 mtdblock0 [ 0.631354] (driver?) [ 0.632524] No filesystem could mount root, tried: [ 0.632526] ext3 [ 0.633451] ext4 [ 0.633809] ext2 [ 0.634163] squashfs [ 0.634517] vfat [ 0.634941] [ 0.635575] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,16) [ 0.637096] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-g708283abf896 #187 [ 0.638444] Hardware name: linux,dummy-virt (DT) [ 0.639325] Call trace: [ 0.639798] dump_backtrace+0x90/0xe8 [ 0.640500] show_stack+0x18/0x24 [ 0.641136] dump_stack_lvl+0x48/0x60 [ 0.641872] dump_stack+0x18/0x24 [ 0.642506] panic+0x314/0x370 [ 0.643103] mount_root_generic+0x304/0x31c [ 0.643941] mount_root+0x164/0x2d4 [ 0.644606] prepare_namespace+0x6c/0x298 [ 0.645364] kernel_init_freeable+0x240/0x280 [ 0.646186] kernel_init+0x24/0x1e0 [ 0.646867] ret_from_fork+0x10/0x20 [ 0.647551] SMP: stopping secondary CPUs [ 0.648311] Kernel Offset: 0x2b04a7400000 from 0xffff800080000000 [ 0.649453] PHYS_OFFSET: 0xffffa1f300000000 [ 0.650243] CPU features: 0x00800000,8a0100a1,08004203 [ 0.651218] Memory Limit: none [ 0.651805] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,16) ]---
这个并没有说明是什么问题,只是说尝试了几种文件系统去mount,但是都失败了,然后列举了所有blk的分区。这种情况大概率也是root设置的问题,应该是root设置错误造成的,重新设置root即可解决。
[ 0.544225] VFS: Cannot open root device "/dev/vda2" or unknown-block(0,0): error -6 [ 0.545590] Please append a correct "root=" boot option; here are the available partitions: [ 0.547094] 1f00 131072 mtdblock0 [ 0.547098] (driver?) [ 0.548267] List of all bdev filesystems: [ 0.548981] ext3 [ 0.548983] ext4 [ 0.549346] ext2 [ 0.549700] squashfs [ 0.550053] vfat [ 0.550466] [ 0.551135] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [ 0.552576] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.5.0-g708283abf896 #188 [ 0.553848] Hardware name: linux,dummy-virt (DT) [ 0.554672] Call trace: [ 0.555147] dump_backtrace+0x90/0xe8 [ 0.555850] show_stack+0x18/0x24 [ 0.556483] dump_stack_lvl+0x48/0x60 [ 0.557254] dump_stack+0x18/0x24 [ 0.557887] panic+0x314/0x370 [ 0.558472] mount_root_generic+0x240/0x31c [ 0.559331] mount_root+0x164/0x2d4 [ 0.559994] prepare_namespace+0x6c/0x298 [ 0.560752] kernel_init_freeable+0x240/0x280 [ 0.561581] kernel_init+0x24/0x1e0 [ 0.562248] ret_from_fork+0x10/0x20 [ 0.562928] SMP: stopping secondary CPUs [ 0.563694] Kernel Offset: 0x342273c00000 from 0xffff800080000000 [ 0.564833] PHYS_OFFSET: 0xffffd14880000000 [ 0.565629] CPU features: 0x00800000,8a0100a1,08004203 [ 0.566592] Memory Limit: none [ 0.567176] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) ]---
虽然log提示是root设置不对,但是其实是blk驱动缺失造成的,因为他没有列出各个blk dev的分区。这种可以检查kernel是不是缺少了blk驱动,enable and build then try again。
[ 0.657479] /dev/root: Can't open blockdev [ 0.658218] VFS: Cannot open root device "/dev/vda2" or unknown-block(254,2): error -6 [ 0.659650] Please append a correct "root=" boot option; here are the available partitions: [ 0.661117] fe00 20971520 vda [ 0.661121] driver: virtio_blk [ 0.662299] fe01 20971519 vda1 00000000-01 [ 0.662302] [ 0.663437] fe10 366 vdb [ 0.663439] driver: virtio_blk [ 0.664629] List of all bdev filesystems: [ 0.665325] ext3 [ 0.665327] ext4 [ 0.665664] ext2 [ 0.666001] squashfs [ 0.666340] vfat [ 0.666737] [ 0.667352] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,2) [ 0.668821] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.5.0-g708283abf896 #189 [ 0.670077] Hardware name: QEMU KVM Virtual Machine, BIOS unknown 2/2/2022 [ 0.671297] Call trace: [ 0.671752] dump_backtrace+0x90/0xe8 [ 0.672442] show_stack+0x18/0x24 [ 0.673060] dump_stack_lvl+0x48/0x60 [ 0.673741] dump_stack+0x18/0x24 [ 0.674358] panic+0x314/0x370 [ 0.674927] mount_root_generic+0x240/0x31c [ 0.675704] mount_root+0x164/0x2d4 [ 0.676360] prepare_namespace+0x6c/0x298 [ 0.677099] kernel_init_freeable+0x240/0x280 [ 0.677902] kernel_init+0x24/0x1e0 [ 0.678548] ret_from_fork+0x10/0x20 [ 0.679208] SMP: stopping secondary CPUs [ 0.679951] Kernel Offset: 0x120000 from 0xffff800080000000 [ 0.680994] PHYS_OFFSET: 0x40000000 [ 0.681645] CPU features: 0x00800000,0a0100a1,08004203 [ 0.682598] Memory Limit: none [ 2.643124] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,2) ]---
在这个log中vda的俩分区没有全部识别出来,vda1的guid看起来也不对。这是由于系统是从uefi启动,缺少CONFIG_EFI_PARTITION。enable这个config,build再试。
标签:kernel,Kernel,panic,mount,0x24,linux,root From: https://www.cnblogs.com/banshanjushi/p/17677402.html