RISC-V Linux系统rootfs制作

文章目录

buildroot 是一个构建嵌入式Linux系统的框架。整个 buildroot 是由Makefile(*.mk) 脚本和 Kconfig(Config.in) 配置文件构成的,因此可以像配置 Linux 内核一样执行 make menuconfig 进行配置,编译出一个完整的、可以直接烧写到机器上运行的 Linux 系统文件(包含 bootloader、kernel、rootfs 以及 rootfs 中的各种库和应用程序)。

文件系统可以用 busybox、buildroot 等工具制作,busybox 需要自己一步一步的做出来,过程比较麻烦。更便捷的做法是使用 buildroot,它可以自动帮我们完成。

1、下载

官网:https://buildroot.org/download.html

历史版本下载:https://buildroot.org/downloads

shell 复制代码
$ wget https://buildroot.org/downloads/buildroot-2023.02.1.tar.gz
$ tar -zxvf buildroot-2023.02.1.tar.gz
$ cd buildroot-2023.02.1

2、配置与编译

  • 安装依赖
shell 复制代码
$ sudo apt-get -y install build-essential libncurses-dev cpio rsync file unzip bc
  • 配置buildroot
shell 复制代码
$ make menuconfig
  1. 选择RISC-V架构
shell 复制代码
Target options --->
    Target Architecture (i386) --->
        (X) RISCV

Target Architecture Size (64-bit)
  1. 选择ext文件系统类型:
shell 复制代码
Filesystem images --->
    [*] ext2/3/4 root filesystem
        ext2/3/4 variant (ext4)
  • 编译
shell 复制代码
$ make -j10

buildroot 编译过程需要联网,在线下载交叉编译器和各种工具。

编译完后,生成文件在 output/images 目录下,rootfs.ext2 是我们需要用到的。

3、运行

shell 复制代码
#!/bin/sh

qemu-system-riscv64 \
-M virt \
-bios opensbi/build/platform/generic/firmware/fw_jump.elf \
-kernel linux-5.10.181/arch/riscv/boot/Image \
-append "rootwait root=/dev/vda ro" \
-drive file=buildroot-2023.02.1/output/images/rootfs.ext2,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic
相关推荐
蝎子莱莱爱打怪6 小时前
ESXi 强制断电后恢复CentOS7虚拟机避坑指南:解决重复注册&目录清理难题
linux·后端·程序员
xlp666hub1 天前
Leetcode第五题:用C++解决盛最多水的容器问题
linux·c++·leetcode
张宏2361 天前
原子操作 (基于Linux 应用层 C 语言)
linux
kymjs张涛2 天前
OpenClaw 学习小组:初识
android·linux·人工智能
程序设计实验室2 天前
经历分享,发现挖矿木马后,服务器快速备份与重装(腾讯云平台)
linux
Miku162 天前
OpenClaw-Linux+飞书官方Plugin安装指南
linux·人工智能·agent
Miku162 天前
OpenClaw 接入 QQ Bot 完整实践指南
linux·人工智能·agent
Yogurt_cry2 天前
[树莓派4B] 闲置近10年的爱普生 L310 打印机爆改无线打印机
linux·物联网·树莓派
Johny_Zhao3 天前
OpenClaw中级到高级教程
linux·人工智能·信息安全·kubernetes·云计算·yum源·系统运维·openclaw
Sheffield4 天前
Docker的跨主机服务与其对应的优缺点
linux·网络协议·docker