随笔 - 20  文章 - 0  评论 - 1  阅读 - 8060

如何使用Ubunut20.04根文件系统

rootfs

cd /home/kun/ubuntu_rootfs
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️第一次⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
sudo apt-get install qemu-user-static
⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️第一次⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️
tar -xzf ubuntu-base-20.04.5-base-arm64.tar.gz -C  ./
sudo cp -b /usr/bin/qemu-aarch64-static ./usr/bin/   (arm64与arm有区别)
sudo cp /etc/resolv.conf ./etc/resolv.conf
sudo cp /home/kun/shao-gaoyan/ubuntu_rootfs/ubuntu/sources.list ./etc/apt
挂载到本地PC
sh ch-mount.sh -m ubuntu_rootfs/
安装常用的命令和软件
export LC_ALL=C.UTF-8
export APT_INSTALL="apt-get install -fy --allow-downgrades"
apt-get -y update
apt-get -f -y upgrade
DEBIAN_FRONTEND=noninteractive apt-get install -y  rsyslog sudo dialog apt-utils
apt-get install -fy --allow-downgrades net-tools ifupdown ethtool iputils-ping udhcpc vim udev network-manager
设置 root 用户密码
passwd root
123456

img

添加用户
adduser faker

img

vim /etc/sudoers

img

设置本机名称和IP地址
echo "Ubuntu" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.1.1 Ubuntu" >> /etc/hosts  
配置网络 dhcp
vim /etc/network/interfaces
⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️
auto lo
allow-hotplug eth0
iface eth0 inet dhcp
⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️
上记使用的脚本
 #!/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        
    sudo chroot ${2}
}
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 bothparameters were missing"
    echo ""
    echo "1'st parameter can be one ofthese: -m(mount) OR -u(umount)"
    echo "2'nd parameter is the full pathof rootfs directory(with trailing '/')"
    echo ""
    echo "For example: ch-mount -m/media/sdcard/"
    echo ""
    echo 1st parameter : ${1}
    echo 2nd parameter : ${2}
fi   

⬇️有箭头的特别要注意⬇️

参考

https://doc.embedfire.com/linux/rk356x/build_and_deploy/zh/latest/building_image/ubuntu_rootfs/ubuntu_rootfs.html

有问题随时联系

posted on   Ctrl攻城狮  阅读(98)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示