VirtualBox 7 Unattended Install (includes GPG conversion)

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
336
Reaction score
360
Credits
11,504
Oracle has recently released VirtualBox 7.0.2 on October 19, 2022. There are some differences, but one main difference is to note is the unattended installation of some Operating Systems.

The options existed before, but were available from the command line. In version 7, the unattended install is available in the Graphical User Interface (GUI). The unattended installation comes in quite handy for just answering a few questions and then you can do something else while the system installs the OS.

Once it completes the installation, there are a few things you need to do to complete the setup, but it is easier.

Downloading Version 7

The download is simple, just go to https://www.virtualbox.org/wiki/Linux_Downloads and download the file for your Linux distro.

Once you have started the download, go to https://www.virtualbox.org/wiki/Downloads and download the Extension Pack.

This is the easy way to do this, but for someone that wants to do it through the command line, especially if they want to make a script to do it on multiple systems, then we can do that too. This will get a little involved if you already have it installed. The keys that were added before will need to be exported in the newer way, since the deprecation of 'apt-key'.

NOTE: You read that correctly. The deprecation of the 'apt-key' and any keys you have need to be exported to the new method of 'gpg'.

Command Line Installation

So, let's look at the keys on your system. If you already have an older version of VirtualBox, then we need to get your keys taken care of, or you need new keys.

To check your keys, use the command 'sudo key-apt list'.

On a system that has not had VirtualBox installed, see something similar to Figure 1.

Figure01.JPG

FIGURE 1

What you want is to have all the keys in the folder '/etc/apt/trusted.gpg.d/'. You should see that there is one key for Docker-CE that is in the '/etc/apt/trusted.gpg'. Any keys you have in the 'trusted.gpg' folder needs to be moved. This is what we are going to cover. Currently, I do not have a VirtualBox key, but we'll move my Docker-CE key to show how it is done.

NOTE: You'll also see an error when you run 'sudo apt update' at the end of the output if you are using a key for contacting a repository.

To do this, you need the last 8 characters of the keyid, not counting the space, which is '0EBFCD88'. We also need to name the new GNUPrivacy Guard (gpg) file. I'll just call is 'dockerce' so it’s easy to recognize. The command then would be:

sudo apt-key export 0EBFCD88 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/dockerce.gpg

We use the deprecated 'apt-key' program to export the key. We take that information and pass it to the 'gpg' program. The '--dearmour' parameter causes the file to be converted to a binary format. It then sends the output to the folder '/etc/apt/trusted.gpg.d/' with a filename of 'dockerce.gpg'. If you issue the command 'sudo apt-key list', see a new key that we just exported, as shown in Figure 2.

Figure02.JPG

FIGURE 2

You may notice that there is still a warning about 'apt-key' being deprecated, so let's see what we can do about that.

The command still uses the last 8 characters of the keyid, but if you notice, there are two keys for Docker, and both have the same last 8 characters. If we delete one, we lose both. Notice the path for the 'gpg' key is '/etc/apt/trusted.gpg.d/dockerce.gpg'. With root privileges, go to the folder and copy the file 'dockerce.gpg' to a different folder.

From a terminal, issue the command 'sudo apt-key del 0EBFCD88'. If you issue a command to show the list again, then you see that the key in the 'trusted.gpg' for the deprecated 'apt-key' is now gone. It has also removed the file you copied out from the list. If you go back to the folder '/etc/apt/trusted.gpg.d/' you only need to copy the file back you copied out. When you issue another 'sudo apt-key list', the key should be back in the list. Just make sure you change the keyid and the key name when you do this as you need.

You should also notice that the '/etc/apt/trusted.gpg' file is also missing now. The system should remove the file when you have all the keys out of it.

If you issue the command 'sudo apt update', see that the error at the end is now gone.

If you did not have the VirtualBox keys already, we will add them the new way:

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/oracle_vbox_2016.gpg
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/oracle_vbox.gpg


After running these to add the keys, you can run 'sudo apt-key list' to verify they are present and in the correct place.

The following commands should complete the installation.

sudo apt install software-properties-common
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update


You should see a line for 'https://download.virtualbox.org/virtualbox/debian jammy InRelease' that has a package list retrieved from it. Since the repository is being used, we know the key is working, and it added the repository correctly. Now all we need is to get the packages we need to install the newest version of VirtualBox. To see the versions available, run the command 'sudo apt list --all-versions virtualbox-7.0'. The result shows there is a single version with the version of '7.0.2-154219~Ubuntu~jammy amd64'. The version may be different, but eventually, the command may need to be '7.1' or later. If you type in 'virtualbox' and hit <TAB> it should autofill or double click <TAB> to get a list. Choose the latest version to get information on the version available.

