DEV Community

Hollow Man
Hollow Man

Posted on

Install VirtualBox Guest Additions for openEuler 20.03 SP1

This article mainly discusses encountered issues and solutions when I installed VirtualBox Guest Additions for OpenEuler 20.03 SP1.

  1. After installing openEuler 20.03 SP1, log in to openEuler (I login as root here, if you are a regular user, you may need to use sudo when executing commands below), and then click Device -> Insert Guest Additions CD image... to load the latest version of the Guest Additions CD into the system.

  2. Mount the CD:

mkdir -p /run/media/openeuler/VBoxAdditions
mount /dev/sr0 /run/media/openeuler/VBoxAdditions
cd /run/media/openeuler/VBoxAdditions
Enter fullscreen mode Exit fullscreen mode

  1. If you choose to install directly as usual, it may prompt an error for extraction because the system lacks the tar extraction program in the case of minimal installation. So install it:
dnf update
dnf install tar
Enter fullscreen mode Exit fullscreen mode

  1. Run the installation:
./VBoxLinuxAdditions.run
Enter fullscreen mode Exit fullscreen mode

You can see there exists an error. Let's take a look at the details of the error:

cat /var/log/vboxadd-setup.log
Enter fullscreen mode Exit fullscreen mode

It can be seen that it is a compilation error. According to Linux kernel documentation, the access_ok function has been changed from passing three parameters to passing two parameters after the Linux kernel version 5. VBoxAdditions judges whether to use three or two parameters by the Linux version number. However, the kernel version number used by openEuler 20.03 SP1 is 4, but the patches later than the Linux kernel version 5 for this have been applied. As a result, the access_ok function only needs two parameters in this case, so we only need to change the VBoxAdditions source code to let it call access_ok with two parameters.

  1. Modify the source code of VBoxAdditions (note that the corresponding path is changed according to the version number of VBoxAdditions):
cd /opt/VBoxGuestAdditions-6.1.22/src/vboxguest-6.1.22/vboxguest/r0drv/linux
vi memuserkernel-r0drv-linux.c
Enter fullscreen mode Exit fullscreen mode

Use i to edit, and change the following two places RTLNX_VER_MIN(5,0,0) to RTLNX_VER_MIN(4,0,0):

Then press the ESC key, :wq save and exit.

There is also a same issue in another file, so continue to execute the command:

cd ../../../vboxsf
vi regops.c
Enter fullscreen mode Exit fullscreen mode


Then press the ESC key, :wq save and exit.

  1. Finally continue the installation:
/sbin/rcvboxadd setup
Enter fullscreen mode Exit fullscreen mode

Installation is complete!

Finally, the VirtualBox Guest Addition can be used after restarting the system!

Top comments (0)