如何使用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
添加用户
adduser faker
vim /etc/sudoers
设置本机名称和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
⬇️有箭头的特别要注意⬇️