首页 > 其他分享 >qemu运行树莓派系统

qemu运行树莓派系统

时间:2024-03-24 23:35:55浏览次数:25  
标签:树莓 img qcow2 sudo raspios armhf qemu 运行

qemu运行树莓派系统

去树莓派官网下载需要的镜像 https://downloads.raspberrypi.com/

Go to the Raspberry PI website to download the required image -> https://downloads.raspberrypi.com/

看你的需求选armhf或者arm64

Choose armhf or arm64 depending on your needs

[DIR] raspios_arm64/ -
[DIR] raspios_armhf/ -
[DIR] raspios_full_arm64/ -
[DIR] raspios_full_armhf/ -
[DIR] raspios_lite_arm64/ -
[DIR] raspios_lite_armhf/

转换 img 到 qcow2

Convert img to qcow2

qemu-img convert -f raw 2024-03-15-raspios-bookworm-armhf-lite.img -O qcow2 raspios-bookworm-armhf-lite.qcow2

扩容到128G

Expand the capacity of qcow2 to 128 GB

qemu-img resize disk.qcow2 +128G

使用qemu-nbd挂载qcow2,修改里面的一些文件

Mount qcow2 using qemu-nbd and modify some files

sudo modprobe nbd
sudo qemu-nbd --connect /dev/nbd1 raspios-bookworm-armhf-lite.qcow2
sudo mount /dev/nbd1p2 /mnt

把fstab改成这个

Change fstab

proc            /proc           proc    defaults          0       0
LABEL=rootfs	/               ext4    defaults,noatime  0       1

然后自己生成一个用户加到passwd和shadow不然等下启动会没法登录到系统,我本机有个用户叫 r00t,我就直接复制过来了,一样的密码。根据自己的情况变换,也可以给shadow中的root生成一个密码

Then generate a user and add it to passwd and shadow, otherwise it will not be able to log in to the system after the startup. There is a user named r00t on my machine, so I directly copy it over with the same password. Depending on your situation, you can also generate a password for root in shadow

sudo sh -c "sudo cat /etc/passwd | grep r00t >> /mnt/etc/passwd"
sudo sh -c "sudo cat /etc/shadow | grep r00t >> /mnt/etc/shadow"

然后把用户加入 sudoers,不然启动之后没法使用 sudo

Then add the user to sudoers, otherwise you won't be able to use sudo once started

修改完了之后取消挂载

After the modification is complete, cancel the mount

sudo umount /mnt
sudo qemu-nbd --disconnect /dev/nbd1

启动试试,这里我用的 https://people.debian.org/~gio/dqib/ 的 armhf-virt 的 kernel 和 initrd

Start a try, here I am using https://people.debian.org/~gio/dqib/ armhf - virt kernel and initrd

qemu-system-arm -machine 'virt' -cpu 'cortex-a15' -m 1G -device virtio-blk-device,drive=hd -drive file=2024-03-15-raspios-bookworm-armhf-lite.qcow2,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -kernel kernel -initrd initrd -nographic -append "root=LABEL=rootfs console=ttyAMA0"

因为img镜像直接转换成qcow2相当与使用dd克隆了分区,我们扩展的空间没被使用,可以在启动之后可以用 raspi-config 去扩容根文件系统

Since converting the img image directly to qcow2 is equivalent to cloning the partition using dd, our extended space is not used, and you can use pfi-config to expand the root file system after booting

sudo raspi-config

image

image

标签:树莓,img,qcow2,sudo,raspios,armhf,qemu,运行
From: https://www.cnblogs.com/scriptk1d/p/18093352/qemu-running-raspberry-pi-system-1iuehp

