16
August
2023
Use Virtualbox with USB flash drive
17:35

Use Virtualbox with USB flash drive

16 August 2023 17:35

Usually, when creating a virtual machine in Oracle VM, an ISO file is chosen with the image of a loading flash drive. But you can also use a physical carrier for loading in VM - a USB disk with a Live CD operating system recorded on it.

System requirements

1. For Oracle Virtualbox 6.x and 7.x, hardware support is required by the processor of the option for hardware virtualization vt-x .

*Intel processor produced later 2011 ("Sandy Bridge" and newer). For example, Intel Core i5-3330 was released in 2012 with VT-X support for Socket 1155.

  • Almost all Intel Atom.
  • Pentium Dual-Core E5500 regardless of marking, some E5300, E5400 for Socket 775.
  • Core 2 Duo "Conroe" E6300 ... E6850 WolfDale-2M core. The BIOS should have the menu item "Virtualization Technology" - turn it on.

Intel® Core 2 Duo "Allendale" E4300 ... E4700 and Intel® Pentium® D ProCessor 945, Pentium® Dual-Core E2200 and Celeron release before 2010 do not support vt-x.

U AMD The technology of hardware virtualization is called AMD-V ™ .
It is implemented in the AMD Athlon 64 ("Orleans"), Athlon 64 X2 ("Windsor"), Athlon 64 FX ("Windsor"), the processor family for the AM2 - Athlon 64 and Athlon 64 X2 steps "F" or "G", Turion 64 X2 And Opteron of the 2nd and 3rd generations, Phenom and Phenom II.
Naturally, they support hardware virtualization of more and more new AMD Ryzen processors (Zen, Zen 2, Zen 3, Zen 4).

You can find out the processor model with a team:

sudo lshw -class cpu

Then check with the manufacturer’s website, learning about the support of VT-X. If the processor does not support VT-X, you need to roll back to Oracle VirtualBox version 5.22 (see the last paragraph).

In the BIOS or UEFI BIOS, the menu item for turning on the virtualization is called "virtualization technology" or svm or vt -x - it must be turned on - enabled . It is also desirable to have vt-D virtualization for spraying input-output ports and PCI devices (analogue Immu in AMD).

2. Support for the instructions of the instructions SSE2 (Streaming SIMD Extensions 2). It is supported by the majority of processors - the IA -32 iron class also designated I486, i586 and i686 or newer (X64): almost all Intel and AMD processors. These instructions are not implemented in processors to Athlon 64 (for example, Athlon XP).

Launch methods

1) A loading disk is stored on the flash drive, and a virtual hard drive file (for example, VHD) is created on the local hard drive. The ISO loading file is selected in Oracle VM when creating a virtual machine and then the VM is loaded from the ISO file and launch in the Live mode or installing the operating system.

Advantage: on the flash drive you can store several ISO files.
Disadvantage: for each VM you need to create your own virtual hard drive, which is invoice when using an SSD-disk, because Spend free space.

2) loading flash drive - prepared boot disk is launched into Oracle VM. The physical disk - "flash drive" with the image of the system is used using the VMDK file as SATA 0 controller.

Dignity: saving space on the hard drive, information is stored only on a flash drive.
Disadvantage: The initial initialization (see below) and below the speed of circulation is more difficult than with a local SSD.

3) The loading flash drive is not used in Oracle VM, but directly on the "iron" - when starting the computer, you need to enter the boot "boot menu" by clicking when the computer is included in the F9 or F12 button (or go to the BIOS Setup menu, where to specify the priority of the launch of "removable dev.").
The operating system starts with USB Flash.

Dignity: It is promised to load on almost any PC when choosing a launch of USB, some Linux (Antix) distributions maintain constancy - "persona" (storage of data from a flash drive). Saving a disk space.
Disadvantage: Not all computers can boot with USB flash, some old can only with CD/DVD. The need for manipulation with Boot Menu at the start of the PC. To record a flash drive with Persistence, you need to use not DD or Balena etcher, but rufus or mx_live_usb_maker. See detailed article about recording a loading usb flash drive with constancy.

The best ways to create a loading flash drive

