【RK3399】rk3399 arm64 ubuntu18.04 根文件系统制作

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 就是最终的根文件系统映像文件了。

 

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值