瑞芯微Rockchip开发者社区
直播中

张静

7年用户 1479经验值
私信 关注
[问答]

如何制作rk3399 arm64 ubuntu18.04 根文件系统?

如何制作rk3399 arm64 ubuntu18.04 根文件系统?

回帖(1)

庞书娟

2022-3-7 10:48:22
1、下载ARM64根文件系统 ubuntu-base-18.04.5-base-arm64.tar.gz

   http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/

2、制作根文件系统



  • 安装qeum模拟器


sudo apt-get install qemu-user-static



  • 解压文件


mkdir rootfs

tar -xvf ubuntu-base-18.04.5-base-arm64.tar.gz -C rootfs/





  • 拷贝模拟器到文件系统


sudo cp /usr/bin/qemu-aarch64-static rootfs/usr/bin/





  • 拷贝域名解析文件到根文件系统,为连网做准备


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



  • 切换到到根文件系统进行操作
  • 添加一个挂载的脚本


#!/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 chroot ${2}
}

function umnt() {
    echo "UNMOUNTING"
    sudo umount ${2}/proc
    sudo umount ${2}/sys
    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


  • 执行命令,将工作目录切换到rootfs中


sudo bash rootfs-mount.sh -m rootfs



  • 根新下载源为华为源,这样下载速度比较快,打开/etc/apt/source.list,修改内容如下


deb http://mirrors.huaweicloud.com/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-proposed main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-proposed main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ bionic-updates main multiverse restricted universe
apt-get update



  • 下载所需要的软件


apt-get install  language-pack-en-base  sudo  ssh  net-tools  ethtool  wireless-tools  ifupdown  network-manager iputils-ping  rsyslog  bash-completion  htop  --no-install-recommends



  • 添加用户及设置密码


useradd -s '/bin/bash' -m -G adm,sudo ubuntu



  • 给用户设置密码


passwd ubuntu



  • 给root用户设置密码


passwd root



  • 修改完自己的根文件系统就可以退出了


exit



  • 制作根文件系统


dd if=/dev/zero of=linuxroot.img bs=1M count=1024
sudo mkfs.ext4 linuxroot.img
mkdir  hyrootfs
sudo mount linuxroot.img hyrootfs/
sudo cp -rfp rootfs/*  hyrootfs/
sudo umount hyrootfs/
e2fsck -p -f linuxroot.img
resize2fs  -M linuxroot.img
这样 linuxroot.img 就是最终的根文件系统映像文件了。

举报

更多回帖

发帖
×
20
完善资料,
赚取积分