MPSOC 移植ubuntu文件系统
0、uboot和kernel准备(有关petalinux的介绍我就不多说了参见ug1144)
- 利用petalinux配置文件系统格式、根文件系统路径
1、下载ubuntu-base
- 打开ubuntu-base下载网址,根据自己的需求下载ubuntu版本,我下载的是ubuntu-base-22.04-base-amd64.tar.gz
2、解压
mkdir rootfs
tar xzvf ubuntu-base-XXXXXX.tar.gz -C ./rootfs
cd rootfs
3、安装 qemu-user-static(为了在PC上模拟运行根文件系统)
apt-get install qemu-user-static
cp /usr/bin/qemu-aarch64-static usr/bin/
4、拷贝PC主机端网络配置到虚拟根文件系统中
cp -b /etc/resolv.conf etc/resolv.conf
5、创建mount.sh,放置于rootfs同等级目录下
#!/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
chmod +x mount.sh
- 通过mount.sh脚本chroot到arm64的文件系统下
./mount.sh -m rootfs/
6、下载基础软件(一定要找一个网速好的地方)
apt update
apt install language-pack-en-base
apt install sudo
apt install ssh
apt install net-tools
apt install ssh
apt install network-manager
apt install iputils-ping
apt install rsyslog
apt install bash-completion
apt install gcc
apt install vim
7、添加用于名和密码
useradd -s '/bin/bash' -m -G adm,sudo bohai
passwd bohai
passwd root
8、设置主机名
echo 'ubuntu' > /etc/hostname
echo '127.0.0.1 ubuntu' >> /etc/hosts
9、保存退出
exit
./mount -u rootfs/
10、打包压缩
sudo tar -zcvf rootfs.tar.gz -C rootfs/ .
11、解压到SD卡第二分区(EXT4格式的文件系统)
sudo tar xzvf rootfs.tar.gz -C /media/xxx/EXT
- 注意的的SD卡EXT4分区盘符的名字叫做“EXT”
- /media/xxx/EXT表示盘符挂载路径,根据实际情况更改
12、新建网卡配置文件01-network-manager-all.yaml
sudo cp 01-network-manager-all.yaml /media/hhl/EXT4/etc/netplan/
13、插入SD卡上电启动
14、注意
- 上述的一些指令如果不能正常运行请切换至sudo权限
|