To get VirtualBox installed, use the same package name you used to get the version listing and install it using the command:

sudo apt install virtualbox-7.0 -y

Once quick thing to do is add your user account to the 'vboxusers' group or you will have issues enumerating the USB drives. Use the command:

sudo usermod -aG vboxusers $USER

You should restart the system to make sure the changes take effect. Use the command 'groups' to get the groups that the current user is in, or 'groups <username>' to see what groups a specific user is in.

Once done, you should have the newest version of VirtualBox and the program is nearly ready.

It is best to install the 'Extension Pack'. You can download the 'Extension Pack' with the command:

wget https://download.virtualbox.org/vir..._VirtualBox_Extension_Pack-7.0.0.vbox-extpack

After it completes, open VirtualBox and select 'File' from the top menu. Arrow down to 'Tools' and then over to 'Extension Pack Manager'. Once the window opens, select the 'Install' icon and the go to where you downloaded the pack. Click on the pack and click on 'Open' at the top right of the window. It should present you with another screen to let you select 'Install' to get it into the VirtualBox application. Scroll down to the bottom of the User Agreement. Click on 'Agree', then type in your password for elevated privileges to install the pack. Select 'Authenticate' and you should see the pack appear on the list. Click on the list icon to the right of 'Tools' and select 'Home' to get back to the main screen.

Now, we need to set up an unattended installation.

Unattended Installation

In this example, I'll just use Ubuntu 22.04. Other distros should be similar, you may have to change the commands from Ubuntu to match your distro. Make sure you have downloaded the ISO of the Operating System you want to install on VirtualBox.

If you are starting from the beginning on a system where VirtualBox has not run, you’ll see a window similar to Figure 3.

Figure03.jpg

FIGURE 3

Otherwise, if you have been using VirtualBox before and made any machines, they will remain in the left pane.

Click on New and you should have a window similar to Figure 4.

Figure04.jpg

FIGURE 4

Type in a name for the Virtual Machine. Click on the far right box after 'ISO Image'. Click on 'Other' and, in the new window, locate the ISO file you previously downloaded or want to use for the OS. There is a box to check if you want to skip the Unattended Installation. Leave it unchecked and click on 'Next'.

If you check the box to skip the Unattended Installation, then the setup will continue the same as the previous versions of VirtualBox. Things will look a little different, but it is still nearly exactly the same.

In Figure 5, you can see the next screen. Here, you set a username for an account to create as well as the password. You will also need to specify a Host name and Domain Name for the machine. You can also check the box to auto install the 'Extension Pack'. Do not change the path of the Extension Pack, it is set to an ISO file and the 'vbox-extpack' file you downloaded. Click 'Next'.

Figure05.jpg

FIGURE 5

The next window will let you specify the RAM to allocate to the machine, the number of processors to use and you can check the box if the OS is EFI. It showed the window in Figure 6. Click 'Next' after you have made your choices.

Figure06.jpg

FIGURE 6

The next window, Figure 7, allows you to specify whether it will set a hard disk up. You can set the size or specify an existing drive. You can even use no drive. Click 'Next'.

Figure07.jpg

FIGURE 7


The next screen summarizes the choices. Once you click Finish, it saves the machine, and will then start back up and perform all the tasks.

By default, it dynamically allocates the drive, it uses a NAT network adapter, it sets the minimum amount of Video RAM. Once the install is done, you can go into the settings and change some of these options. It is also important to note that the ROOT user will have the same password that you specify for the user to account for it to create.

Let the installation go through its paces and it seems to go quicker than an attended install.

After Installation Configuration

Once the machine restarts, log in as the user you created. Open a terminal and run 'su root' and use the same password for your user account. Now that you are root, you can run 'sudo usermod -aG sudo <user>'. Replace '<user>' with the your username for your account. The command should add your user account to the sudo group so you are in the 'sudoers' list.

Shutdown the VirtualBox Machine. Open 'Settings' for the machine and make your changes:

  • Remove the Floppy drive
  • Change your Network Adapter, or add Adapters
  • Change the Video Memory to 128
  • make other necessary changes you see fit to modify
Start the machine after it completes your changes. Once the system starts, log back in to your user account. Open terminal and perform 'sudo apt update && sudo apt upgrade -y'. The commands should work fine since you should have 'sudo' ability.

Conclusion

VirtualBox 7 is a major upgrade that looks and operates very nicely.

Get a little practice on changing the 'apt-key' to 'gpg' keys. This is important, since the 'apt-key' is being deprecated.

The Unattended Installation method allows for a slick use of a GUI to perform it. Just keep in mind the changes to make after it complete the installation. These are necessary for setting up an administrative account that is not automatic at this point.
 

Members online


Top