How to Install Guest Additions via command line for Windows and Linux VM’s.

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Banner
Posts: 6
Joined: 20. Nov 2021, 04:48

How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by Banner »

Installing Guest Additions online via command line for Windows and Linux VM’s.

I was unable to install Guest Additions for either my Windows 10 or my Linux VM, via “Devices/Insert Guest Additions CD Image...”.*

However, I was able to install Guest Additions for both VM's, from online sources, via command line.

I describe how, in case this is useful to anyone (I suspect that fewer people know how to do this for a Windows VM, than for a Linux VM).

LINUX

For Linux, the command is:

Code: Select all

sudo apt-get install virtualbox-guest-additions-iso
WINDOWS

For Windows, open Powershell as administrator (I use version 7, but suspect this will work for other versions).

"Chocolatey" is the Windows equivalent of "apt-get".

If you don't have it installed, you'll need to install it.

Before installing Chocolatey, you may wish to check your execution policy.

My execution policy is "RemoteSigned".
If yours is "Restricted", you'll need to change it.

To see your execution policy:

Code: Select all

Get-ExecutionPolicy
To change it,

Code: Select all

Set-ExecutionPolicy AllSigned
or

Code: Select all

Set-ExecutionPolicy RemoteSigned
You may then install Chocolatey with:

Code: Select all

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Once Chocolatey is installed, you may then download and install Guest Additions:

Code: Select all

choco install virtualbox-guest-additions-guest.install
Good Luck


*I intend to make posts regarding those issues.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by scottgus1 »

Re command-line install of Guest Additions in Windows, the manual https://www.virtualbox.org/manual/ch04. ... dd-install section 4.2.1.3 says:
  1. Log in as Administrator on the guest.
  2. Mount the Oracle VM VirtualBox Guest Additions .ISO.
  3. Open a command line window on the guest and change to the cert folder on the Oracle VM VirtualBox Guest Additions CD.
  4. Run the following command:

    VBoxCertUtil.exe add-trusted-publisher vbox*.cer --root vbox*.cer

    This command installs the certificates to the certificate store. When installing the same certificate more than once, an appropriate error will be displayed.
  5. To allow for completely unattended guest installations, you can specify a command line parameter to the install launcher:

    VBoxWindowsAdditions.exe /S
Banner
Posts: 6
Joined: 20. Nov 2021, 04:48

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by Banner »

scottgus1 wrote:Re command-line install of Guest Additions in Windows, the manual https://www.virtualbox.org/manual/ch04. ... dd-install section 4.2.1.3 says:
  1. Log in as Administrator on the guest.
  2. Mount the Oracle VM VirtualBox Guest Additions .ISO.
  3. Open a command line window on the guest and change to the cert folder on the Oracle VM VirtualBox Guest Additions CD.
  4. Run the following command:

    VBoxCertUtil.exe add-trusted-publisher vbox*.cer --root vbox*.cer

    This command installs the certificates to the certificate store. When installing the same certificate more than once, an appropriate error will be displayed.
  5. To allow for completely unattended guest installations, you can specify a command line parameter to the install launcher:

    VBoxWindowsAdditions.exe /S
Ah, thanks.

The approach I gave is more convenient, if (or once) Chocolatey is installed.

However, the approach from the manual has the minor advantage that you don't need Chocolatey**, and the major advantage that it does not require an online connection.

** Though it seems good to have Chocolatey installed, regardless of this issue.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by fth0 »

Regarding Linux guests, your suggestion installs the distribution-specific Guest Additions, not the Oracle-provided ones. In consequence, you'll often get a version mismatch, which is not recommended ...
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by scottgus1 »

FWIW I tried the manual's method and fond that it worked on XP and 7 VMs. XP still had the pop-ups requesting authorization for the unsigned GAs drivers for mouse and video. 7 was completely silent.

The "VBoxWindowsAdditions.exe /S" command finished immediately in the command window, though the actual install was still running. So a batch-file install would have to monitor the task list to see that all Virtualbox-based processes in the list were done before the batch file could continue.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by scottgus1 »

One other thing, for Linux VMs, there are prerequisites for Guest Additions, same as for installing Virtualbox on a Linux host: https://www.virtualbox.org/manual/ch02. ... nux-prereq. Very often, in modern Linux, it centers around the kernel headers.
operation420.net
Posts: 62
Joined: 28. May 2020, 02:17
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: The hood
Contact:

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by operation420.net »

Is it possible to install the guest additions from yum repository? I am trying to install the GA in this one VM and it's being picky. I've installed many times using the ISO image, going to try and debug further in the meantime, but if installing from the repo is a better way (at least on this VM) it would be good to know...
viewtopic.php?t=8208
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by scottgus1 »

operation420.net wrote:Is it possible to install the guest additions from yum repository?
If that's http://www.virtualbox.org 's yum repository, then it'd probably be OK, as it's probably going to be the same executable as on the iso.

This question might be more answerable by the Linux gurus on the Linux Guests forum.
operation420.net
Posts: 62
Joined: 28. May 2020, 02:17
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows
Location: The hood
Contact:

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by operation420.net »

Where can I find the URLs of the repos of the yum repo?

PS because you put 's at the end of your link it added %27 to the end of the URL, causing it to be a dead link...

Wow that reply was fast, thanks for the fast reply.

EDIT: https://www.virtualbox.org/ticket/4953
Provides dead link http://download.virtualbox.org/yum.repo.rpm

EDIT2: viewtopic.php?f=3&t=106546
There was a "humourous" video I was sent as a teenager called "Posting and You" that says it's usually best post in an existing thread if relevant than create a new one. But if you take that too far, you might end up hi-jacking other user's threads...
viewtopic.php?t=8208
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to Install Guest Additions via command line for Windows and Linux VM’s.

Post by scottgus1 »

Link fixed, thanks!
Post Reply