Tag: VirtualBox

VirtualBox Error “NS_ERROR_FAILURE (0x80004005)” (SOLVED)

After updating VirtualBox, all virtual machines stopped working, regardless of the guest operating system and their settings.

The situation is complicated by the fact that instead of an exact indication of the problem, when trying to start the virtual machine, only a general message is displayed that the session was terminated, as well as an error number, which is common to a number of errors related to the inability to start the virtual machine session.

Full text of the error:

The VM session was aborted.

Result Code: 
NS_ERROR_FAILURE (0x80004005)
Component: 
SessionMachine
Interface: 
ISession {c0447716-ff5a-4795-b57a-ecd5fffa18a4}

One possible reason is a mismatch between the versions of the VirtualBox Extension Pack and the installed version of VirtualBox.

VirtualBox Extension Pack is an extension that adds features such as support for USB 2.0 and USB 3.0 devices, VirtualBox RDP, disk encryption, NVMe and PXE boot for Intel cards.

To make sure that the reason is in the VirtualBox Extension Pack, you can disable the functions that the extension pack provides in the virtual machine settings (for example, rollback to USB 1.1 version) – after that the virtual machine should work without errors. Or go straight to updating the extension pack, which will solve the indicated problem.

To fix this problem, just install the version of the VirtualBox Extension Pack that matches the version of your VirtualBox.

If you installed the extension pack manually, then go to the VirtualBox download page https://www.virtualbox.org/wiki/Downloads and find the VirtualBox Oracle VM VirtualBox Extension Pack there.

Download and run the file by double clicking.

During the installation of the new version, you will be prompted to uninstall the old version.

The Linux repositories also contain the VirtualBox Extension Pack.

On Debian and derivative distributions (Linux Mint, Ubuntu, Kali Linux and others), to install the VirtualBox Extension Pack from the repository, run:

sudo apt install virtualbox-ext-pack

On Arch Linux and derivative distributions (Manjaro, BlackArch and others), to install the VirtualBox Extension Pack from the repository, run:

pikaur -S virtualbox-ext-oracle

If you get a message that the pikaur command was not found, then see the article “Automatic installation and update of AUR packages”.

If you receive an error that the VirtualBox Extension Pack is already installed, for example:

VBoxManage: error: Extension pack 'Oracle VM VirtualBox Extension Pack' is already installed. In case of a reinstallation, please uninstall it first

Then you need to start by removing it manually. To do this, open VirtualBox, go to the menu File → Preferences → Extensions.

Uninstall VirtualBox Extension Pack.

After that, restart the installation of the VirtualBox Extension Pack from the repository.

After updating the VirtualBox Extension Pack, the “NS_ERROR_FAILURE (0x80004005)” error is gone.

How to make VirtualBox virtual machines destroy on computer restart

How to use VirtualBox on Linux so that virtual machines and their settings are not saved

The desire to completely destroy virtual machines is extraordinary and may be related to security and privacy. However, there are at least two ways to achieve the desired effect: the virtual machines will be destroyed as soon as the computer is turned off.

1. Using VirtualBox on a Live System

If you need VirtualBox without saving settings, then you can work in a Live system.

Boot into Live mode, run the command to install VirtualBox:

sudo apt install virtualbox virtualbox-ext-pack

After the command completes, you can start VirtualBox, create virtual machines in it and work in them.

On the next reboot, all changes made will be lost.

To get VirtualBox again, repeat the previous steps exactly.

2. Saving virtual machines in the /tmp directory

The second method involves using a regular Linux installation or Persistence.

If you are working with a Live system, select “Live USB Persistence” or “Live USB Encrypted Persistence” when booting.

Install VirtualBox:

sudo apt install virtualbox virtualbox-ext-pack

Then open VirtualBox and go to menu File → Preferences → General.

Set “Default Machine Folder” to /tmp

As a result, all virtual machines will store their settings in the /tmp directory.

On each reboot, the /tmp directory is automatically cleared.

As a result, after the reboot, the VirtualBox executable files will remain in the system, but all virtual machines will be deleted.

If you are running a Live system, you will also need to select “Live USB Persistence” or “Live USB Encrypted Persistence” on subsequent reboots.

How to boot into VirtualBox from USB

In this post I will tell you how to connect a USB disk (or USB flash drive) to a virtual machine so that the guest system treats it like a regular hard disk.

This trick will allow you not only to boot from the installation USB – which is rather pointless. If you connect a USB disk or flash drive to the guest system as a regular disk, you can do such interesting things as:

  • boot from physical SATA disk via USB adapter
  • install Windows on a USB disk or flash drive