相关文章

  • 实验一 熟悉C语言运行环境
    c语言程序设计——实验报告一实验项目名称:实验一熟悉C语言运行环境实验项目类型:验证性实验日期:2023年3月14日一、实验目的下载安装Devc6.0程序。了解在该系统上如何进行编辑、编译、连接和运行一个C程序。|通过运行简单的C程序了解C程序的特点。二、实验硬、软件环境......
  • macbook(M1芯片)搭建php+nginx运行环境
    macbook(M1芯片)搭建php+nginx运行环境php安装phpbrewinstallphp//低版本php需要这样安装brewinstallshivammathur/php/[email protected]配置环境变量(低版本的php才需要)echo'exportPATH="/usr/local/opt/[email protected]/bin:$PATH"'>>~/.zshrcecho'exportPATH=&quo......
  • 【保姆级教程】YOLOv8_Track多目标跟踪,快速运行
    一、YOLOV8环境准备1.1下载安装最新的YOLOv8代码仓库地址:https://github.com/ultralytics/ultralytics1.2配置环境pipinstall-rrequirements.txt-ihttps://pypi.tuna.tsinghua.edu.cn/simple二、下载测试视频,预训练权重测试视频链接:https://pan.baidu.c......
  • 【AI】发现一款运行成本较低的SelfHosting语言模型
    【背景】作为一个想构建局域网AI服务的屌丝,一直苦恼的自然是有限的资源下有没有对Spec要求低一点的SelfHosting的AI服务框架了。今天给大家介绍这款听起来有点希望,但是我也还没试验过,感兴趣的可以去尝试看看。【介绍】大模型生成式AI与别的技术不同,由于资源要求高,玩儿起......
  • 运行单机模式Nacos
    可以使用2种方式运行单机模式的Nacos服务:编译后的压缩包,从源码启动。如下示例基于MySQL数据库。基于编译后的压缩包启动Nacos服务下载最新的nacos-server-2.2.3稳定版并解压:$unzipnacos-server-$version.zip或者tar-xvfnacos-server-$version.tar.gz$cdnacos#解压......
  • 智能停车场管理系统设计与实现|jsp+ Mysql+Java+ B/S结构(可运行源码+数据库+设计文档
    本项目包含可运行源码+数据库+LW,文末可获取本项目的所有资料。推荐阅读100套最新项目最新ssm+java项目文档+视频演示+可运行源码分享最新jsp+java项目文档+视频演示+可运行源码分享最新SpringBoot项目文档+视频演示+可运行源码分享2024年56套包含java,ssm,springboot的平台......
  • 医院预约挂号系统设计与实现|jsp+ Mysql+Java+ Tomcat(可运行源码+数据库+设计文档)
    本项目包含可运行源码+数据库+LW,文末可获取本项目的所有资料。推荐阅读100套最新项目最新ssm+java项目文档+视频演示+可运行源码分享最新jsp+java项目文档+视频演示+可运行源码分享最新SpringBoot项目文档+视频演示+可运行源码分享2024年56套包含java,ssm,springboot的平台......
  • 智能停车场管理系统设计与实现|jsp+ Mysql+Java+ B/S结构(可运行源码+数据库+设计文档
    本项目包含可运行源码+数据库+LW,文末可获取本项目的所有资料。推荐阅读100套最新项目最新ssm+java项目文档+视频演示+可运行源码分享最新jsp+java项目文档+视频演示+可运行源码分享最新SpringBoot项目文档+视频演示+可运行源码分享2024年56套包含java,ssm,springboot的平台......
  • 沙县小吃点餐系统|基于JSP技术+ Mysql+Java的沙县小吃点餐系统设计与实现(可运行源码+
    推荐阅读100套最新项目最新ssm+java项目文档+视频演示+可运行源码分享最新jsp+java项目文档+视频演示+可运行源码分享最新SpringBoot项目文档+视频演示+可运行源码分享2024年56套包含java,ssm,springboot的平台设计与实现项目系统开发资源(可运行源代码+设计文档)目录1.前......
  • 在Linux中,如何查看系统上运行的进程?
    在Linux中查看系统上运行的进程有多种命令和工具可用,以下是一些常见的方法:1.ps命令查看当前终端下运行的进程:ps显示所有进程:ps-e显示所有进程的完整信息(包括父进程ID、启动时间、CPU和内存使用等):ps-ef显示所有进程并按照用户和CPU使用排序:ps-aux2.t......