I would like to install VirtualBox as an Ubuntu testing environment. Must I permanently sacrifice system resources such as RAM? Or only when the environment is running?
- You must sacrifice some disk space when you install it.
- And a minor part of RAM, as it loads additional kernel modules.
Nothing more, as long as the app is not running.
The ressources you assign to a virtual machine are different:
- of course its virtual disks/storages will be there until you delete that VM and its files
- the RAM assigned to the VM will only be used when you fire up the VM and should be freed once you power it down.
- Same for the RAM VirtualBox itself uses to run, which should be freed when you exit the VirtualBox application itself.
The most common bottleneck, in my experience, is the HDD and/or the memory controller.
There will be more space allocated in the RAM, that's for sure, but the big problem is that your HDD and your memory controller have to work double times for 2 OS, doesn't matter if the 1 OS is virtualized, it still have to access a phisical device somewhere to read and write data.
If you have a chance to install and use another HDD, use this one to store all the data about your VM, having 2 HDD will make everything run smoother.
If the guest is Linux, there is one option not mentioned often that may improve speed a lot if meet the requirements.
You can tell VirtualBox to use a USB disk inside the guest, and if the guest is a Linux system, it can use such a disk for root, though maybe not for boot (VBox refuses to boot from USB).
Also you can tell VBox to use such a disk as RAW (warning: with host accessing the disk at same time, if host is Windows you had better set disk as offline). I dislike this a lot; I prefer to pass a USB drive.
But ensure the USB drive is fast (better if an SSD) and USB is 3.x (better if 3.1 Gen2), USB 2.0 is a real bottle neck.
In this way the Linux guest will control the real hardware (through USB pass) and that can make the guest really smooth.
Also think about using Linux Live systems (that run full in RAM), but have plenty of RAM (like 32GiB/64GiB/128GiB/256GiB/.../1TiB of RAM on Host).
Nothing actually beats RAM speed.
My configuration is a 128GiB AMD ThreadRipper 1950X (16 cores/32 threads) with 128GiB of DDR4 and eigth 120GiB SSD (each 500MiB/s) in LVM2 (stripped).
On boot the Linux system copies its 2GiB Host Linux into RAM (from an SSD like RAID 0 in less than two seconds), then host is running fully from RAM, then I copy the Guest disks to RAM drive (64GiB copied on less than nine seconds) and then I run VBox and start the Guest, and the guest disks are fully on RAM.
So all (host and guest) runs with all disk storages on RAM (faster disk access while running is impossible with any physical disk).
I know, I allow only 30GiB for host and guest as RAM, for host I give 6GiB and guest 24 GiB.
So my 128GiB are used as this (number with * indicate approximated):
- 2GiB* of RAM Drive for Linux host (disk to ram boot)
- 6GiB of RAM as host RAM (for host system and apps)
- 64GIB of RAM Drive for Guest virtual (fised size) disk
- 128MiB of RAM for guest video memory
- 24GiB of RAM for guest RAM
- Total: 128GiB
I know having 128GiB lets me do good things.
I should mention that using this setup my Guest is immutable unless I save from RAM drive the disk image back to the SSDs.
Also note SSDs are used only at boot time, and only at shutdown if I want to save changes, while on boot they are used for only around 12 seconds (yes, you read correctly, less than a quarter of a minute), and if I want to save the changes on powerdown they are used for only nine seconds.
Since I have it on powerdown each night, my SSDs are used on read only 12 seconds per day, and on write only 9 seconds per day (not all days).
Also note that all reads/writes are for files with sizes (near 2GiB host Linux .ISO, like a small LiveDVD)+(64GiB of guest virtual fixed size disk), except Grub2 boot files, kernel and initramfs. So my main use of SSDs are for two non-fragmented files, one of near 2GiB, one of 64GiB.
Having a lot of RAM is really great (and such processor is brilliant), but expensive (near $3000).
I could do it better if I were rich... use a Quad socket main board for AMD Epyc processors (each one costs $4000, so only the processors are $16000). I cannot afford such huge prices, but such a mainboard allows up to 1 TeraByte of DDR4 RAM... think what could I do with such a beast!