【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


相关推荐
chouchuang19 小时前
day-030-综合练习-笔记管理器
开发语言·笔记·python
不羁的木木21 小时前
HarmonyOS APP实战-基于Image Kit的图像处理APP - 第9篇:批量处理与编辑历史
图像处理·ubuntu·harmonyos
从零开始的代码生活_21 小时前
C++ list 原理与实践:双向链表、迭代器与简化实现
开发语言·c++·后端·学习·算法·链表·list
春卷同学21 小时前
HarmonyOS掌上记账APP开发实践第15篇:ArkTS 类型系统深度解析 — 从接口到联合类型的灵活运用
ubuntu·华为·harmonyos
二炮手亮子21 小时前
记录AI学习之路Day13:小模型(AI生成)
学习
程序员小八7771 天前
从 0 学习 MySQL 索引——7 大核心精讲
android·学习·mysql
渣渣灰飞1 天前
MySQL 系统学习 第六阶段:Redis + 缓存 + 高并发设计 第六章:Redis 实现登录 Token
学习·mysql·缓存
渣渣灰飞1 天前
MySQL 系统学习 第六阶段:Redis + 缓存 + 高并发设计 第五章:缓存穿透、缓存击穿、缓存雪崩
学习·mysql·缓存
岑梓铭1 天前
《考研408数据结构》第六章(6.3 图的遍历)复习笔记
数据结构·笔记·考研··拓扑排序·408
he_wen_jian1 天前
【无标题】
笔记