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
相关推荐
花嫁代二娃4 小时前
Linux:环境变量
linux
l1x1n010 小时前
Vim 编辑器常用操作详解(新手快速上手指南)
linux·编辑器·vim
ajassi200011 小时前
开源 python 应用 开发(三)python语法介绍
linux·python·开源·自动化
o不ok!11 小时前
Linux面试问题-软件测试
linux·运维·服务器
DaxiaLeeSuper11 小时前
Prometheus+Grafana+node_exporter监控linux服务器资源的方案
linux·grafana·prometheus
GateWorld11 小时前
RISC-V:开源芯浪潮下的技术突围与职业新赛道 (二) RISC-V架构深度解剖(上)
架构·risc-v·指令集精简·寄存器设计·特权架构·模块化扩展
尽兴-12 小时前
如何将多个.sql文件合并成一个:Windows和Linux/Mac详细指南
linux·数据库·windows·sql·macos
kfepiza12 小时前
Netplan 中 bridges、bonds、ethernets、vlans 之间的关系 笔记250711
linux·tcp/ip·shell
小小不董13 小时前
深入理解oracle ADG和RAC
linux·服务器·数据库·oracle·dba
杰夫贾维斯14 小时前
CentOS Linux 8 的系统部署 Qwen2.5-7B -Instruct-AWQ
linux·运维·人工智能·机器学习·centos