rootfs
busybox
ARM
QEMU
linux
Author: WhoAmI
Date: 20220727
E-mail: kccddb@gmail.com
Copyright: CC BY-NC-SA
使用 Sourcery G++ Lite 2011.03-42 編譯 Linux Kernel for QEMU ARM Version
Remark. ttyAMA0
使用 Busybox 1.22.0:
laikc@laikc-virtual-machine:~/arm$ tar xjfv busybox-1.22.0.tar.bz2
警告: 注意還有一些 沒有 mount…/proc /sys 還有 /dev 沒作
確認 PATH /opt/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin
確認 prefix arm-none-linux-gnueabi-
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ echo $PATH
/opt/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin:/home/laikc/CodeSourcery/Sourcery_G++_Lite/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ ls -al /opt/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin
total 21824
drwxr-xr-x 3 root root 4096 6月 7 16:24 .
drwxr-xr-x 12 root root 4096 6月 7 16:24 ..
-rwxr-xr-x 1 root root 730764 11月 25 2013 arm-none-linux-gnueabi-addr2line
-rwxr-xr-x 2 root root 757424 11月 25 2013 arm-none-linux-gnueabi-ar
-rwxr-xr-x 2 root root 1249264 11月 25 2013 arm-none-linux-gnueabi-as
-rwxr-xr-x 2 root root 686384 11月 25 2013 arm-none-linux-gnueabi-c++
-rwxr-xr-x 1 root root 728524 11月 25 2013 arm-none-linux-gnueabi-cfilt
-rwxr-xr-x 1 root root 686128 11月 25 2013 arm-none-linux-gnueabi-cpp
-rwxr-xr-x 1 root root 183996 11月 25 2013 arm-none-linux-gnueabi-cs
-rwxr-xr-x 1 root root 2186684 11月 25 2013 arm-none-linux-gnueabi-cs-daemon
-rwxr-xr-x 1 root root 24692 11月 25 2013 arm-none-linux-gnueabi-elfedit
-rwxr-xr-x 2 root root 686384 11月 25 2013 arm-none-linux-gnueabi-g
-rwxr-xr-x 2 root root 683952 11月 25 2013 arm-none-linux-gnueabi-gcc
-rwxr-xr-x 2 root root 683952 11月 25 2013 arm-none-linux-gnueabi-gcc-4.8.1
-rwxr-xr-x 1 root root 23608 11月 25 2013 arm-none-linux-gnueabi-gcc-ar
-rwxr-xr-x 1 root root 23544 11月 25 2013 arm-none-linux-gnueabi-gcc-nm
-rwxr-xr-x 1 root root 23544 11月 25 2013 arm-none-linux-gnueabi-gcc-ranlib
-rwxr-xr-x 1 root root 306856 11月 25 2013 arm-none-linux-gnueabi-gcov
-rwxr-xr-x 1 root root 4361156 11月 25 2013 arm-none-linux-gnueabi-gdb
-rwxr-xr-x 1 root root 796972 11月 25 2013 arm-none-linux-gnueabi-gprof
-rwxr-xr-x 2 root root 1193232 11月 25 2013 arm-none-linux-gnueabi-ld
-rwxr-xr-x 2 root root 740876 11月 25 2013 arm-none-linux-gnueabi-nm
-rwxr-xr-x 2 root root 904588 11月 25 2013 arm-none-linux-gnueabi-objcopy
-rwxr-xr-x 2 root root 1102188 11月 25 2013 arm-none-linux-gnueabi-objdump
-rwxr-xr-x 2 root root 757424 11月 25 2013 arm-none-linux-gnueabi-ranlib
-rwxr-xr-x 1 root root 412800 11月 25 2013 arm-none-linux-gnueabi-readelf
-rwxr-xr-x 1 root root 731372 11月 25 2013 arm-none-linux-gnueabi-size
-rwxr-xr-x 1 root root 730700 11月 25 2013 arm-none-linux-gnueabi-strings
-rwxr-xr-x 2 root root 904588 11月 25 2013 arm-none-linux-gnueabi-strip
drwxr-xr-x 2 root root 4096 6月 7 16:24 cache
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$
先用 ARM default
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
再來 config, 沒有 ncurse 請參考 kernel 編譯 (注意 是 32bits 或 64bits)
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
需要 init (如果您需要, 我用 /bin/sh 代替, 現沒用到)
BusyBox 1.22.0 Configuration
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Init Utilities qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Arrow keys navigate the menu. selects submenus –->. Highlighted letters are x
x hotkeys. Pressing includes, excludes, modularizes features. Press x
x to exit, for Help, </> for Search. Legend: [] built-in [ ] excluded x
x module < > module capable x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x [] bootchartd x x
x x [] Compatible, bloated header x x
x x [] Support bootchartd.conf x x
x x [] poweroff, halt, and reboot x x
x x [] init x x
x x [] Support reading an inittab file x x
x x [ ] Support killing processes that have been removed from inittab x x
x x [] Run commands with leading dash with controlling tty x x
x x [] Enable init to write to syslog x x
x x [] Be extra quiet on boot x x
x x [] Support dumping core for child processes (debugging only) x x
x x [] Support running init from within an initrd (not initramfs) x x
x x (linux) Initial terminal type x x
x x [*] mesg x x
x mqqqqqqqv(+)qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
進入 Build Options –->
BusyBox 1.22.0 Configuration
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Busybox Settings qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Arrow keys navigate the menu. selects submenus –->. Highlighted letters are x
x hotkeys. Pressing includes, excludes, modularizes features. Press x
x to exit, for Help, </> for Search. Legend: [*] built-in [ ] excluded x
x module < > module capable x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x General Configuration –-> x x
x x Build Options –-> x x
x x Debugging Options –-> x x
x x Installation Options ("make install" behavior) –-> x x
x x Busybox Library Tuning –-> x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
改成 static binary (no shared libs) , 否則需要準備 libxxx.so 等, 懶人法
try ldd
BusyBox 1.22.0 Configuration
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq Build Options qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Arrow keys navigate the menu. selects submenus –->. Highlighted letters are x
x hotkeys. Pressing includes, excludes, modularizes features. Press x
x to exit, for Help, </> for Search. Legend: [] built-in [ ] excluded x
x module < > module capable x
x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
x x [] Build BusyBox as a static binary (no shared libs) x x
x x [ ] Force NOMMU build x x
x x [*] Build with Large File Support (for accessing files > 2 GB) x x
x x () Cross Compiler prefix x x
x x () Path to sysroot x x
x x () Additional CFLAGS x x
x x () Additional LDFLAGS x x
x x () Additional LDLIBS x x
x x x x
x x x x
x x x x
x x x x
x x x x
x x x x
x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
/*
上面 Build BusyBox as a static binary (no shared libs) 使用懶人法,
但也可用shared libs, 您必需 於 rootfs 中產生
/lib
此路徑, 並且將 arm tools chain 裏的 libc.so copy 至 /lib (不是您 VM 裡的 /lib !!!)*
*/
Q:
dynamic link 與 static link 有何差別?
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ cd _install/
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$
看看 busybox header
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ arm-none-linux-gnueabi-objdump -x bin/busybox**
bin/busybox: file format elf32-littlearm
bin/busybox
architecture: armv5te, flags 0x00000102:
EXEC_P, D_PAGED
start address 0x0000c450
Program Header:
0x70000001 off 0x001e3d94 vaddr 0x001ebd94 paddr 0x001ebd94 align 22
filesz 0x00002d40 memsz 0x00002d40 flags r–
LOAD off 0x00000000 vaddr 0x00008000 paddr 0x00008000 align 215
filesz 0x001e6ad8 memsz 0x001e6ad8 flags r-x
LOAD off 0x001e7000 vaddr 0x001f7000 paddr 0x001f7000 align 215
filesz 0x000011b0 memsz 0x00005574 flags rw-
NOTE off 0x000000f4 vaddr 0x000080f4 paddr 0x000080f4 align 22
filesz 0x00000020 memsz 0x00000020 flags r–
TLS off 0x001e7000 vaddr 0x001f7000 paddr 0x001f7000 align 22
filesz 0x00000018 memsz 0x0000004c flags r–
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 24
filesz 0x00000000 memsz 0x00000000 flags rw-
private flags = 5000202: [Version5 EABI] [soft-float ABI] [has entry point]
Sections:
Idx Name Size VMA LMA File off Algn
0 .note.ABI-tag 00000020 000080f4 000080f4 000000f4 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .init 0000000c 00008114 00008114 00000114 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .text 00188930 00008120 00008120 00000120 24
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 __libc_freeres_fn 00000e7c 00190a50 00190a50 00188a50 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 __libc_thread_freeres_fn 000001cc 001918cc 001918cc 001898cc 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
5 .fini 00000008 00191a98 00191a98 00189a98 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
6 .rodata 0005974d 00191aa0 00191aa0 00189aa0 23
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 __libc_subfreeres 0000005c 001eb1f0 001eb1f0 001e31f0 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 __libc_atexit 00000004 001eb24c 001eb24c 001e324c 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 __libc_thread_subfreeres 0000000c 001eb250 001eb250 001e3250 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .ARM.extab 00000b38 001eb25c 001eb25c 001e325c 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
11 .ARM.exidx 00002d40 001ebd94 001ebd94 001e3d94 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
12 .eh_frame 00000004 001eead4 001eead4 001e6ad4 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
13 .tdata 00000018 001f7000 001f7000 001e7000 22
CONTENTS, ALLOC, LOAD, DATA, THREAD_LOCAL
14 .tbss 00000034 001f7018 001f7018 001e7018 22
ALLOC, THREAD_LOCAL
15 .init_array 00000004 001f7018 001f7018 001e7018 22
CONTENTS, ALLOC, LOAD, DATA
16 .fini_array 00000008 001f701c 001f701c 001e701c 22
CONTENTS, ALLOC, LOAD, DATA
17 .jcr 00000004 001f7024 001f7024 001e7024 22
CONTENTS, ALLOC, LOAD, DATA
18 .data.rel.ro 00000070 001f7028 001f7028 001e7028 22
CONTENTS, ALLOC, LOAD, DATA
19 .got 0000007c 001f7098 001f7098 001e7098 22
CONTENTS, ALLOC, LOAD, DATA
20 .data 00001098 001f7118 001f7118 001e7118 23
CONTENTS, ALLOC, LOAD, DATA
21 .bss 00004384 001f81b0 001f81b0 001e81b0 23
ALLOC
22 __libc_freeres_ptrs 00000040 001fc534 001fc534 001e81b0 22
ALLOC
23 .ARM.attributes 0000002b 00000000 00000000 001e81b0 20
CONTENTS, READONLY
SYMBOL TABLE:
no symbols
是正確armv5te因此可進行 產生 image
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ find . | cpio -o –format=newc >../rootfs.img
4007 blocks
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ cd ..
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$
產生 gz image
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ gzip -c rootfs.img > rootfs.img.gz
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ ls
applets Config.in include Makefile.custom rootfs.img.gz
applets_sh configs init Makefile.flags runit
arch console-tools _install Makefile.help scripts
archival coreutils INSTALL miscutils selinux
AUTHORS debianutils libbb modutils shell
busybox docs libpwdgrp networking sysklogd
busybox.links e2fsprogs LICENSE printutils testsuite
busybox_unstripped editors loginutils procps TODO
busybox_unstripped.map examples mailutils README TODO_unicode
busybox_unstripped.out findutils Makefile rootfs.img util-linux
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$
我們使用 /bin/sh 代替 init … 誰說不可以呢?
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ cd ..
laikc@laikc-virtual-machine:~/arm$ /usr/local/bin/qemu-system-arm -machine versatileab -kernel /home/laikc/arm/linux-2.6.33/arch/arm/boot/zImage -nographic -initrd /home/laikc/arm/busybox-1.22.0/rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh console=ttyAMA0"
audio: Could not init `oss' audio driver
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.33 (laikc@laikc-virtual-machine) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-42) ) #1 Sat Jun 7 14:19:01 CST 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile AB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/ram rdinit=/bin/sh console=ttyAMA0
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 125680KB available (2572K code, 219K data, 100K init, 0K highmem)
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is enabled.
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80x30
Calibrating delay loop… 496.43 BogoMIPS (lpj=2482176)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
bio: create slab at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs…
Freeing initrd memory: 1084K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright © 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD © 2007 Red Hat, Inc.
msgmni has been set to 247
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x60
brd: module loaded
armflash.0: Found 1 x32 devices at 0x0 in 32-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
RedBoot partition parsing not available
afs partition parsing not available
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at c88be000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: not present
Freeing init memory: 100K
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
/bin/sh: can't access tty; job control turned off
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
/ # ls
bin dev linuxrc root sbin usr
/ #
完工, 謝謝~~~~沒用 init 與 tty密碼等
Ref. https://lxr.linux.no/linux+v2.6.33/init/main.c
Freeing init memory: 100K
是 803 free_initmem(); 的結果
/ # ps
PID USER TIME COMMAND
ps: can't open '/proc': No such file or directory
解決ProcFs問題:
/ # mkdir /proc
/ # mount -t proc none /proc
/ # ps
PID USER TIME COMMAND
1 0 0:03 /bin/sh
2 0 0:00 [kthreadd]
3 0 0:00 [ksoftirqd/0]
4 0 0:00 [watchdog/0]
5 0 0:00 [events/0]
6 0 0:00 [khelper]
9 0 0:00 [async/mgr]
91 0 0:00 [sync_supers]
93 0 0:00 [bdi-default]
95 0 0:00 [kblockd/0]
99 0 0:00 [kseriod]
101 0 0:00 [kmmcd]
118 0 0:00 [rpciod/0]
127 0 0:00 [khungtaskd]
128 0 0:00 [kswapd0]
129 0 0:00 [aio/0]
130 0 0:00 [nfsiod]
273 0 0:00 [mtdblockd]
287 0 0:00 [kpsmoused]
309 0 0:00 ps
/ #
/ # ls /dev
console
/ #
哇 …好多沒有喔, 只好 DIY
/ # mkdir /sys
/ # mount -t sysfs none /sys
/ # mdev -s**
現在 出來了!!!
/ # ls /dev
console ram13 tty28 tty59
cpu_dma_latency ram14 tty29 tty6
fb0 ram15 tty3 tty60
full ram2 tty30 tty61
input ram3 tty31 tty62
kmem ram4 tty32 tty63
kmsg ram5 tty33 tty7
mem ram6 tty34 tty8
network_latency ram7 tty35 tty9
network_throughput ram8 tty36 ttyAMA0
null ram9 tty37 ttyAMA1
psaux random tty38 ttyAMA2
ptmx tty tty39 ttyp0
ptyp0 tty0 tty4 ttyp1
ptyp1 tty1 tty40 ttyp2
ptyp2 tty10 tty41 ttyp3
ptyp3 tty11 tty42 ttyp4
ptyp4 tty12 tty43 ttyp5
ptyp5 tty13 tty44 ttyp6
ptyp6 tty14 tty45 ttyp7
ptyp7 tty15 tty46 ttyp8
ptyp8 tty16 tty47 ttyp9
ptyp9 tty17 tty48 ttypa
ptypa tty18 tty49 ttypb
ptypb tty19 tty5 ttypc
ptypc tty2 tty50 ttypd
ptypd tty20 tty51 ttype
ptype tty21 tty52 ttypf
ptypf tty22 tty53 urandom
ram0 tty23 tty54 vcs
ram1 tty24 tty55 vcs1
ram10 tty25 tty56 vcsa
ram11 tty26 tty57 vcsa1
ram12 tty27 tty58 zero
以下使用 /sbin/init 當 init
––––––––––––––––––––––––––––––––––
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ pwd
/home/laikc/arm/busybox-1.22.0/_install
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$
製造路徑
mkdir proc sys etc etc/init.d dev
記得一定存 unix 格式, 不知就用 vi 寫吧
把 rcS 寫好並且 chmod 改權限
放到 etc/init.d
**laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install/etc/init.d$ cat rcS
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install/etc/init.d$
準備 inittab
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install/etc$ ls
init.d inittab
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install/etc$
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install/etc$ cat inittab
放到 etc 底下
重新 製作 rootfs.img.gz
若是出現 & gt ; 那個是 IO 轉向的 '大於' > 的數學符號,
開始 產生 rootfs
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ find . | cpio -o –format=newc > ../rootfs.img
4015 blocks
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0/_install$ cd ..
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ gzip -c rootfs.img > rootfs.img.gz
laikc@laikc-virtual-machine:~/arm/busybox-1.22.0$ /usr/local/bin/qemu-system-arm -machine versatileab -kernel /home/laikc/arm/linux-2.6.33/arch/arm/boot/zImage -nographic -initrd /home/laikc/arm/busybox-1.22.0/rootfs.img.gz -append "root=/dev/ram rdinit=/sbin/init console=ttyAMA0"
audio: Could not init `oss' audio driver
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.33 (laikc@laikc-virtual-machine) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-42) ) #1 Sat Jun 7 14:19:01 CST 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile AB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/ram rdinit=/sbin/init console=ttyAMA0
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 125680KB available (2572K code, 219K data, 100K init, 0K highmem)
Hierarchical RCU implementation.
RCU-based detection of stalled CPUs is enabled.
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80x30
Calibrating delay loop… 522.64 BogoMIPS (lpj=2613248)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
bio: create slab at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs…
Freeing initrd memory: 1084K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright © 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD © 2007 Red Hat, Inc.
msgmni has been set to 247
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x60
brd: module loaded
armflash.0: Found 1 x32 devices at 0x0 in 32-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
RedBoot partition parsing not available
afs partition parsing not available
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at c88be000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: not present
Freeing init memory: 100K
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
Please press Enter to activate this console.
/ #
可以 reboot 了
/ # reboot
/ # swapoff: /etc/fstab: No such file or directory
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system reboot
Restarting system.
Uncompressing Linux… done, booting the kernel.
Linux version 2.6.33 (laikc@laikc-virtual-machine) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-42) ) #1 Sat Jun 7 14:19:01 CST 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile AB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/ram rdinit=/sbin/init console=ttyAMA0
…
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
bio: create slab at 0
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs…
Freeing initrd memory: 1084K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright © 1996 okir@monad.swb.de).
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD © 2007 Red Hat, Inc.
msgmni has been set to 247
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x60
brd: module loaded
armflash.0: Found 1 x32 devices at 0x0 in 32-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
RedBoot partition parsing not available
afs partition parsing not available
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
eth0: SMC91C11xFD (rev 1) at c88be000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: not present
Freeing init memory: 100K
input: AT Raw Set 2 keyboard as /devices/fpga:06/serio0/input/input0
input: ImExPS/2 Generic Explorer Mouse as /devices/fpga:07/serio1/input/input1
Please press Enter to activate this console.
/ #
恭喜恭喜
Futher Reading:
Linux initial RAM disk (initrd) overview
10+ losetup command examples in Linux [Cheat Sheet]