yum install stratovirt
stratovirt -version
安装2.1.0版本的stratovirt
yum install make gcc bison flex openssl-devel elfutils-devel -y #编译工具
yum install kernel-source -y #内核源码
配置并编译Linux kernel,将指定版本的推荐文件复制到kernel路径下并重命名为.config, 并执行命令make olddefconfig更新到最新的默认配置。
配置文件5.10_x86:https://gitee.com/openeuler/openeuler-os-build/tree/master/script/config/microvm_image
https://gitee.com/openeuler/openeuler-os-build/blob/master/script/step/make_microvm_image.sh
dnf -y --installroot=${rootfs_dir} --noplugins install systemd yum iproute iputils
size=`du -sh --block-size=1MiB ${rootfs_dir} | cut -f 1 | xargs`
size=$(($size+500))
img_file=${workdir}/img
dd if=/dev/zero of=${img_file} bs=1MiB count=$size && sync
mkfs.ext4 ${img_file}
root_mnt=${workdir}/rootmnt
mkdir -p ${root_mnt}
mount $img_file $root_mnt
tmp_dir=${workdir}/tmp
if [ ! -d ${tmp_dir} ]; then
mkdir -p ${tmp_dir}
else
rm -rf ${tmp_dir}/*
fi
if [ -f ${tmp_dir}/rootfs.tar ]; then
rm ${tmp_dir}/rootfs.tar
fi
pushd ${rootfs_dir}
tar cpf ${tmp_dir}/rootfs.tar .
popd
pushd ${root_mnt}
tar xpf ${tmp_dir}/rootfs.tar -C .
popd
sync
sleep 10
umount ${root_mnt}
/usr/bin/stratovirt \
-machine microvm \
-kernel /usr/src/linux${kernel_src_version}/vmlinux.bin \
-append "console=ttyS0 root=/dev/vda reboot=k panic=1" \
-drive file=${workdir}/img,id=rootfs,readonly=off \
-device virtio-blk-device,drive=rootfs,id=rootfs \
-qmp unix:/tmp/stratovirt.socket,server,nowait \
-serial stdio
[root@StratoVirt ~]# systemd-analyze
Startup finished in 657ms (kernel) + 2.241s (userspace) = 2.898s
graphical.target reached after 2.217s in userspace
[root@StratoVirt ~]# free -h
total used free shared buff/cache available
Mem: 228Mi 27Mi 179Mi 728Ki 21Mi 193Mi
Swap: 0B 0B 0B
[root@StratoVirt ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.1G 617M 375M 63% /
devtmpfs 112M 0 112M 0% /dev
tmpfs 115M 0 115M 0% /dev/shm
tmpfs 46M 728K 46M 2% /run
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
tmpfs 115M 0 115M 0% /tmp
Hi yangtzuho, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Virt, and any of the maintainers: @朱科潜 , @frankyj915 , @Bin Wu , @ZhiGang , @alexchen , @Chuan , @imxcc , @ZhangBo , @yezengruan , @limingwang , @sujerry , @李华超
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
此issue建议分类到X86架构下
登录 后才可以发表评论