使用busybox製作iniramfs

來源:互聯網
上載者:User
啟動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/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.