su -
## OR ##
sudo -i
Update virtual machine kernel and reboot
## Fedora 28/27/26/25/24/23/22 ##
dnf update kernel*
## Fedora 21/20/19/18/17, CentOS/RHEL 7/6/5 ##
yum update kernel*
reboot
Click Devices > Install Guest Additions… on VirtualBox
Mount VirtualBox Guest Additions device
mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions
On CentOS/Red Hat (RHEL) 7/6/5, EPEL repo is needed
## CentOS 7 and Red Hat (RHEL) 7 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
## CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
Install following packages
## Fedora 28/27/26/25/24/23/22 ##
dnf install gcc kernel-devel kernel-headers dkms make bzip2 perl
## Fedora 21/20/19/18/17, CentOS/RHEL 7/6/5 ##
yum install gcc kernel-devel kernel-headers dkms make bzip2 perl
## Current running kernel on Fedora 28/27/26/25/24/23/22, CentOS 7/6 and Red Hat (RHEL) 7/6 ##
KERN_DIR=/usr/src/kernels/`uname -r`/build
## Current running kernel on CentOS 5 and Red Hat (RHEL) 5 ##
KERN_DIR=/usr/src/kernels/`uname -r`-`uname -m`/build
## Fedora example ##
KERN_DIR=/usr/src/kernels/4.15.6-300.fc27.x86_64/build
## CentOS and Red Hat (RHEL) example ##
KERN_DIR=/usr/src/kernels/3.10.0-693.17.1.el7-x86_64/build
## Export KERN_DIR ##
export KERN_DIR
cd /media/VirtualBoxGuestAdditions
# 32-bit and 64-bit systems run following
./VBoxLinuxAdditions.run
Output looks like following:
[root@fedora VBoxGuestAdditions]# ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 5.2.8 Guest Additions for Linux........ VirtualBox Guest Additions installer Removing installed version 5.2.6 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted VirtualBox Guest Additions: Starting.
reboot
Then VirtualBox Guest Additions install is ready.
出现的问题:
运行.run文件会出现modprobe vboxguest failed错误。这是因为内核的版本不一致。
共享D盘share文件夹
2.在虚拟机里的Linux系统建一个共享文件夹
su
mkdir /home/share
3确保加载vboxsf模块,使用modprobe vboxsf(需要超级用户权限)加载
su
modprobe vboxsf
4.共享文件夹
su
mount -t vboxsf share /home/share/ #share 数据空间名称,如下图
转自:https://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/
以及https://blog.csdn.net/lazyclough/article/details/6121533