- Docker环境搭建
- QEMU环境搭建
- 交叉编译工具链搭建
- CROSS PATH
- U-boot编译(qemu暂不支持)
- u-boot-2017.03.tar.bz2为例)">下载官网u-boot源码(以u-boot-2017.03.tar.bz2为例)
- 解压u-boot
- 编译u-boot
- Linux kernel编译
- linux-4.9.tar.xz为例)">下载官网linux内核源码(以linux-4.9.tar.xz为例)
- 解压linux kernel
- 编译kernel
- 制作rootf根文件系统
- /etc/profile: system-wide .profile file for the Bourne shells
- /etc/profile: system-wide .profile file for the Bourne shells
- /etc/inittab
- /etc/inittab
- ! /bin/sh
- ! /bin/sh
+-------------+
| | 容器与Boot2dorcker文件共享
| docker容器 +--+ Boot2docker通过VirtualBox与Windows文件共享
+-------------+ | Qemu与Windows通过NFS文件共享
| | | 间接实现容器与Qemu实现文件共享
| Boot2Dokcer | |
+-------------+ | +----------+
| | | | |
| Virtual Box | +--> | Qemu |
+-------------+ +----------+
| | | |
| Windows | | Windows |
+-------------+ +----------+
Docker环境搭建
Docker概念
镜像(images) 镜像就是环境包 容器(Container) 容器就是镜像的实例, 一个镜像可以启动多个容器
Windows docker环境搭建:
- VirtualBox官网:
- 下载boot2docker.iso
https://github.com/boot2docker/boot2docker/releases
- 虚拟机搭建
打开VirtualBox,新建虚拟机
网络和共享文件夹配置
Ctrl+S进入设置
配置docker环境
启动boot2docker虚拟机
$ ifconfig 找到网卡2(eth1)ip地址为192.168.56.101
使用ssh工具连接到docker(这里演示MobaXterm_Personal) ip:192.168.56.101 user:docker password:tcuser
配置docker镜像加速
docker@boot2docker:~$ sudo su
root@boot2docker:/home/docker# cd /etc/docker
root@boot2docker:/etc/docker# vi dameon.json
root@boot2docker:/etc/docker# touch dameon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
root@boot2docker:/etc/docker# /etc/init.d/docker restart
root@boot2docker:/etc/docker# exit
docker@boot2docker:~$
dameon.json:
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
Ubuntu docker环境搭建(Ubuntu版本建议大于16.04):
国内 daocloud 一键安装命令:
$ curl -sSL https://get.daocloud.io/docker | sh
更新最新软件包:
$ sudo apt-get update
安装 apt 依赖包,用于通过HTTPS来获取仓库:
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
添加 Docker 的官方 GPG 密钥:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥。
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) docker@docker.com sub rsa4096 2017-02-22 [S]
使用以下指令设置稳定版仓库
$ sudo add-apt-repository \ “deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable”
安装最新版本的 Docker Engine-Community 和 containerd ,或者转到下一步安装特定版本:
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io
要安装特定版本的 Docker Engine-Community,请在仓库中列出可用版本,然后选择一种安装。列出您的仓库中可用的版本:
$ apt-cache madison docker-ce docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages …
使用第二列中的版本字符串安装特定版本,例如 5:18.09.1~3-0~ubuntu-xenial
$ sudo apt-get install docker-ce=
docker-ce-cli= containerd.io 测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:
sudo docker info
如果要使用 Docker 作为非 root 用户,则应考虑使用类似以下方式将用户添加到 docker 组:
$ sudo usermod -aG docker your-user
Docker常用命令
下载镜像
docker pull xxxxOS
上传镜像
docker push xxxxOS:v1
删除容器
docker rm -f centos7
创建容器
docker run —privileged —name centos7 -v /mnt/sda1:/work -p 24:22 -itd centos7 :v1 /usr/sbin/init
运行容器
docker start centos7
停止容器
docker stop centos7
在终端以交互模式进入容器
docker exec -it centos7 /bin/bash
QEMU环境搭建
软件环境准备
- windows qemu环境下载:
https://gitee.com/DAI_David/qemu_imx6ull_windows/repository/archive/master.zip
- ComEmu终端官网:
- SSH工具下载:
根据个人爱好下载自己ssh工具,本文演示的是MobaXterm_Personal
环境部署
- 使用ComEmu运行qemu
解压DAI_David-qemu_imx6ull_windows-master.zip到本地电脑
打开ComEmu:
$ cd d:\Download\DAI_David-qemu_imx6ull_windows-master\qemu_imx6ull_windows
$ QEMU_WIN.bat nogui
显示qemu_imx6ul login:,输入用户名:root 密码:123456
[root@qemu_imx6ul:~]#
ssh工具远程连接Qemu
配置ssh: ip:127.0.0.1 user:root password:123456
交叉编译工具链搭建
相关工具下载
下载地址:链接: https://pan.baidu.com/s/1Mz70aBMGrrAgSDY6FIKQEw 提取码: x2ga 并解压到共享目录中为后续做准备
SSH连接boot2docker
SSH连接boot2docker
容器环境搭建
Ubuntu docker镜像
方法一:通过网络下载Ubuntu docker镜像 docker@boot2docker:~$ docker pull silencedai/ubuntu16.04:cross_v1.0 docker@boot2docker:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE silencedai/ubuntu16.04 cross_v1.0 477e1767707c 1 minutes ago 351MB docker@boot2docker:~$ docker tag silencedai/ubuntu16.04:cross_v1.0 ubuntu16.04:cross_v1.0 #修改镜像名称为ubuntu16.04:cross_v1.0 docker@boot2docker:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu16.04 cross_v1.0 477e1767707c 1 minutes ago 351MB silencedai/ubuntu16.04 cross_v1.0 477e1767707c 1 minutes ago 351MB docker@boot2docker:~$ cd /share/ docker@boot2docker:/share$ docker save -o ubuntu16.04_cross.tar ubuntu16.04:cross_v1.0 #保存镜像为tar包 方法二:下载镜像压缩包导入 docker@boot2docker:~$ cd /share docker@boot2docker:/share$ docker load < ubuntu16.04_cross.tar.bz2 Loaded image: ubuntu16.04:cross_v1.0 docker@boot2docker:/share$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu16.04 cross_v1.0 477e1767707c 1 minutes ago 351MB
启动Ubuntu docker镜像
docker@boot2docker:~$ ubuntu.sh run ubuntu16.04:cross_v1.0 PS:如果提示:”docker: Error response from daemon: cgroups: cannot find cgroup mount destination: unknown.” 解决办法: docker@boot2docker:~$ sudo cgroup.sh docker@boot2docker:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2110559d37fb ubuntu16.04:cross_v1.0 “systemd” 5 minutes ago Created 0.0.0.0:24->22/tcp ubuntu16.04 docker@boot2docker:~$ docker rm -f ubuntu16.04 docker@boot2docker:~$ ubuntu.sh run ubuntu16.04:cross_v1.0 docker@boot2docker:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 07b86898f1f3 ubuntu16.04:cross_v1.0 “systemd” 10 seconds ago Up 9 seconds 0.0.0.0:24->22/tcp ubuntu16.04
进入ubuntu16.04容器
方法一:使用exec进入容器 docker@boot2docker:~$ docker exec -it ubuntu16.04 bash root@07b86898f1f3:/# 方法二:使用SSH连接容器 配置ssh: ip:192.168.56.101
port:24
user:work password:123456 work@07b86898f1f3:~$
虚拟机重启后,使用docker start启动容器
此时容器属于Exited状态 docker@boot2docker:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 07b86898f1f3 ubuntu16.04:cross_v1.0 “systemd” 7 minutes ago Exited (137) 2 seconds ago ubuntu16.04 docker@boot2docker:~$ docker start ubuntu16.04 #启动容器 docker@boot2docker:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 07b86898f1f3 ubuntu16.04:cross_v1.0 “systemd” 9 minutes ago Up 5 seconds 0.0.0.0:24->22/tcp ubuntu16.04
交叉编译工具搭建
进入容器
ssh连接容器 work@07b86898f1f3:~$ work@07b86898f1f3:~$ cd /work/ work@07b86898f1f3:~$ mkdir imx work@07b86898f1f3:~$ sudo chmod 777 imx work@07b86898f1f3:~$ cd imx work@07b86898f1f3:/work/imx$
解压交叉编译工具链
ssh连接docker虚拟机 docker@boot2docker:~$ docker@boot2docker:~$ cd /mnt/sda1/imx/ docker@boot2docker:/mnt/sda1/imx$ unzip /share/weidongshan-ToolChain-6.2.1-master.zip docker@boot2docker:/mnt/sda1/imx$ ls ToolChain-6.2.1-master
设置环境变量
切换到容器 work@07b86898f1f3:/work/imx$ ls ToolChain-6.2.1-master work@07b86898f1f3:/work/imx$ cat >> env_cross << EOF
CROSS PATH
export CROSS_PATH=/work/imx/ToolChain-6.2.1-master/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin export PATH=\$CROSS_PATH:\$PATH
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- EOF work@07b86898f1f3:/work/imx$ source env_cross work@07b86898f1f3:/work/imx$ arm-linux-gnueabihf-gcc -v Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc COLLECT_LTO_WRAPPER=/work/imx/ToolChain-6.2.1-master/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/6.2.1/lto-wrapper Target: arm-linux-gnueabihf Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-6.2-2016.11/configure SHELL=/bin/bash —with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu —with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu —with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu —with-gnu-as —with-gnu-ld —disable-libstdcxx-pch —disable-libmudflap —with-cloog=no —with-ppl=no —with-isl=no —disable-nls —enable-c99 —enable-gnu-indirect-function —disable-multilib —with-tune=cortex-a9 —with-arch=armv7-a —with-fpu=vfpv3-d16 —with-float=hard —with-mode=thumb —enable-multiarch —with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf —enable-lto —enable-linker-build-id —enable-long-long —enable-shared —with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc —enable-languages=c,c++,fortran,lto —enable-checking=release —disable-bootstrap —build=x86_64-unknown-linux-gnu —host=x86_64-unknown-linux-gnu —target=arm-linux-gnueabihf —prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11)
U-boot编译(qemu暂不支持)
下载官网u-boot源码(以u-boot-2017.03.tar.bz2为例)
u-boot官网源码地址:https://ftp.denx.de/pub/u-boot/ 放在虚拟共享目录中
解压u-boot
ssh连接docker虚拟机 docker@boot2docker:~$ docker@boot2docker:~$ cd /mnt/sda1/imx/ docker@boot2docker:/mnt/sda1/imx$ tar xvf /share/u-boot-2017.03.tar.bz2 -C ./
编译u-boot
ssh连接容器 work@07b86898f1f3:~$ work@07b86898f1f3:~$ cd /work/imx/ work@07b86898f1f3:/work/imx$ ls ToolChain-6.2.1-master env_cross u-boot-2017.03 work@07b86898f1f3:/work/imx$ sudo chown work:work u-boot-2017.03/ -R [sudo] password for work:123456 work@07b86898f1f3:/work/imx$ source env_cross work@07b86898f1f3:/work/imx$ cd u-boot-2017.03/ work@07b86898f1f3:/work/imx/u-boot-2017.03$ make distclean work@07b86898f1f3:/work/imx/u-boot-2017.03$ make imx6ul_geam_mmc_defconfig work@07b86898f1f3:/work/imx/u-boot-2017.03$ make menuconfig #配置u-boot work@07b86898f1f3:/work/imx/u-boot-2017.03$ make -jN #N为cpu核心数,例如make -j4
Linux kernel编译
下载官网linux内核源码(以linux-4.9.tar.xz为例)
linux内核官方下载地址:https://www.kernel.org 放在虚拟共享目录中
解压linux kernel
ssh连接docker虚拟机 docker@boot2docker:~$ docker@boot2docker:~$ cd /mnt/sda1/imx/ docker@boot2docker:/mnt/sda1/imx$ tar xvf /share/linux-4.9.tar.xz -C ./
编译kernel
ssh连接容器 work@07b86898f1f3:~$ work@07b86898f1f3:~$ cd /work/imx/ work@07b86898f1f3:/work/imx$ ls ToolChain-6.2.1-master env_cross linux-4.9 u-boot-2017.03 work@07b86898f1f3:/work/imx$ sudo chown work:work linux-4.9/ -R [sudo] password for work:123456 work@07b86898f1f3:/work/imx$ source env_cross work@07b86898f1f3:/work/imx$ cd linux-4.9/ work@07b86898f1f3:/work/imx/linux-4.9$ make distclean work@07b86898f1f3:/work/imx/linux-4.9$ make imx_v6_v7_defconfig work@07b86898f1f3:/work/imx/linux-4.9$ make menuconfig #配置linux kernel work@07b86898f1f3:/work/imx/linux-4.9$ make -jN zImage #N为cpu核心数,例如make -jN zImage work@07b86898f1f3:/work/imx/linux-4.9$ make dtbs
制作rootf根文件系统
制作rootfs.img
打开ComEmu进入共享目录 $ cd d:\VM\share $ qemu-img create rootfs.img 300M
下载官网busybox源码(以busybox-1.31.1.tar.bz2为例)
busybox源码下载地址:https://busybox.net/downloads/ 放在虚拟共享目录中
解压busybox
ssh连接docker虚拟机 docker@boot2docker:~$ docker@boot2docker:~$ cd /mnt/sda1/imx/ docker@boot2docker:/mnt/sda1/imx$ tar xvf /share/busybox-1.31.1.tar.bz2 -C ./
使用busybox制作根文件系统
格式化rootfs.img为ext4文件格式
ssh连接容器 work@07b86898f1f3:~$ work@07b86898f1f3:~$ cd /work/imx/ work@07b86898f1f3:/work/imx$ cp /share/rootfs.img ./ work@07b86898f1f3:/work/imx$ mkfs.ext4 rootfs.img mke2fs 1.44.4 (18-Aug-2018) rootfs.img contains a ext4 file system last mounted on / on Thu Jul 16 06:52:07 2020 Proceed anyway? (y,n) y Discarding device blocks: done Creating filesystem with 307200 1k blocks and 76912 inodes Filesystem UUID: 280abf1c-6085-49be-8167-d4268b21abc0 Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
挂载rootfs.img
work@07b86898f1f3:/work/imx$ ls ToolChain-6.2.1-master busybox-1.31.1 env_cross linux-4.9 rootfs rootfs.img u-boot-2017.03 work@07b86898f1f3:/work/imx$ sudo su [sudo] password for work:123456 root@07b86898f1f3:/work/imx# sudo mount rootfs.img rootfs root@07b86898f1f3:/work/imx# cd rootfs/ root@07b86898f1f3:/work/imx/rootfs# ls lost+found root@07b86898f1f3:/work/imx/rootfs# cd ..
配置busybox
root@07b86898f1f3:/work/imx# source env_cross root@07b86898f1f3:/work/imx# cd busybox-1.31.1/ root@07b86898f1f3:/work/imx/busybox-1.31.1# make distclean root@07b86898f1f3:/work/imx/busybox-1.31.1# make defconfig root@07b86898f1f3:/work/imx/busybox-1.31.1# make menuconfig
配置安装路径:setting->Installation Options ->(./_install) Destination path for ‘make install’ ->(/work/imx/rootfs) Destination path for ‘make install’ PS: shift+backpace可删除()里面的数据
配置静态链接busybox:setting->Build Options->[ ] Build static binary (no shared libs)->[*] Build static binary (no shared libs)
Exit保存配置
编译和安装busybox
root@07b86898f1f3:/work/imx/busybox-1.31.1# make -jN #N为cpu核心数,例如make -j4 root@07b86898f1f3:/work/imx/busybox-1.31.1# make install root@07b86898f1f3:/work/imx/busybox-1.31.1# cd ../rootfsroot@07b86898f1f3:/work/imx/rootfs# mkdir root etc dev lib tmp mnt sys proc varroot@07b86898f1f3:/work/imx/rootfs# mkdir -p usr/lib
配置rootfs文件
创建设备节点
root@07b86898f1f3:/work/imx/rootfs# cd dev/ root@07b86898f1f3:/work/imx/rootfs/dev# ls root@07b86898f1f3:/work/imx/rootfs/dev# mknod -m 666 console c 5 1 root@07b86898f1f3:/work/imx/rootfs/dev# mknod -m 666 null c 1 3 root@07b86898f1f3:/work/imx/rootfs/dev# mknod -m 666 ttymxc0 c 207 16root@07b86898f1f3:/work/imx/rootfs/dev# ls -l total 0 crw-rw-rw- 1 root root 5, 1 Jul 16 06:58 console crw-rw-rw- 1 root root 1, 3 Jul 16 06:58 null crw-rw-rw- 1 root root 207, 16 Jul 16 06:59 ttymxc0
配置etc文件
root@07b86898f1f3:/work/imx/rootfs/dev# cd ../etc/ root@07b86898f1f3:/work/imx/rootfs/etc# cp -rf /work/imx/busybox-1.31.1/examples/bootfloppy/etc/* ./ root@07b86898f1f3:/work/imx/rootfs/etc# ls fstab init.d inittab profile
fstab:
root@07b86898f1f3:/work/imx/rootfs/etc# cat > fstab << EOF proc /proc proc defaults 0 0 tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
var /dev tmpfs defaults 0 0
ramfs /dev ramfs defaults 0 0
EOF root@07b86898f1f3:/work/imx/rootfs/etc# cat fstab
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
var /dev tmpfs defaults 0 0
ramfs /dev ramfs defaults 0 0
profile:
root@07b86898f1f3:/work/imx/rootfs/etc# cat > profile << EOF
/etc/profile: system-wide .profile file for the Bourne shells
export HOSTNAME=`/bin/hostname`
export USER=`id -un`
export LOGNAME=$USER
export PS1=”[\u@\h \W]# “
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib:\$LD_LIBRARY_PATH
export PATH LD_LIBRARY_PATH
EOF
root@07b86898f1f3:/work/imx/rootfs/etc# cat profile
/etc/profile: system-wide .profile file for the Bourne shells
export HOSTNAME=
/bin/hostname
export USER=
id -un
export LOGNAME=\$USER
export PS1=”[\u@\h \W]# “
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH
export PATH LD_LIBRARY_PATH
inittab:
root@07b86898f1f3:/work/imx/rootfs/etc# cat > inittab << EOF
/etc/inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::restart:/sbin/init
EOF
root@07b86898f1f3:/work/imx/rootfs/etc# cat inittab
/etc/inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::restart:/sbin/init
group:
root@07b86898f1f3:/work/imx/rootfs/etc# cat > group << EOF
root:x:0:
EOF
root@07b86898f1f3:/work/imx/rootfs/etc# cat group
root:x:0:
passwd:
root@07b86898f1f3:/work/imx/rootfs/etc# cat > passwd << EOF
root:x:0:0:Linux User,,,:/root:/bin/sh
EOF
root@07b86898f1f3:/work/imx/rootfs/etc# cat passwd
root:x:0:0:Linux User,,,:/root:/bin/sh
hostname:
root@07b86898f1f3:/work/imx/rootfs/etc# mkdir sysconfig
root@07b86898f1f3:/work/imx/rootfs/etc# cd sysconfig/ root@07b86898f1f3:/work/imx/rootfs/etc/sysconfig# cat > hostname << EOF
imx6ull
EOF
root@07b86898f1f3:/work/imx/rootfs/etc/sysconfig# cat hostname
imx6ull root@07b86898f1f3:/work/imx/rootfs/etc/sysconfig# cd ..
rcS:
root@07b86898f1f3:/work/imx/rootfs/etc# cd init.d/ root@07b86898f1f3:/work/imx/rootfs/etc/init.d# cat > rcS << EOF
! /bin/sh
/bin/mount -a
/bin/mkdir -p /dev/pts
/bin/mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s
ifconfig lo 127.0.0.1
/bin/hostname -F /etc/sysconfig/hostname
EOF
root@07b86898f1f3:/work/imx/rootfs/etc/init.d# cat rcS
! /bin/sh
/bin/mount -a
/bin/mkdir -p /dev/pts
/bin/mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s
ifconfig lo 127.0.0.1
/bin/hostname -F /etc/sysconfig/hostname
rootfs.img制作完成
root@07b86898f1f3:/work/imx/rootfs/etc/init.d# cd ../../../
root@07b86898f1f3:/work/imx# umount rootfs
root@07b86898f1f3:/work/imx# ls rootfs.img
rootfs.img
root@07b86898f1f3:/work/imx#