In addition to copying dd if = some.iso of =/dev/sdc bs = 1m, there are two new ways:

In Windows - program rufus :
*https://rufus.ie/ru/

In linux:
*https://etcher.balena.io/

The Balena Etcher application records the loading USB Flash in the CD-R ISO9660 format ("only reading"). For recording USB flash drives in the function of preserving constancy cm.The article "How to record the booting USB Flash for Antix / MX Linux with constancy" ".

Which version of the distribution to choose for the guest OS - X86 or X64?

If the host’s OS has a full -fledged X64 support and the modern processor supports the VT -X or AMD -V hardware virtualization - you can safely choose OS X64 (the ISO file in the file name contains the “X64”).

If an OS type X86 or the processor does not support VT -X, you have to choose versions I386 - i486 or i686 (ISO file usually contains a note "X86" in the file).

Installation VirtualBox from the Ubuntu 22.04 repository for processors with VT-X

If the processor supports hardware virtualization, Virtualbox 6.1 will operate with a 5.15 core from the Ubuntu or Linux Mint repository.

Installation Virtualbox 6.1 or 7.0 - 7.1.8 (reinstallation) is simple:

sudo apt update
sudo apt install --reinstall linux-headers-$(uname -r) virtualbox-dkms dkms virtualbox-qt
sudo reboot

After rebooting, on behalf of the superpower, we perform the Module loading command

sudo modprobe vboxdrv

Now you can run VirtualBox either on the menu or the console command

virtualbox

If when starting a virtual machine there is an error vt-x is not avilable (Verr_vmx_no_vmx). Error code: ns_error_failure (0x80004005), so the processor does not support the hardware virtualization of VT-X. The problem can be solved by the upgrade of the motherboard and processor.

Refusal of VirtualBox 6 and installation of Virtualbox 7 for new processors with VT-X

This method is relevant for OS 22.04 and above, for processors with support for VT-X or AMD-V.
If you install VirtualBox from the repository (APT Install VirtualBox), Virtualbox 6.1 will be installed in the UBUNTU version 22.04.
While the newer version of Oracle Virtualbox 7.0 was released on July 18, 2023.

Removing VirtualBox of any version:

sudo apt remove --purge virtualbox virtualbox-guest-utils

Detailed article on installing virtualbox 7.0 on Linuxcapable.com на английском языке.

sudo apt update
sudo apt upgrade
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y

I import the GPG key for the repository

curl -fSsL https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/virtualbox.gpg > /dev/null

For Ubuntu 22.04 "Jammy" and derivatives from it:

echo deb [arch=amd64 signed-by=/usr/share/keyrings/virtualbox.gpg] http://download.virtualbox.org/virtualbox/debian jammy contrib | sudo tee /etc/apt/sources.list.d/virtualbox.list

For Ubuntu 20.04 "Focal" and the derivatives of it:

echo deb [arch=amd64 signed-by=/usr/share/keyrings/virtualbox.gpg] http://download.virtualbox.org/virtualbox/debian focal contrib | sudo tee /etc/apt/sources.list.d/virtualbox.list

The new version of Ubuntu 24.04 LTS uses the code name NOBLE, in 25.10 - Quizzical. For Debian -Watch Wiki for installing Virtualbox on Debian 11 "Bullseye", 12 "Bookworm".

The next command displays the names of packages starting with VirtualBox:

sudo apt update
apt-cache search virtualbox | grep "^virtualbox*" 

I install the VirtualBox-7.0 package:

sudo apt install virtualbox-7.0 linux-headers-$(uname -r) dkms virtualbox-dkms build-essential module-assistant -y

I launch the Vboxdrv service:

sudo systemctl enable vboxdrv --now

I turn on the VM driver in the nucleus:

sudo modprobe vboxdrv

I delete traces of old VM drivers. Otherwise, the error of the inconsistency of the version of the drivers and the VM version

sudo mv /lib/modules/$(uname -r)/updates/dkms/vbox* /tmp

Where $ (UNAME -R) sets a version of the nucleus used by the operating system, for example 5.15.0-79.

Installation of drivers of the new Oracle VM (!)

sudo /sbin/vboxconfig

Creation VM when using an ISO file

  • Launch the Virtualbox "Oracle VM"
  • menu "Machine" - "Create"
  • Specify the name, for example "Winxp"
  • We leave the folder by default (/home/name of the_Poller/virtualbox vms)
  • Choose an ISO-image, for example, WinXP.iso
  • Further.

Creating a virtual machine when using a loading flash drive

Create a VMDK file to communicate with a physical flash drive.

lsblk

By the volume of the disk we find a flash drive and watch the name - SDB or SDC.

version 5.2

Access to the physical device using the RAWDISK parameter is not supported. (The method with VMDK is useless.) It is possible only to create a virtual hard VDI or VHD disk on a local computer hard drive with an installation of an OS with a conventional ISO file).

version 6.0

VBoxManage internalcommands createrawvmdk --filename=~/usb.vmdk  --rawdisk /dev/sdc

or

VBoxManage internalcommands createrawvmdk --variant RawDisk --format=VMDK --filename=~/usb.vmdk --property RawDrive=/dev/sdc

Where /DEV /SDC we replace the name in your case, for example, it can be /DEV /SDB.

version 7.0 has a new team syntax - the parameter "Createmedium":

VBoxManage createmedium --variant RawDisk  --format=VMDK --filename=~/usb.vmdk --property RawDrive=//dev/sdc

Launch in the menu Start - System - Oracle VM VirtualBox
menu " car " - " create "

  • In the item "Iso ISO" we do not choose anything
  • The remaining points by logic
  • Further, further

Use the existing virtual hard drive - select
* usb.vmdk

Rights

sudo addgroup vboxusers
sudo usermod -a -G vboxusers vladimir
sudo usermod -a -G disk vladimir

Setting up parameters VM

You can disable virtualization in VM itself and change work with memory pages

VBoxManage modifyvm usb --hwvirtex off --nestedpaging off

where the USB is the name of the virtual machine.

An indication to use for VM one processor core:

VBoxManage modifyvm usb --cpus 1

where the USB is the name of the virtual machine.

Migration on Virtualbox 5.2 for old processors without VT-X

In versions 6.0 and 7.0 on the processors of bet hardware virtualization (or when the corresponding BIOS parameter is turned off), the Verr_cmx_NO_VMX error is issued. The only way out is to roll back the version up to 5.2.

V! Virtualbox 5.2 for Ubuntu 18.04 "Bionic Beard" was released in July 2020, during the nuclei 5.0 - 5.6. Virtualbox 5.2 can be launched only in Linux Mint 19.3 "Tricia" (19.3 Mate) or Ubuntu 20.04 (so far is supported - until April 2025) or the Russian OS Linux Lite 5.6, developed on the Ubuntu 20.04.
In the last Linux Mint 22.04, neither the core of 5.6 or Virtualbox 5.2 is launched.
In version 5.2 there is no way to connect to the physical flash drive as a RAW device (the main theme of this article) is possible only (https://www.virtualBox.org/manual/ch01.html#intro-vm-vm-first-time) OS from ISO-Fail hard drive.

1) Before installing Virtualbox 5.2, it is necessary to remove traces of the old version of Virtualbox 6 or 7

sudo apt remove virtualbox-6.1 virtualbox-7.0
sudo mv /lib/modules/$(uname -r)/updates/dkms/vbox* /tmp

2) Download virtualbox 5.2 (for Ubuntu 18.04 / 18.10 / 19.04).

*Download_old_builds_5_2

3) establish dependencies for Virtualbox 5.2 - LibVPX5 library and Python 2.7 programming environment.

sudo apt update
sudo apt install ca-certificates
wget http://ftp.de.debian.org/debian/pool/main/libv/libvpx/libvpx5_1.7.0-3+deb10u1_amd64.deb
sudo dpkg -i libvpx5_1.7.0-3+deb10u1_amd64.deb

Checked the Python version:

python -v

If Python 2 is not installed (by default, it is and is not required in Linux Mint 19.3), install it: we install it:

SUDO APT Install Python2

ВерThis Python should be 2.7.
If the main VirtualBox package is not installed without errors, the team can help sudo apt install python-is-python2.

The last dependence that needs to be allowed by hand is the Libqt5opengl5 library:

