After you install Ubuntu inside VirtualBox its necessary to install guest additions in order to enable enhanced features like native screen resolution, seamless windows, shared clipboard, shared folders and few others.
Without it, you would probably have to work with a standard resolution like 1024x768 as the default virtual machine does not support every possible video resolution. These details have been explained on virtualbox website.
Install Guest Additions on Ubuntu 22.10
Installing guest additions inside ubuntu and many popular linux distros is actually quite easy and requires a few clicks and commands only. Make sure that Ubuntu is fully installed inside VirtualBox and that you can boot properly to the desktop. Once there, you can follow the next steps as shown below.
1. Update Ubuntu
As a first step its always better to upgrade all the packages on the system.
sudo apt-get update && sudo apt-get dist-upgrade
2. Install essential packages
Next you have to install important packages like linux headers and build files. These are needed in order to compile virtualbox guest additions for your particular linux system and ubuntu version.
On Linux guest additions are always compiled from source for proper compatibility.
sudo apt-get install build-essential module-assistant dkms linux-headers-generic
The above command will install linux headers for your current kernel which is needed to compile and build virtualbox source code. Some distros like Fedora have guest addition package pre-installed.
You do not have to compile or install guest additions on such distros. All features would be available and work fine out of the box, provided that the version of virtualbox is compatible with the guest additions in that distro. Its always best to install the virtualbox provided guest additions for maximum compatiblity.
3. Compile Guest Additions
On the Virtual Machine window click the menu option on the top:
Click Devices > Insert Guest Additions CD Image
Now open any file browser like Nautilus (Gnome) or Dolphin (KDE) and navigate to the mounted disk and note the full path. For instance on my system the path is:
Now open a terminal and switch to that folder:
View the files with the ls -la command
[email protected]:/media/silver/VBox_GAs_6.1.38$ ls -la total 49580 dr-xr-xr-x 5 silver silver 2570 Sep 1 19:53 . drwxr-x---+ 3 root root 4096 Jan 5 18:31 .. -r--r--r-- 1 silver silver 763 Feb 20 2020 AUTORUN.INF -r-xr-xr-x 1 silver silver 6384 Sep 1 19:13 autorun.sh dr-xr-xr-x 2 silver silver 968 Sep 1 19:53 cert dr-xr-xr-x 2 silver silver 1824 Sep 1 19:53 NT3x dr-xr-xr-x 2 silver silver 2652 Sep 1 19:53 OS2 -r-xr-xr-x 1 silver silver 4821 Sep 1 19:13 runasroot.sh -r--r--r-- 1 silver silver 592 Sep 1 19:53 TRANS.TBL -r--r--r-- 1 silver silver 4114801 Sep 1 19:16 VBoxDarwinAdditions.pkg -r-xr-xr-x 1 silver silver 3949 Sep 1 19:12 VBoxDarwinAdditionsUninstall.tool -r-xr-xr-x 1 silver silver 7566772 Sep 1 19:13 VBoxLinuxAdditions.run -r--r--r-- 1 silver silver 9559552 Sep 1 19:10 VBoxSolarisAdditions.pkg -r-xr-xr-x 1 silver silver 18283432 Sep 1 19:53 VBoxWindowsAdditions-amd64.exe -r-xr-xr-x 1 silver silver 272736 Sep 1 19:15 VBoxWindowsAdditions.exe -r-xr-xr-x 1 silver silver 10940328 Sep 1 19:32 VBoxWindowsAdditions-x86.exe -r--r--r-- 1 silver silver 259 Oct 4 2021 windows11-bypass.reg [email protected]:/media/silver/VBox_GAs_6.1.38$
There are lots of installation files for various systems like Windows, Solaris and Linux. The linux specific installer is
Now start the compilation process by running the script with root privileges. You need to run it with root privileges because it shall install guest addition driver as kernel modules on the system.
[email protected]:/media/silver/VBox_GAs_6.1.38$ sudo ./VBoxLinuxAdditions.run [sudo] password for silver: Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.38 Guest Additions for Linux........ VirtualBox Guest Additions installer Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 5.19.0-26-generic. update-initramfs: Generating /boot/initrd.img-5.19.0-26-generic VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted [email protected]:/media/silver/VBox_GAs_6.1.38$
Finally restart the guest OS.
Now you should be able to get native resolution easily.
To make sure that the guest additions are installed, you can run the following commands. The lsmod command lists all modules and the modinfo command shows details about a given module.
[email protected]:~$ lsmod | grep -io vboxguest vboxguest
[email protected]:~$ modinfo vboxguest filename: /lib/modules/5.19.0-26-generic/misc/vboxguest.ko version: 6.1.38 r153438 license: GPL description: Oracle VM VirtualBox Guest Additions for Linux Module author: Oracle Corporation srcversion: FA5DE49C7F2CB39107D8436 alias: pci:v000080EEd0000CAFEsv00000000sd00000000bc*sc*i* depends: retpoline: Y name: vboxguest vermagic: 5.19.0-26-generic SMP preempt mod_unload modversions [email protected]:~$
Now you can enable shared clipboard and "Drag and Drop" functionality from the top menu.
1. Click Devices > Shared Clipboard > Bidirectional
2. Click Devices > Drag and Drop > Bidirectional