Linux常用系统定制
Ubuntu文件系统修改
chroot 方式
1. 搭建构建环境
修改前先备份保留原本的镜像
2. 解压
3. chroot 进行挂载,等同于在 root 下进行修改ubuntu镜像
// 配置以及挂载
$ ./ch-mount.sh -m rootfs_k4b
$ sudo cp -b /etc/resolv.conf rootfs_k4b/etc/resolv.conf
$ sudo cp -b /usr/bin/qemu-arm-static rootfs_k4b/usr/bin/
// 通过chroot挂载修改
$ sudo chroot rootfs_k4b
# export LC_ALL=C.UTF-8
# echo "nameserver 8.8.8.8" >> etc/resolv.conf
# echo "nameserver 114.114.114.114" >> etc/resolv.conf
// 测试是否有网
# ping www.baidu.com
# apt-get update
# apt-get upgrade
// 下载需要的东西 或 修改文件
# apt install
// chroot下用exit退出
# exit
// 取消挂载(注意:必须取消挂载!!!)
$ ./ch-mount.sh -u rootfs_k4b
4. 将修改后的ubuntu重新打包(必须取消挂载!)
rm -v ubuntu-armhf.tar.gz
cd rootfs_k4b/
sudo tar -zcf ../ubuntu-armhf.tar.gz .
cd ..
ls ubuntu-armhf.tar.gz
5. 重新编译./build.sh , 会将新的 rootfs 打包编译进镜像。
overlay 方式修改ubuntu
将需要替换的文件存放到此目录下,编译会拷贝替换 rootfs 对应路径下的文件
比如,需要将脚本放到 /etc/test.sh,则放到代码路径
编译会拷贝到根目录 /etc/test.sh