CentOS 8 无GUI安装virtualbox6.1及OVA镜像延迟启动

编程入门 行业动态 更新时间:2024-10-07 22:19:28

CentOS 8 无GUI安装virtualbox6.1及OVA<a href=https://www.elefans.com/category/jswz/34/1770431.html style=镜像延迟启动"/>

CentOS 8 无GUI安装virtualbox6.1及OVA镜像延迟启动

Centos 8.4 安装VitrualBox并导入OVA(无GUI)(精简文字版)

#进入管理目录

cd /etc/yum.repos.d/

#删除现有的源配置文件

rm *.repo

#下载阿里的源配置文件

wget .5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo

#修改配置文件

sed -i 's/mirrors.cloud.aliyuncs/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun/mirrors.cloud.aliyuncs/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo

#下载VitrualBox.repo文件

wget .repo

mv virtualbox.repo /etc/yum.repos.d/

#更新源

dnf clean all

dnf makecache

#查看现有virtualbox版本

dnf search virtualbox

Last metadata expiration check: 0:00:20 ago on Thu 16 Sep 2021 08:29:35 PM CST. ================================================== Name & Summary Matched: virtualbox = VirtualBox-5.2.x86_64 : Oracle VM VirtualBox VirtualBox-6.0.x86_64 : Oracle VM VirtualBox VirtualBox-6.1.x86_64 : Oracle VM VirtualBox

#安装最新版

dnf install VirtualBox-6.1.x86_64

#运行VirtualBox

VirtualBox

出现报错: WARNING: The vboxdrv kernel module is not loaded. Either there is no module ... ... sudo /sbin/vboxconfig You will not be able to start VMs until this problem is fixed.

#运行/sbin/vboxconfig检查依赖环境

/sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services. vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: Building VirtualBox kernel modules. This system is currently not set up to build kernel modules. Please install the gcc make perl packages from your distribution. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system. The distribution packages containing the headers are probably: kernel-devel kernel-devel-4.18.0-305.17.1.el8_4.x86_64 This system is currently not set up to build kernel modules. Please install the gcc make perl packages from your distribution. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system. The distribution packages containing the headers are probably: kernel-devel kernel-devel-4.18.0-305.17.1.el8_4.x86_64 There were problems setting up VirtualBox. To re-start the set-up process, run /sbin/vboxconfig as root. If your system is using EFI Secure Boot you may need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information.

【 提示缺少 gcc make perl,kernel-devel 】

#安装缺失组件(完成后需要重启服务器)

dnf install gcc make perl kernel-devel

【检查是否已有对应的内核】

#查看已安装内核版本

rpm -qa |grep kernel

#更新内核(反复head报错的情况,终极大招)

yum update kernel

#再次运行检查

/sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services. vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: Building VirtualBox kernel modules. vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong. There were problems setting up VirtualBox. To re-start the set-up process, run /sbin/vboxconfig as root. If your system is using EFI Secure Boot you may need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information.

还是运行失败,提示到/var/log/vbox-setup.log文件中查看失败原因

#查看日志

cat /var/log/vbox-setup.log

Building the main VirtualBox module. Error building the module: make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/4.18.0-305.17.1.el8_4.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j8 modules make[1]: warning: -jN forced in submake: disabling jobserver mode. Makefile:984: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop. make: *** [/tmp/vbox.0/Makefile-footer.gmk:117: vboxdrv] Error 2

提示需要install libelf-dev, libelf-devel or elfutils-libelf-devel 3个依赖中的一个,挨个尝试,只有最后一个可以安装

#安装缺失组件

[root@~]# dnf install elfutils-libelf-devel

#再次检查

[root@~]# /sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services. vboxdrv.sh: Starting VirtualBox services. vboxdrv.sh: Building VirtualBox kernel modules.

【如上结果,无其他信息,表示安装成功】

#导入OVA镜像:VBoxManage import 目录

VBoxManage import /home/win\ 2003.ova

[root@nbgims ~]# VBoxManage import /home/win\ 2003.ova 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Interpreting /home/win 2003.ova... OK. 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Successfully imported the appliance.

#VBoxManage list vms

//查看可用的虚拟机

VBoxManage list vms

"win 2003" {325011dd-e7ad-4c4a-a1ed-61f80a2f245e}

#后台启动虚拟机 命令:VBoxManage startvm name/ID --type headless

VBoxManage startvm "win 2003" --type headless

#查看运行状态

VBoxManage list runningvms

"win 2003" {325011dd-e7ad-4c4a-a1ed-61f80a2f245e}

#关闭虚拟机,关闭电源(慎用,小心系统丢失文件崩溃)

VBoxManage controlvm 'win 2003' poweroff

------------------------------------------------------------------------

CentOS 8 设置开机延迟自动启动虚拟机

#先确保rc.local可用

--查看rc.local状态

systemctl status rc-local

--如果状态是:(dead)

--设置为开机启动

systemctl enable rc-local

--文件赋权

chmod +x /etc/rc.d/rc.local

#创建启动对应虚拟机的脚本

--创建sh,延迟启动虚拟机

vim /usr/local/winstart.sh

#us to start VM - 'win 2003'

#延时30S sleep 30

#后台静默启动

VBoxManage startvm "win 2003" --type headless

--文件赋权

chmod +x winstart.sh

重启计算机,验证结果。

------------------------------------------------------------------------------------------------

以上为实战经验,分享给初步接触centos安装virtualbox追求最小化的朋友。

更多推荐

CentOS 8 无GUI安装virtualbox6.1及OVA镜像延迟启动

本文发布于:2024-03-13 14:56:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1734226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:镜像   GUI   CentOS   OVA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!