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
相关推荐
轻松Ai享生活15 小时前
5 节课深入学习Linux Cgroups
linux
christine-rr15 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
三坛海会大神55515 小时前
LVS与Keepalived详解(二)LVS负载均衡实现实操
linux·负载均衡·lvs
東雪蓮☆15 小时前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
乌萨奇也要立志学C++16 小时前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
獭.獭.18 小时前
Linux -- 信号【上】
linux·运维·服务器
hashiqimiya18 小时前
centos配置环境变量jdk
linux·运维·centos
hashiqimiya18 小时前
权限更改centos中系统文件无法创建文件夹,使用命令让普通用户具备操作文件夹
linux
逆小舟1 天前
【Linux】人事档案——用户及组管理
linux·c++
青草地溪水旁1 天前
pthread_mutex_lock函数深度解析
linux·多线程·pthread