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
相关推荐
一个平凡而乐于分享的小比特7 分钟前
Linux内核构建三剑客:Kconfig、.config与Makefile关系详解
linux·makefile·kconfig·.config
Dillon Dong8 分钟前
服务器运维:Linux 磁盘查看 & 清理常用命令
linux·运维·服务器
ben9518chen13 分钟前
Linux用户管理
linux·运维·服务器
用户6135411460161 小时前
xampplinux_v174beta11在 Linux 下的安装与配置步骤
linux
Byron Loong1 小时前
【系统】Mac系统和Linux 指令对比
linux·macos·策略模式
markvivv1 小时前
在 Kylin Linux Advanced Server for Kunpeng V10 上构建 VSCode 1.106
linux·vscode·kylin
看见繁华2 小时前
Linux 交叉编译实践笔记
linux·运维·笔记
tianyuanwo2 小时前
深入解析CentOS 8网络配置:NetworkManager DNS管理机制与网卡类型深度剖析
linux·网络·centos
tianyuanwo2 小时前
深入解析CentOS 8中NetworkManager重启后DNS配置被覆盖的机制与解决方案
linux·运维·centos·dns
Dragon~Snow2 小时前
Linux-centOS Stream 9 系统 mysql-8.4.7 RPM版本
linux·mysql·centos