If you do not have the ability to connect a SATA disk directly to a computer – for example, to a laptop – but you really need to boot into the operating system that is deployed on it, then the trick described here will help you do this: plug the SATA disk to the computer via a USB adapter, and then connect the USB disk to the virtual machine as a regular disk, as shown in this guide.

Regarding the second point – installing Windows on a USB drive – if you want to install Linux on a USB flash drive (not to write a Live image, but to install a full-fledged system), then you do not have to do the trick shown here to install it – since Linux is perfectly installed on a portable media. But in Windows there is a prohibition for installation on USB disks and flash drives.

I will show you how to boot from USB on Windows and Linux. The principle is the same in both of these operating systems, but the commands differ slightly due to the specifics of the OS.

How to Boot into VirtualBox from USB on Windows

Plug a USB flash drive or disk to your computer. Then press Win+r and execute diskmgmt.msc.

Find your USB flash drive and remember the disk number:

For example, in my screenshot, the flash drive has the number 2.

Close all VirtualBox windows if they are open.

Next, we need to open a command prompt as administrator. To do this, press Win+x and select “Windows PowerShell (Admin)”.

Now go to the folder where you have VirtualBox installed. If this program is installed in the default directory, then the command to go:

cd $Env:programfiles\Oracle\VirtualBox

If you chose a different location for VirtualBox, then edit the previous command accordingly.

Now, in the command line, paste the following command, in which replace # with the disk number that we looked at just above, then press Enter:

.\VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#

For example, I have this second disk, then the command looks like this:

.\VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive2

If everything went well, the following message should appear:

RAW host disk access VMDK file C:\usb.vmdk created successfully.

Note that you can replace C:\ usb.vmdk with any file location you want.

This command creates a virtual machine disk file (VMDK) pointing to the physical disk you selected. When you use a VMDK file as a disk in VirtualBox, then VirtualBox will actually have access to the physical disk.

Now open VirtualBox as administrator - this is a must, otherwise it will not work as it should. To do this, click the Start button, type in “VirtualBox” and select “Run as administrator”:

VirtualBox can only access raw disk devices with administrator privileges.

Now in VirtualBox create a new virtual machine, select the appropriate operating system and when it comes to choosing a hard disk, instead of creating a new one, select “Use an existing virtual hard disk file”:

Click “Add”:

Now open the file C:\usb.vmdk (or another one if you saved it in a different location or under a different name):

Choose it:

Press “Create” button:

Boot your virtual machine, now it should see your USB flash drive as an ordinary hard drive. That is, if it is a correctly written boot disk or USB flash drive, then the system will boot from it.

Please note that the USB device must be the first hard drive in your VirtualBox virtual machine, otherwise it will not boot. If you are connecting a new USB disk to an existing machine, then try changing the order of the media in the settings of this machine, or select the appropriate disk at the beginning of the boot.

How to Boot into VirtualBox from USB in Linux

To understand the principle, read the previous section on Windows.

To do without root rights in Linux, you need to add the user (yourself) to the “disk” group:

sudo usermod -a -G disk $USER

Then reboot.

If you do not add yourself to the “disk” group, then you will need to run VirtualBox as root or with sudo, otherwise you will encounter an error:

VD: error VERR_ACCESS_DENIED opening image file '/home/mial/VirtualBox VMs/usb.vmdk' (VERR_ACCESS_DENIED).

On Linux, to find out the name of the USB drive, run the command:

sudo fdisk -l

In my case, the disk name is /dev/sdb.

To create a virtual disk file pointing to a real disk, run a command like this:

VBoxManage internalcommands createrawvmdk -filename '~/VirtualBox VMs/usb.vmdk' -rawdisk /dev/sdX

Where, instead of X, write the letter of the corresponding drive. An example for my conditions:

sudo VBoxManage internalcommands createrawvmdk -filename '~/VirtualBox VMs/usb.vmdk' -rawdisk /dev/sdb

In this command, you can replace '~/VirtualBox VMs/usb.vmdk' with a different location of your choice.

Everything else – creating a virtual machine and choosing an existing virtual disk as a hard disk – just like in Windows.

Note that the usb.vmdk file is a simple text file that you can move to any location and even edit.

Instead of a name like /dev/sdX, you can use a by-id based persistent name, for example:

VBoxManage internalcommands createrawvmdk -filename flash.vmdk -rawdisk '/dev/disk/by-id/usb-Samsung_Flash_Drive_0325121050019952-0:0'

This will allow you to avoid an unavailable disk error if its name changes. See the article “Persistent names for block devices” for details.

Connection type “Bridged Adapter” stopped working on VirtualBox guest machine (SOLVED)

In the settings of the virtual machine on the “Network” tab, you can select the type of network connection. The most common types are NAT and Bridged Adapter.

NAT: for a virtual computer, its own local network is created, which has an Internet connection. This computer is not accessible from the local network of the main machine

