修改适用于ARM平台上的Ubuntu rootfs(根文件系统)

0、背景

 本文在RK3399开发板上的Ubuntu rootfs(根文件系统)基础上进行用户自定义软件,并生成可以进行烧录的统一固件。

1、获得Ubuntu rootfs

Ubuntu rootfs镜像压缩包
将ubuntu-rootfs.img.tar.bz2里面的ubuntu-rootfs.img解压出来,用于后面的镜像挂载。
创建一个目录,我们接下来在这个目录中构建目标rootfs

mkdir ~/ubuntu-rootfs
cd ubuntu-rootfs 

将ubuntu-rootfs.img拷贝到ubuntu-rootfs里面

2、挂载ubuntu-rootfs.img

sudo mount -o loop ubuntu-rootfs.img ~/ubuntu-rootfs

//将ubuntu-rootfs.img挂载到刚才建的目录(~/ubuntu-rootfs)里

3、下载qemu static解释器

由于我们要chroot,所以需要能够在chroot环境执行armhf版本的binary,所以我们要接触linux的binfmt机制和qemu static解释器

sudo apt-get install qemu-user-statica
sudo cp /usr/bin/qemu-arm-static /home/cjn/ubuntu-rootfs/usr/bin/

4、先将本机的dns配置复制到目标rootfs,后面联网时会用到

sudo cp -b /etc/resolv.conf ~/ubuntu-rootfs/etc/resolv.conf

5、挂载相关文件系统并chroot

sudo mount -t proc /proc ~/ubuntu-rootfs/proc
sudo mount -t sysfs /sys ~/ubuntu-rootfs/sys
sudo mount -o bind /dev ~/ubuntu-rootfs/dev
sudo mount -o bind /dev/pts ~/ubuntu-rootfs/dev/pts
# 进入chroot环境
sudo chroot ~/ubuntu-rootfs/
# 更新repo
sudo apt-get update

6、 添加自己的软件,此时进行的所有操作和改变,都是在根文件系统中进行的

7、退出chroot环境

exit

8、卸载ubuntu-rootfs.img镜像

sudo umount /home/cjn/ubuntu-rootfs

大功告成

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值