Monday, April 16, 2007

Booting ubuntutrinux (or other initrafms fare) within Qemu

Getting re-acquainted with embedded linux (and building ramdisk distros) over the past week or so has been sort of painful (I'm still struggling with the transition from initrd to initramfs) but over the weekend I manged to "release" a kernel and filesystem built on busybox 1.4.2 and Linux 2.6.20 as well some scripts (stripped down versions of the mkinitrd stuff in ubuntu) I used to create them.

But I'm still not happpy. Rob Landley's site and various documentation he has written has proved to be quite useful but still haven't solved the main problem of getting a initramfs to behave like the initrd+linuxrc's did with Trinux but I have ditched VMWare for QEMU. I do builds on my Dell Optiplex Pentium D then copy them over to my PowerBook where they run (even on a PPC!)


franz-g4:~/ubuntutrinux-test-0 mdfranz$ qemu -nographic -kernel bzImage -initrd initramfs -append "console=ttyS0" /dev/zero


And then you get within a Terminal...

starting qemu...
(qemu) [ 0.000000] Linux version 2.6.20.2 (root@gx620) (gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)) #1 SMP PREEMPT Sat Apr 7 07:56:09 CDT 2007
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] sanitize start
[ 0.000000] sanitize end
[ 0.000000] copy_e820_map() start: 0000000000000000 size: 000000000009fc00 end: 000000000009fc00 type: 1
[ 0.000000] copy_e820_map() type is E820_RAM
[ 0.000000] copy_e820_map() start: 000000000009fc00 size: 0000000000000400 end: 00000000000a0000 type: 2
[ 0.000000] copy_e820_map() start: 00000000000e8000 size: 0000000000018000 end: 0000000000100000 type: 2
[ 0.000000] copy_e820_map() start: 0000000000100000 size: 0000000007f00000 end: 0000000008000000 type: 1
[ 0.000000] copy_e820_map() type is E820_RAM
[ 0.000000] copy_e820_map() start: 00000000fffc0000 size: 0000000000040000 end: 0000000100000000 type: 2
[ 0.000000] BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
[ 0.000000] BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
[ 0.000000] BIOS-e820: 00000000000e8000 - 0000000000100000 (reserved)
[ 0.000000] BIOS-e820: 0000000000100000 - 0000000008000000 (usable)
[ 0.000000] BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[ 0.000000] 0MB HIGHMEM available.
[ 0.000000] 128MB LOWMEM available.
[ 0.000000] Zone PFN ranges:
[ 0.000000] DMA 0 -> 4096
[ 0.000000] Normal 4096 -> 32768
[ 0.000000] HighMem 32768 -> 32768
[ 0.000000] early_node_map[1] active PFN ranges
[ 0.000000] 0: 0 -> 32768
[ 0.000000] DMI not present or invalid.
[ 0.000000] ACPI: Disabling ACPI support
[ 0.000000] Allocating PCI resources starting at 10000000 (gap: 08000000:f7fc0000)
[ 0.000000] Detected 18.432 MHz processor.
[ 2.901454] Built 1 zonelists. Total pages: 32512
[ 2.901788] Kernel command line: console=ttyS0
[ 2.911864] Found and enabled local APIC!
[ 2.912649] Enabling fast FPU save and restore... done.
[ 2.913650] Enabling unmasked SIMD FPU exception support... done.
[ 2.916144] Initializing CPU#0
[ 2.919308] PID hash table entries: 512 (order: 9, 2048 bytes)
[ 2.927577] Console: colour VGA+ 80x25
[ 3.149985] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
[ 3.156115] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[ 3.302374] Memory: 121064k/131072k available (2010k kernel code, 9508k reserved, 653k data, 312k init, 0k highmem)
[ 3.341009] virtual kernel memory layout:
[ 3.341098] fixmap : 0xfff4f000 - 0xfffff000 ( 704 kB)
[ 3.341176] pkmap : 0xff800000 - 0xffc00000 (4096 kB)
[ 3.341253] vmalloc : 0xc8800000 - 0xff7fe000 ( 879 MB)
[ 3.341330] lowmem : 0xc0000000 - 0xc8000000 ( 128 MB)
[ 3.341405] .init : 0xc039f000 - 0xc03ed000 ( 312 kB)
[ 3.341482] .data : 0xc02f69d3 - 0xc0399f70 ( 653 kB)
[ 3.341557] .text : 0xc0100000 - 0xc02f69d3 (2010 kB)
[ 3.431756] Checking if this processor honours the WP bit even in supervisor mode... Ok.
[ 3.659081] Calibrating delay using timer specific routine.. 93.63 BogoMIPS (lpj=187261)
[ 3.691223] Security Framework v1.0.0 initialized
[ 3.716745] SELinux: Disabled at boot.
[ 3.720889] Mount-cache hash table entries: 512
[ 3.756947] CPU: L1 I cache: 8K
[ 3.771871] CPU: L2 cache: 128K
[ 3.784194] Compat vDSO mapped to ffffe000.
[ 3.802657] Checking 'hlt' instruction... OK.
[ 3.920842] SMP alternatives: switching to UP code
[ 3.931291] Freeing SMP alternatives: 10k freed
[ 3.943582] CPU0: Intel Pentium II (Klamath) stepping 03
[ 3.964529] SMP motherboard not detected.
[ 4.230102] Brought up 1 CPUs
[ 4.267331] NET: Registered protocol family 16
[ 4.314839] EISA bus registered
[ 4.322200] PCI: PCI BIOS revision 2.10 entry at 0xf9fa0, last bus=0
[ 4.325915] PCI: Using configuration type 1
[ 4.328017] Setting up standard PCI resources
[ 4.427408] ACPI: Interpreter disabled.
[ 4.441367] Linux Plug and Play Support v0.97 (c) Adam Belay
[ 4.483253] pnp: PnP ACPI: disabled
[ 4.498100] PnPBIOS: Scanning system for PnP BIOS support...
[ 4.541351] PnPBIOS: PnP BIOS support was not detected.
[ 4.587718] PCI: Probing PCI hardware
[ 4.609690] * Found PM-Timer Bug on the chipset. Due to workarounds for a bug,
[ 4.610142] * this clock source is slow. Consider trying other clock sources
[ 4.645056] PCI quirk: region b000-b03f claimed by PIIX4 ACPI
[ 4.685876] PCI: Using IRQ router PIIX/ICH [8086/7000] at 0000:00:01.0
[ 4.710713] PCI: BIOS reporting unknown device 01:00
[ 4.733156] PCI: BIOS reporting unknown device 01:00
[ 4.749968] PCI: BIOS reporting unknown device 01:00
[ 4.784264] PCI: BIOS reporting unknown device 01:00
[ 4.795444] PCI: BIOS reporting unknown device 01:00
[ 4.815190] PCI: BIOS reporting unknown device 01:00
[ 4.843408] NET: Registered protocol family 8
[ 4.845769] NET: Registered protocol family 20
[ 4.895700] PCI: Ignore bogus resource 6 [0:0] of 0000:00:02.0
[ 4.918304] NET: Registered protocol family 2
[ 5.044717] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 5.075773] TCP established hash table entries: 4096 (order: 3, 49152 bytes)
[ 5.123529] TCP bind hash table entries: 2048 (order: 2, 24576 bytes)
[ 5.146642] TCP: Hash tables configured (established 4096 bind 2048)
[ 5.180315] TCP reno registered
[ 5.249366] checking if image is initramfs... it is
[ 24.071603] Freeing initrd memory: 4956k freed
[ 24.134872] audit: initializing netlink socket (disabled)
[ 24.160085] audit(1176777411.196:1): initialized
[ 24.215895] VFS: Disk quotas dquot_6.5.1
[ 24.234002] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 24.280635] io scheduler noop registered
[ 24.295858] io scheduler anticipatory registered (default)
[ 24.299539] io scheduler deadline registered
[ 24.302895] io scheduler cfq registered
[ 24.306052] Limiting direct PCI/PCI transfers.
[ 24.308877] PCI: PIIX3: Enabling Passive Release on 0000:00:01.0
[ 24.312882] Activating ISA DMA hang workarounds.
[ 24.347502] isapnp: Scanning for PnP cards...
[ 25.303982] isapnp: No Plug & Play device found
[ 27.407116] Real Time Clock Driver v1.12ac
[ 27.430981] Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
[ 27.472354] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450
[ 27.575725] RAMDISK driver initialized: 16 RAM disks of 65536K size 1024 blocksize
[ 27.634910] Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
[ 27.668313] ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
[ 27.694047] PNP: No PS/2 controller found. Probing ports directly.
[ 27.715008] serio: i8042 KBD port at 0x60,0x64 irq 1
[ 27.741112] serio: i8042 AUX port at 0x60,0x64 irq 12
[ 27.769258] mice: PS/2 mouse device common for all mice
[ 27.802423] input: AT Translated Set 2 keyboard as /class/input/input0
[ 27.865277] EISA: Probing bus 0 at eisa.0
[ 27.902510] EISA: Detected 0 cards.
[ 27.922112] TCP cubic registered
[ 27.954340] NET: Registered protocol family 1
[ 27.979541] Testing NMI watchdog ... CPU#0: NMI appears to be stuck (0->0)!
[ 28.141213] Using IPI No-Shortcut mode
[ 28.188656] Time: tsc clocksource has been installed.
[ 28.275904] Freeing unused kernel memory: 312k freed
Starting init!
mknod: /dev/console: File exists
mknod: /dev/null: File exists
bash: no job control in this shell
bash-3.1#

I just wish there were a way to "stay in" this filesystem (I think it is rootfs) and get job control, run the simple busybox init and spawn shells without mounting another root, but I'm guessing I'll have to create another ramdisk filesystem and switch_root into it.


label default
kernel bzimage
append initrd=initrd.gz root=/dev/ram0 rw


Then linuxrc got executed and then after exiting it, Busybox init kicked in.

No comments: