实习,启动!
记录OERV实习过程中Pretask实现流程。如有错误欢迎指正。
pcre2
先按提示注册好OBS. openEuler的OBS是openSUSE obs的分支,因此文档可以去看openSUSE的。https://openbuildservice.org/files/manuals/obs-user-guide.pdf
下载好obs以后需要先改配置文件
[root@localhost ~]# vim /root/.config/osc/oscrc
#默认是这样
···
apiurl=https://api.opensuse.org
[https://api.opensuse.org]
···
#替换为下面的
···
apiurl = https://build.tarsier-infra.isrc.ac.cn/
no_verify = 1
[https://build.tarsier-infra.isrc.ac.cn]
···
创建远程分支以及拉文件到本地,并对文件重命名的操作如下
osc branch openEuler:Mainline:RISC-V coreutils
osc co home:root:openEuler:Maniline:RISC-V coreutils
osc up -S
rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done
之后即可开始构建
osc build
关于QEMU User Mode Emulation :使用QEMU运行为另一种CPU编译的进程。相较于System Emulation, 仅虚拟CPU。
关于systemd-nspawn: 允许在namespace container中运行指令或OS。
首先可以将QEMU中文件系统提取到宿主机。关于如何挂载QEMU img
sudo modprobe nbd
sudo qemu-nbd --connect=/dev/nbd0 openEuler-25.03-V1-base-qemu-testing.qcow2
$ sudo fdisk -l /dev/nbd0
Disk /dev/nbd0: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 131072 bytes
Disklabel type: gpt
Disk identifier: 42062537-9FE0-49CF-B11A-FE04D17040B4
Device Start End Sectors Size Type
/dev/nbd0p1 2048 1050623 1048576 512M BIOS boot
/dev/nbd0p2 1050624 41943006 40892383 19.5G Linux filesystem
$ sudo mount /dev/nbd0p2 /mnt/
完事以后unmount and disconnect的指令放在这里,不过这里还没有用完,
umount /mnt
qemu-nbd --disconnect /dev/nbd0
rmmod nbd
本人目前没有太多关于虚拟化方面的经验。关于如何使用systemd-nspawn
以及qemu-user
来在容器中运行不同架构的程序参考了以下博客
systemd-nspawn
功能与chroot
类似,但其会顺带帮你完成一系列工作,如建立/proc
, /sys
等virtual file system. 同时,由于目标系统架构为RV64, 此处需要qemu-user-static
来对cpu进行虚拟。linux 提供了一套魔法来通过二进制文件的头部判断其架构并运行(详见binfmt-misc). 具体实现细节在上述参考连接中有详解,此处我们仅需安装qemu-user-static
软件包
dnf install qemu-user-static
之后即可通过systemd-nspawn
进入系统
systemd-nspawn -D /mnt
后续步骤与pretask2一致。