【imx6ul 学习笔记】移植ubuntu 20.04系统

文章目录

上一篇:【imx6ul 学习笔记】Docker 运行百问网 imx6ul_qemu

前置准备

复制代码
cd ubuntu-18.04_imx6ul_qemu_system/

备份原文件:先把 imx6ull-system-image/rootfs.img 重命名备份

bash 复制代码
sudo apt update
sudo apt install -y debootstrap qemu-user-static binfmt-support

制作 Ubuntu 20.04 ARM 根文件系统

在主机 Linux 执行

创建工作目录

随便找个地方

bash 复制代码
mkdir ubuntu_imx6ull && cd ubuntu_imx6ull

下载 Ubuntu20.04 armhf 最小系统

bash 复制代码
# --arch=armhf 适配 i.MX6ULL,focal=Ubuntu20.04
sudo debootstrap --arch=armhf --foreign focal ubuntu_rootfs http://ports.ubuntu.com/ubuntu-ports/

拷贝 qemu 模拟器

让 x86 主机能运行 ARM 程序

bash 复制代码
sudo cp /usr/bin/qemu-arm-static ubuntu_rootfs/usr/bin/

进入 ARM 环境完成系统配置

bash 复制代码
sudo chroot ubuntu_rootfs /bin/bash

进入后命令行变成

bash 复制代码
groups: cannot find name for group ID 0
I have no name!@xxx:/# 

配置系统

系统初始化

在 chroot 后的 ARM Ubuntu 终端 执行以下命令:

bash 复制代码
/debootstrap/debootstrap --second-stage

设置 root 密码

bash 复制代码
passwd root
# 输入两次密码

开启串口登录

i.MX6ULL QEMU 用 ttymxc0 串口

bash 复制代码
# 1. 创建串口登录服务软链接 让系统开机自动启动 ttymxc0 串口
ln -s /lib/systemd/system/serial-getty@.service /etc/systemd/system/getty.target.wants/serial-getty@ttymxc0.service

# 2. 允许 root 用户通过串口 ttymxc0 登录
echo "ttymxc0" >> /etc/securetty

配置软件源

bash 复制代码
cat > /etc/apt/sources.list << EOF
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
EOF

安装基础工具

按需安装

bash 复制代码
apt update
apt install -y net-tools iputils-ping vim ssh

退出 chroot 环境

bash 复制代码
exit

打包成 QEMU 能用的 rootfs.img

打包成 raw 格式 ext4 镜像

创建 4G 空镜像文件

bash 复制代码
sudo dd if=/dev/zero of=rootfs.img bs=1G count=4

格式化为 ext4

bash 复制代码
sudo mkfs.ext4 rootfs.img

挂载镜像拷贝系统

bash 复制代码
# 创建挂载目录
sudo mkdir mnt
# 挂载镜像
sudo mount -o loop rootfs.img mnt
# 拷贝所有 Ubuntu 文件
sudo cp -rp ubuntu_rootfs/* mnt/
# 卸载镜像
sudo umount mnt

替换镜像并运行

把刚做好的 rootfs.img复制到 imx6ull-system-image/ 覆盖原文件

使用原有的启动脚本

bash 复制代码
./qemu-imx6ull-gui.sh


相关推荐
希和202712 小时前
江科大 51 单片机笔记:DS18B20 温度传感器 + LCD1602 显示代码详解
笔记·单片机·mongodb
电科_银尘15 小时前
【深度学习项目实战·22】灰度图像着色:用小型U-Net学习从灰度到RGB
人工智能·深度学习·学习
Sakura_j_h_16 小时前
MCP SDK 2.0 实战:用 MCPServer 搭本地笔记检索服务
开发语言·笔记·python·qt·ai工具·mcp·mcpserver
QuZhengRong16 小时前
【AI】Agent 全栈进阶|AgentScope 沙箱源码解析
python·学习·ai·agent·沙箱
前进的李工19 小时前
Agent 学习笔记 15:Agent 怎样响应事件与中途打断?
人工智能·笔记·agent·openclaw·工具设计·gpt-6 astra·原生异步
承渊政道21 小时前
【Python编程—从入门到实践】(用户账户:给Django网站装上登录系统,让每个人拥有自己的学习笔记)
python·学习·pycharm·django
诗句藏于尽头1 天前
游戏《完美神话》-使用Ai-agent进行修复已停服游戏到本地成功部署以及GM端网页完整教程
人工智能·学习·游戏
希和20271 天前
51 单片机学习笔记:LCD1602、独立按键、I2C 与 AT24C02 掉电存储(江科大课程小白笔记)
笔记·单片机·学习
北风toto1 天前
Spring Boot 常用注解 · 概要笔记
spring boot·笔记·后端
承渊政道1 天前
【Python编程—从入门到实践】(设置样式并部署:给Django网站换新装,把学习笔记发布到互联网)
python·学习·pycharm·django