sudo apt install libqt5opengl5

5) installation of the nucleus 5.0, 5.4, 5.6 or 5.10 for Virtualbox 5.2

In Linux Mint 19.3 "Tricia" the default nucleus is installed 5.0 - suitable for Virtualbox. Nothing needs to be installed.
Packages coming complete with Linux Mint 19.3:
* linux-headers-5.0.0-32 *
Linux-headers-5.0-32-Generic
Linux-Image-5.0.0-32-Generic
Linux-Modules-5.0-32-Generic
Linux-Modules-Extra-5.0-32-Generic .
Linux-Tools-5.0-32-Generic **

The kernel 5.4 does not need to be installed. Nevertheless, VirtualBox start with a core of 5.4, which can be installed from packages:
* linux-headers-5.4.0-100 *
Linux-headers-5.4.0-100-geneeric
Linux-Image-5.4.0-100-Generic
Linux-Modules-5.4.0-100-Generic
Linux-Modules-Extra-5.4.0-100-Generic .
Linux-Tools-5.4.0-100-Generic **

In Ubuntu 20.04 (Linux Lite 3.6), you can update the Linux Kernel core to the version 5.6 : in the "Update Manager"-Type-Nucleus Linux set the core 5.6 (Linux-Image-5.6.0-1028-. Or in synaptic set packages:
* linux-headers-5.6.0-1028-onm *
Linux-IMAGE-5.6.0-1028-OEM
Linux-Modules-5.6.0-1028-onm
Linux-Modules-Extra-5.6.0-1028-Generic **.
* Linux-TOOLS-5.6.0-1028-OEM

Installation of the Linux Kernel 5.10 nucleus is possible in Linux 20.04: in the "Update Manager"-Types-Linux nucleus, we install the kernel 5.10 (Linux-IMAGE-5.10.0-1016-OEM). Or in synaptic set packages:
* linux-headers-5.10.0-1016-onm *
Linux-IMAGE-5.10.0-1016-OEM
Linux-Mudules-5.10.0-1016-OEM
Linux-Modules-Extra-5.10.0-1016-Generic **.
* Linux-TOOLS-5.10.0-1016-OEM

ДAnna operation is possible only on Ubuntu 04.04 and below, for example, on 19.04, 18.10, 18.04 or 16.04. In the last Ubuntu 22.04 or Linux Mint 21.x - the old nuclei do not work due to unsatisfied dependencies.

If the core is updated, we reload it and in the GRUB2 menu in additional launch parameters we select core 5.4, 5.6 or 5.10 :

sudo reboot

Select the kernel 5.0, 5.4, 5.6 or 5.10 Press Enter.

If after loading nuclei above 5.0, the resolution is 640 x 480, and not what was expected, edit/etc/default/grub, add the line to it
GRUB_GFXMODE=1280x1024 # resolution of your monitor

Then we perform
sudo update-grub

And once again we reboot the PC with the choice of the same nucleus. Now the display resolution is normal.

6) Installation Virtual Box 5.2
We delete the previous Virtualbox 5.2 installation if it is not configured (with errors).

sudo apt --fix-broken install

We install the VirtualBox team:

sudo ~/Загрузки
sudo dpkg -i virtualbox-5.2_5.2.44-139111~Ubuntu~bionic_amd64.deb

7) Install the nucleus drivers for Virtualbox 5.2 in the core.

sudo /sbin/vboxconfig

8) checks:

lsmod | grep vbox
sudo systemctl status vboxdrv

9) the launch is made through the Start menu (search by name VirtualBox).
Or from the command line:

 virtualbox

virtualbox => Help => about the program shows version 5.2.44.

In VirtualBox 5.2 and a processor without support for VT -X in a virtual machine, it is possible to install OS only [Mark] 32 -bit versions of distributions (i386 - i486 - i586 - i686) [/mark].


Sources:
Virtualbox documentation
Support Virtualization Tecnology with processors
*Askubuntu.com user tips

Documentation:
Virtualbox 5.2.44 usermanual.pdf
Virtualbox 6.1.46 Usermanual.pdf
*Virtualbox 7.0.10 Usermanual.pdf



Related publications