(转载)在Fedora 28/27, CentOS/RHEL 7.5/6.9/5.11上安装配置VirtualBox Guest Additions

1. Change root user


su -
## OR ##
sudo -i

2. Make sure that you are running latest kernel

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


3. Mount VirtualBox Guest Additions

Click Devices > Install Guest Additions… on VirtualBox


Mount VirtualBox Guest Additions device


mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions

4. Install following packages

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

5. Add KERN_DIR environment variable


## 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

6. Install Guest Additions


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.

7. Reboot guest system


reboot

Then VirtualBox Guest Additions install is ready.


出现的问题:


运行.run文件会出现modprobe  vboxguest  failed错误。这是因为内核的版本不一致。

运行rpm -qa | grep kernel | sort 检查内核版本
如果kernel 和kernel-devel版本不一直。运行yum -y upgrade kernel kernel-devel 
重启再次运行.run文件应该就可以了


下面说说如何分配数据空间:
1.为virtualbox分配数据空间,[设备][分配数据空间]


共享D盘share文件夹


2.在虚拟机里的Linux系统建一个共享文件夹
su
mkdir /home/share

3
确保加载vboxsf模块,使用modprobe vboxsf(需要超级用户权限)加载
su 
modprobe vboxsf

4.共享文件夹

su
mount -t   vboxsf share   /home/share/    #share 数据空间名称,如下图


如果出现下列错误:/sbin/mount.vboxsf:mounting failed with the error:protocol error
原因是因为你windows中共享的文件夹名字share和挂载点/home/share名字一样。所以还是改下windows下共享的文件夹名字。然后再用mount -t vboxsf 共享文件夹名 /home/share

如果要卸载 sudo umount -f /home/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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值