Bridged Adapter: the virtual computer appears to be on the local network of the host computer. The virtual computer is assigned the IP address of the local network of the router. You can connect to the network services of a virtual computer using a local IP.

If you do not need the ability to connect to a virtual machine, then it does not really matter for you which type of network connection to choose from these two.

Bridged Adapter in VirtualBox not working

You may encounter a situation that the Bridged Adapter functioned normally for a long time, and then simply stopped working, as a result of which the guest machine ended up offline, that is, without connecting to a global or local network.

Moreover, this can happen even if VirtualBox has not been updated recently and no other software changes have been made.

One of the reasons for problems with the Bridged Adapter can be a change in the used network adapter. The fact is that for the Bridged Adapter you need to specify the name of the network card in which the guest machine will have its own IP and to which it will be connected.

In this case, a network adapter named wlo1 is selected in the screenshot.

But in fact, this adapter is not connected to the router, and a different network card is used for the Internet connection.

When you change the network card to the correct one, the Network Bridge starts working normally again and the virtual computer immediately gets a connection to the network.

The cause of this problem may be that you have started using a different network card for the real computer (host). For example, you used to use a wired connection and then switched to wireless. Or you used the built-in Wi-Fi card and then switched to a USB Wi-Fi dongle.

In any of these situations, this guide will help you fix the problem with the Network Bridge.

Ubuntu in VirtualBox does not stretch to full screen although Guest Additions are installed (SOLVED)

1. Are the Guest Additions actually installed?

First, make sure you actually have Guest Additions installed.

It is recommended to update the guest OS to the latest package versions:

sudo apt update
sudo apt full-upgrade

After the update is complete, restart your computer:

reboot

There is a guest additions package in the standard repositories. It can be installed as follows:

sudo apt update
sudo apt install virtualbox-guest-dkms

2. Enabling full screen mode and resizing the guest OS screen

To switch to full screen mode, press Host+A, or go to Menu → View → Full screen mode.

If this did not help either, then maximize the virtual machine window to the maximum, then go to Menu → View → Auto-resize Guest Display.

3. Changing the type of graphics controller

If that doesn't work, try with different graphics controllers. With the virtual machine turned off, you need to go to its settings, then to the Display tab.

On this tab, you need to set VMSVGA or VboxVGA as the Graphics controller - try different controllers and see which one works with “Auto-resize Guest Display”.

4. Reinstallation and reconfiguration of virtualbox-guest-dkms:

sudo apt remove virtualbox-guest-dkms --purge
sudo apt install virtualbox-guest-dkms
sudo dpkg-reconfigure virtualbox-guest-dkms

5. Increase the video memory size

In the settings of the virtual machine, increase the video memory size to the maximum

6. Manually change the screen resolution settings

Go to the screen resolution settings of your guest virtual machine and select another, more appropriate.

So

Some of these methods should help you. Write in the comments – which one, it will help other users who have encountered the exact same problem.

If all else fails, then it is recommended to update VirtualBox to the latest version, and also make a full system update and reboot:

sudo apt update && sudo apt full-upgrade -y
reboot

Why does VirtualBox lose connection when changing MAC address (SOLVED)

Virtual machine, after changing MAC address of eth0, the connection does not work. When changing only the last three octets, the situation is the same. Restarting the modem does not give results, there is no filtering by MAC addresses. Why is this happening and how can I fix it?

VirtualBox does not support changing the MAC address inside the guest virtual machine.

The “official” method of operation is to change the address in the virtual machine settings when the guest computer is completely turned off.

Guest MAC address information is generated by the physical hardware, in this case the VirtualBox network adapter.

VirtualBox uses the hardware on the host and provides the MAC address for the guest as if it were in metal. But a reasonable question arises, because on a physical computer, the MAC address is also hard-coded into the network card and it is impossible to change it on it, but Linux supports changing the MAC address to arbitrary ones and the network is working fine, why is there such a difference?

And by the way, changing the MAC address in the virtual machine breaks the Internet connection for the wired interface only. For Wi-Fi wireless network interfaces (connected via USB), changing the MAC address does not lead to any problems, they work fine, there is a network connection.

There are two possible reasons for this behavior:

1. Whatever MAC address is hard-coded into the network card, the final decision whether or not to accept a packet is made by the operating system kernel. This is in the case of a physical computer. In the case of a virtual machine, it is up to VirtualBox, which may not be aware of what exactly is happening in the virtual machine and that it has changed its MAC address. Therefore VirtualBox does not know about the new MAC address and does not forward Ethernet frames to it.

