启动Linux kernel的其中一种方式是initramfs + kernel。其中iniramfs可使用busybox进行制作。本例子将在ubuntu 16.04 64bit中使用busybox v1.22.1制作iniramfs。
## 下载busybox
[busybox]: https://busybox.net/
## configure, compile
1. 配置
```shell
$ make menuconfig
```
> 若执行`make menuconfig`遇到错误,考虑安装libcurses5-dev
Busybox Settings -> Build Options -> Build Busybox as a static binary (no shared libs)
Busybox Settings -> Build Options -> Cross Compiler Prefix # arm-linux-gnueabi-
2. 编译
```shell
$ make -j5 ARCH=arm install
```
留意到回显
> You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
编译结果存储在_install/中。
```shell
# in _install/bin
$ chmod +s busybox
# in _install
$ find . | cpio -o --format=newc > ../rootfs.img
$ cd ..
$ gzip -c rootfs.img > rootfs.img.gz
```
至此,`rootfs.img.gz`为iniramfs。
## 使用
若之前已有编译完成的linux kernel(zImage),则可以通过类似以下的方式使用
```shell
$ ./qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh console=ttyAMA0" -nographic
```
目前的状况是会停留在ramfs文件系统中,观察到的警告为"/bin/sh: can't access tty; job control turned off"。
## refenrece
[busybox for arm on qemu]: https://balau82.wordpress.com/2010/03/27/busybox-for-arm-on-qemu/
## 下载busybox
[busybox]: https://busybox.net/
## configure, compile
1. 配置
```shell
$ make menuconfig
```
> 若执行`make menuconfig`遇到错误,考虑安装libcurses5-dev
Busybox Settings -> Build Options -> Build Busybox as a static binary (no shared libs)
Busybox Settings -> Build Options -> Cross Compiler Prefix # arm-linux-gnueabi-
2. 编译
```shell
$ make -j5 ARCH=arm install
```
留意到回显
> You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
编译结果存储在_install/中。
```shell
# in _install/bin
$ chmod +s busybox
# in _install
$ find . | cpio -o --format=newc > ../rootfs.img
$ cd ..
$ gzip -c rootfs.img > rootfs.img.gz
```
至此,`rootfs.img.gz`为iniramfs。
## 使用
若之前已有编译完成的linux kernel(zImage),则可以通过类似以下的方式使用
```shell
$ ./qemu-system-arm -M versatilepb -m 128M -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh console=ttyAMA0" -nographic
```
目前的状况是会停留在ramfs文件系统中,观察到的警告为"/bin/sh: can't access tty; job control turned off"。
## refenrece
[busybox for arm on qemu]: https://balau82.wordpress.com/2010/03/27/busybox-for-arm-on-qemu/