2017-03-18 199 views
0

我是qemu的新手,我正在努力學習內核編程,我創建了一個忙框的initrd,但是當我添加一個大的tarbal〜80Mb cpio qemu無法加載。當我的initrd(cpio)很大〜80 MB時,Qemu無法加載

我想將golang包含在intrd中,這樣我就可以測試新的內核。

這是正在發生的事情:

[email protected] ~/os/busybox/test_build 
% ls 
bin linuxrc sbin usr 
[email protected] ~/os/busybox/test_build 
% !find 
find . | cpio -o -H newc | gzip > rootfs_bb.gz 
cpio: File ./rootfs_bb.gz grew, 1261568 new bytes not copied 
7374 blocks 
[email protected] ~/os/busybox/test_build 
% ls -ltrh 
total 2.6M 
drwxr-xr-x 2 mfrw mfrw 4.0K Mar 18 01:56 bin 
lrwxrwxrwx 1 mfrw mfrw 11 Mar 18 01:56 linuxrc -> bin/busybox 
drwxr-xr-x 2 mfrw mfrw 4.0K Mar 18 01:56 sbin 
drwxr-xr-x 4 mfrw mfrw 4.0K Mar 18 15:24 usr 
-rw-r--r-- 1 mfrw mfrw 2.6M Mar 18 15:31 rootfs_bb.gz 
[email protected] ~/os/busybox/test_build 
% 

然後我用QEMU與rootfs的一個新鮮的內核運行= 2.6M,

[email protected] ~/os/linux_staging % qemu-system-x86_64 -nographic -no-reboot -kernel arch/x86/boot/bzImage -initrd ./../busybox/test_build/rootfs_bb.gz -append "panic=1 console=ttyS0 rdinit=/bin/sh" 
[ 0.000000] Linux version 4.11.0-rc2+ ([email protected]) (gcc version 6.3.1 20170109 (GCC)) #7 SMP Sat Mar 18 02:34:27 IST 2017 
[ 0.000000] Command line: panic=1 console=ttyS0 rdinit=/bin/sh 
[ 0.000000] x86/fpu: x87 FPU will use FXSAVE 
[ 0.000000] e820: BIOS-provided physical RAM map: 
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable 
...... the kernel boots fine 

但是當我包括golang tar.gz的在根文件系統,它拍攝高達80M,然後啓動失敗

[email protected] ~/os/busybox/test_build 
% cp ~/go/go1.6.linux-amd64.tar.gz usr 
[email protected] ~/os/busybox/test_build 
% !fin 
find . | cpio -o -H newc | gzip > rootfs_bb.gz 
170406 blocks 
[email protected] ~/os/busybox/test_build 
% ls -ltrh 
total 82M 
drwxr-xr-x 2 mfrw mfrw 4.0K Mar 18 01:56 bin 
lrwxrwxrwx 1 mfrw mfrw 11 Mar 18 01:56 linuxrc -> bin/busybox 
drwxr-xr-x 2 mfrw mfrw 4.0K Mar 18 01:56 sbin 
drwxr-xr-x 4 mfrw mfrw 4.0K Mar 18 15:34 usr 
-rw-r--r-- 1 mfrw mfrw 82M Mar 18 15:34 rootfs_bb.gz 
[email protected] ~/os/busybox/test_build 
% 

我嘗試用相同的命令來運行它,它無法運行...

[email protected] ~/os/linux_staging % qemu-system-x86_64 -nographic -no-reboot -kernel arch/x86/boot/bzImage -initrd ./../busybox/test_build/rootfs_bb.gz -append "panic=1 console=ttyS0 rdinit=/bin/sh" 
.... no .. output 

我在做什麼錯?任何指針請:)

+0

也許內核配置有小的默認的initrd/initramfs的大小? – 0andriy

+0

使用initramfs而不是initrd(已棄用)。 initramfs是動態調整大小的,並且可以與可用內存一樣大。順便說一句,直到內核引導序列的後期(即設備初始化之後)才訪問rootfs。如果你得到*「no ... output」*,那麼內核初始化失敗。嘗試啓用** earlyprintk **功能。 – sawdust

+0

@sawdust,它們使用* initramfs *(注意上面的'cpio -o -H newc')。 – 0andriy

回答

0

我終於找到了解決方案,沒有給它足夠的內存,所以它失敗了。 我最後用

-m大小跑了= 512

它運行良好

相關問題