qemu制作ubuntu文件系统

ZYNQ系列文章目录

第一章:基于zynq的phy调试记录
第二章:qemu制作ubuntu文件系统


前言

记录zynq调试:

从petalinux的搭建,到uboot、kernel、rootfs的调试、打包


提示:以下是本篇文章正文内容,下面案例可供参考

一、ubuntu获取

进入以下地址http://cloud-images.ubuntu.com/下载ARM版本的ubuntu

mkdir -p rootfs
sudo tar -xvpf ubuntu-18.04-armhf.tar.gz -C rootfs/”

使用ls -al查看目录,该有的都有了
在这里插入图片描述

二、QEMU环境配置

1、qemu下载安装

sudo apt-get install qemu-user-static

然后将qemu工具链拷贝到rootfs下

cd /****/rootfs //进入到rootfs目录下
sudo cp /usr/bin/qemu-arm-static ./usr/bin/ //拷贝 qemu-arm-static

2、设置软件源

在设置软件源之前先将 Ubuntu主机下的 DNS配置文件 /etc/resolv.conf拷贝到根文件系统中,命令如下:

sudo rm -f ./etc/resolv.conf //删除
sudo cp /etc/resolv.conf ./etc/resolv.conf //拷贝 resolv.conf

设置软件源,打开根文件系统中的 ubuntu_rootfs/etc/apt/sources.list文件,在此文件最后面添加软件源。

deb http://ports.ubuntu.com/ubuntu-ports/ focal main universe

三、挂在rootfs

1、挂载脚本编写

在rootfs同级目录,新建mount.sh,添加以下内容

#!/bin/bash
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}
}
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 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 chmod 777 mount.sh

2、挂载及卸载

sudo ./mount.sh -m rootfs/”

在这里插入图片描述
使用 apt update更新各种应用。(之前已经更新过了,所以火速结束)
在这里插入图片描述
这个阶段可以自己添加一些必要的或者工具,比如mii-tools ethtools C库等等。。。。

在qemu模拟arm-ubuntu中配置或者下载后使用以下命令卸载dev设备(不然下次挂载不上)

sudo ./mount.sh -u rootfs/

总结

这里对文章进行总结:
本次要讲述的QEMU小知识就说到这里了,兄弟萌要有什么指导意见或疑问可以在评论区留下"足迹"。

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值