QEMU中的MIPS Linux内核在initrd上运行

时间:2018-07-24 01:57:41

标签: linux-kernel mips qemu boot

我从http://ftp.debian.org/debian/dists/Debian9.5/main/installer-mips/20170615+deb9u4/images/malta/netboot抓取了initrdvmlinux(内核4.9.0)映像,安装并启动了Qemu,就好了:

$ qemu-system-mips -M malta -m 1G -hda ./debian-mips.qcow2 \
      -initrd $initrd \
      -kernel $vmlinux \
      -append "nokaslr root=/dev/sda1" -nographic

然后,我使用与4.9.0相同的配置交叉编译了新内核4.18.0,但是这次Qemu无法启动:

...
[    4.036903] NET: Registered protocol family 17
[    4.045894] rtc_cmos 70.rtc: setting system clock to 2018-07-23 02:26:58 UTC (1532312818)
[    4.076247] Freeing unused kernel memory: 1528K
[    4.076491] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[    4.685538] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    4.703542] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    4.754874] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Begin: Waiting for suspend/resume device ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
...
done.
Gave up waiting for suspend/resume device
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ...
done.
done.
Gave up waiting for root file system device.  Common problems:
 - Boot args (cat /proc/cmdline)
   - Check rootdelay= (did the system wait long enough?)
 - Missing modules (cat /proc/modules; ls /dev)
ALERT!  /dev/sda1 does not exist.  Dropping to a shell!


BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs)

我相信我已经编译了所有必需的驱动程序/硬件支持,因为我使用的是相同的.config文件。另外,我安装了我的qemu映像,并在其中执行了make modules_install,因此该映像确实具有与内核版本匹配的正确模块。

更新

因此,我启用了DeviceDrivers/ATA/ATAPI/MFM/RLL support (DEPRECATED)DeviceDrivers/Serial ATA and Parallel ATA drivers (libata)下的所有驱动程序,重建内核,将其安装在qemu映像中,并启动:

[    4.437168] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[    4.442551] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
[    4.443553] ata1.00: 20971520 sectors, multi 16: LBA48 
[    4.478753] scsi 0:0:0:0: Direct-Access     ATA      QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
[    4.490907] sd 0:0:0:0: Attached scsi generic sg0 type 0
[    4.498621] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[    4.501629] sd 0:0:0:0: [sda] Write Protect is off
[    4.508063] scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     2.5+ PQ: 0 ANSI: 5
[    4.518142] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    4.539178] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    4.540712] cdrom: Uniform CD-ROM driver Revision: 3.20
[    4.564806] sr 1:0:0:0: Attached scsi generic sg1 type 5
[    4.569555]  sda: sda1 sda2 < sda5 >
[    4.588040] sd 0:0:0:0: [sda] Attached SCSI disk
[    5.102260] Freeing unused kernel memory: 1556K
[    5.102988] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[    7.297015] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    7.341169] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[    7.527445] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Will now check root file system ... fsck from util-linux 2.29.2
[/sbin/fsck.ext4 (1) -- /dev/sda1] fsck.ext4 -a -C0 /dev/sda1 
/dev/sda1: clean, 29311/628320 files, 454566/2512640 blocks
done.
mount: mounting /dev/sda1 on /root failed: No such device
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
done.

    mount: mounting /run on /root/run failed: No such file or directory
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
No init found. Try passing init= bootarg.

这里还有什么可能出问题了? 谢谢。

1 个答案:

答案 0 :(得分:0)

为了正确的FS挂载过程,内核配置必须包括以下选项:

a)Device Drivers/Serial ATA and Parallel ATA drivers (libata)-CONFIG_ATA_SFF,CONFIG_ATA_BMDMA,CONFIG_ATA_PIIX

b)Device Drivers/Generic Driver Options-CONFIG_DEVTMPFS