2. The differences between wired and wireless networks are obvious: in wireless networks, radio waves propagate freely and every device within reach has access to absolutely all transmitted frames. As for the wired network, the sender sends Ethernet frames to a specific port (in the sense of the device's network port). That is, it is possible that the data is simply not sent by the sender to the new MAC address, since it does not know anything about it.

However, some users wrote that they managed to get the wired interface in the virtual machine to work after changing the MAC address - for this they put it in promiscuous mode. This method did not work for me (the network is still unavailable), but you can try it yourself (replace the eth0 interface name with your own):

sudo macchanger -s eth0 # check the current MAC address
sudo macchanger -r eth0 # change the MAC address to random
sudo ip link set dev eth0 promisc on # put the network interface in promiscuous mode
ping 8.8.8.8 # check if the network is working
# sudo macchanger -p eth0 # return the old MAC address if the network is down

As for the wireless interfaces in the virtual machine, everything works there without the need to switch the network interface to promiscuous mode.

Commands for changing the MAC-address of the Wi-Fi card (replace the wlan0 interface name with your own):

sudo ip link set dev wlan0 down # this is required
sudo macchanger -s wlan0 # check the current MAC address
sudo macchanger -r wlan0 # change the MAC address to random
sudo ip link set dev wlan0 up # this is required
# sudo macchanger -p wlan0 # if needed, return the old MAC address

VirtualBox shared folder is read-only (SOLVED)

VirtualBox Shared Folder allows you to easily exchange files between a virtual machine and a real computer.

By default, the contents of the Shared Folder are owned by the root user. Therefore, the files in the shared folder are read-only for regular users. The following manual shows how to make the VirtualBox shared folder read/write accessible to regular users.

1. Install VirtualBox Guest Additions.

Without Guest Additions, shared folders won't work properly.

2. Add a Shared Folder if you haven't already.

3. Make sure the “Read-only” checkbox is unchecked in the Shared Folder settings.

4. Add your user to the vboxsf group:

sudo usermod -a -G vboxsf $USER

Restart your computer for the changes (the user is added to the group) to take effect.

In theory, this should be enough for the shared folder to become writable. That is, the point is that the folder is mounted so that the group that it belongs to is vboxsf. Users in this group can edit the contents of the folder.

But on some distributions the folder is mounted as owned by the root user and owned by the root group. In this case, regular users have read permissions to the contents of the shared folder, but they cannot edit files in it, create new files, or delete existing ones.

The vboxsf filesystem has uid= and gid= mount options, you can try them with commands like:

sudo mount -t vboxsf -o 'uid=1000,gid=141' SHARE_NAME /PATH/TO/POINT/MOUNT

Or add a line like this to the /etc/fstab file:

SHARE_NAME	/PATH/TO/POINT/MOUNT	vboxsf	gid=141	0	0

But both of these methods did not work in my case.

I tried to change the owner of the folder and its contents using chown:

echo $USER
mial

sudo chown -R mial /mnt/share

But this did not work either - the owner of this folder was still root.

The only way to make the folder readable was by changing the access rights to it with chmod.

This command will create and modify new files and directories in the shared folder:

sudo chmod 777 /PATH/TO/POINT/MOUNT

Conclusion

Note that changing file permissions changes them not only for the virtual computer, but for the real one too! Therefore, the method described above cannot be considered ideal. If you have any thoughts on how to force the shared folder to be mounted with the vboxsf group, then write in the comments!

How to install VirtualBox Guest Additions in Linux LMDE

LMDE is the Linux Mint Debian Edition, i.e. Linux Mint based on Debian.

VirtualBox Guest Additions are kernel modules (drivers) that are needed if you run Linux LMDE in a VirtualBox virtual machine.

Thanks to guest additions it is possible:

  • enable a shared clipboard between the real operating system and the guest OS
  • enable file drag and drop between host and guest OS
  • expand the guest OS screen to a larger size or use the guest OS in full screen mode, as well as enable display integration.

Guest Additions are not available in the standard Linux LMDE repositories (Linux Mint Debian Edition).

There are two installation options:

  • install Guest Additions from the disk that comes with VirtualBox
  • add a third-party repository

I prefer the first option, so let’s consider it.

Start by fully upgrading and rebooting the system:

sudo apt update && sudo apt full-upgrade -y
reboot

Install the dependencies needed to compile the kernel module:

sudo apt install build-essential module-assistant

Configure the system to build kernel modules:

sudo m-a prepare

Connect the disk with Guest Add-ons, for this, in the VirtualBox menu of the virtual machine, select «Devices» → «Insert Guest Additions CD image»:

Return to the system again and do type in console:

cd /media/*/VBox*
sudo sh VBoxLinuxAdditions.run

Wait for the installation to finish, pay attention that everything goes without errors.

After the installation is complete, reboot again for the changes to take effect:

reboot

In the VirtualBox menu, turn on “Shared Clipboard” and other functions that you need:

Loading...
X