firefly自带的文件系统,由于缺少一些基本功能模块,因此,我们可以自己手动制作一个ubuntu20.04的文件系统。
下载Ubuntu根文件系统
安装虚拟机
apt-get install qemu-user-static
解压
mkdir ubuntu-rootfs tar -xpf ubuntu-base-20.04.5-base-arm64.tar.gz -C ubuntu-rootfs
复制一下虚拟机的运行环境
cp -b /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf cp /usr/bin/qemu-aarch64-static ubuntu-rootfs/usr/bin/
复制官方外设驱动文件
将开发板挂载到虚拟机上,将开发板的/vendor,/system,/lib/firmware,这三个文件夹复制到我们自己的文件系统中。
挂载根文件系统
创建ch-mount.sh文件,写入以下脚本
#!/bin/bash # function mnt() { echo "MOUNTING..." sudo mount -t proc /proc ${2}proc sudo mount -t sysfs /sys ${2}sys sudo mount -o bind /dev ${2}dev sudo mount -o bind /dev/pts ${2}dev/pts echo "CHROOT..." sudo chroot ${2} echo "Success!" } function umnt() { echo "UNMOUNTING" sudo umount ${2}proc sudo umount ${2}sys sudo umount ${2}dev/pts sudo umount ${2}dev } if [ "$1" == "-m" ] && [ -n "$2" ] ; then mnt $1 $2 elif [ "$1" == "-u" ] && [ -n "$2" ]; then umnt $1 $2 else echo "" echo "Either 1'st, 2'nd or both parameters were missing" echo "" echo "1'st parameter can be one of these: -m(mount) OR -u(umount)" echo "2'nd parameter is the full path of rootfs directory(with trailing '/')" echo "" echo "For example: ch-mount -m /media/sdcard/" echo "" echo 1st parameter : ${1} echo 2nd parameter : ${2} fi
把下载好的脚本置于ubuntu-rootfs目录的上一级目录,并修改权限:
chmod a+x ch-mount.sh ./ch-mount.sh -m ubuntu-rootfs/
执行mount动作,注意退出后一定再执行 ./ch-mount.sh -u ubuntu-rootfs/,否则你的本机ubuntu系统会出问题,需要重启才能恢复正常。
拷贝bash依赖库
执行挂载脚本时遇到以下错误,可以拷贝bash动态库。
➜ tools sudo chroot ubuntu-rootfs chroot: failed to run command ‘/bin/zsh’: No such file or directory
查看/bin/bash文件所依赖的动态链接库,然后依次拷贝到相应目录。由于我安装了zsh,所以除了拷贝bash动态库外,还需要拷贝zsh动态库。没有安装zsh的可以不用拷贝zsh动态库。
zhongyi@ubuntu:~$ ldd /bin/zsh linux-vdso.so.1 (0x00007ffd5c1dc000) libcap.so.2 => /lib/x86_64-linux-gnu/libcap.so.2 (0x00007f4b4d9d7000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4b4d7d3000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f4b4d5a9000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4b4d20b000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4b4ce1a000) /lib64/ld-linux-x86-64.so.2 (0x00007f4b4debc000) zhongyi@ubuntu:~$ ldd /bin/bash linux-vdso.so.1 (0x00007ffd8335a000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f50a4d2a000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f50a4b26000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f50a4735000) /lib64/ld-linux-x86-64.so.2 (0x00007f50a526e000)
$ mkdir lib64 $ cp /lib64/ld-linux-x86-64.so.2 ./lib64/ $ mkdir ./lib/x86_64-linux-gnu $ cp /lib/x86_64-linux-gnu/libtinfo.so.5 ./lib/x86_64-linux-gnu/ $ cp /lib/x86_64-linux-gnu/libdl.so.2 ./lib/x86_64-linux-gnu/ $ cp /lib/x86_64-linux-gnu/libc.so.6 ./lib/x86_64-linux-gnu/ $ cp /lib/x86_64-linux-gnu/libcap.so.2 ./lib/x86_64-linux-gnu/ $ cp /lib/x86_64-linux-gnu/libm.so.6 ./lib/x86_64-linux-gnu/ $ cp /lib/x86_64-linux-gnu/libc.so.6 ./lib/x86_64-linux-gnu/ $cp /bin/bash ubuntu-rootfs/bin $cp /bin/zsh ubuntu-rootfs/bin
执行挂载
成功挂载后,会看到自动切换为root用户。
zhongyi@ubuntu:~/tools$ ./ch-mount.sh -m ubuntu-rootfs/ MOUNTING... CHROOT... zsh: failed to load module `zsh/zle': /usr/lib/x86_64-linux-gnu/zsh/5.4.2/zsh/zle.so: cannot open shared object file: No such file or directory #已经成功挂载 ubuntu#
安装必要的软件
apt-get update apt-get -y install vim nfs-common sudo ssh net-tools ethtool wireless-tools xfce4-power-manager xinit network-manager iputils-ping rsyslog bash-completion lxtask htop synaptic --no-install-recommends
更换源
vim /etc/apt/source.list #添加中科大源 deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe #添加阿里源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse #添加清华源 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
设置账户名和密码
useradd -s '/bin/bash' -m -G adm,sudo firefly passwd firefly passwd root
设置主机名
echo 'ubuntu.firefly' > /etc/hostname
添加主机入口到/etc/hosts
127.0.0.1 localhost 127.0.0.1 ubuntu.firefly 127.0.1.1 firefly
添加nameserver
vim /etc/resolvconf/resolv.conf.d/head #添加nameserver nameserver 114.114.114.114 nameserver 8.8.8.8
取消挂载
exit ./ch-mount.sh -u ubuntu-rootfs/
创建 mkrootfs.sh文件,写入以下脚本,其中2048取决于你的根文件系统实际大小,比如安装了桌面环境后若大小超过2048M,就改大一点
#!/bin/bash # dd if=/dev/zero of=ubuntu-rootfs.img bs=1M count=2048 sudo mkfs.ext4 ubuntu-rootfs.img rm -r rootfs mkdir rootfs sudo mount ubuntu-rootfs.img rootfs/ sudo cp -rfp ubuntu-rootfs/* rootfs/ sudo umount rootfs/ e2fsck -p -f ubuntu-rootfs.img resize2fs -M ubuntu-rootfs.img
执行制作
➜ tools ./mkrootfs.sh ➜ tools ls -al |grep *.img -rw-rw-r-- 1 zhongyi zhongyi 1497706496 Sep 30 21:32 ubuntu-rootfs.img
烧写镜像
sudo upgrade_tool di -rootfs ubuntu-rootfs.img
审核编辑:汤梓红
全部0条评论
快来发表一下你的评论吧 !