Virtual machines allow you to run a computer inside a computer as an app or program. This can be extremely helpful testing Leap or other ENF applications in a clean environment or using an operating system different than what you have installed. This guide, written while I was waiting on three permutations of Ubuntu to install in VMs on two different host machines, will walk you though setting up Ubuntu virtual machines assuming you know nothing about virtual machines.
Note there is a host, your physical computer, and a guest, the virtual machine running as a program on your computer.
- VirtualBox
- Security Concerns
VirtualBox is a free and open source type 2 hypervisor that lets you run virtual machines. If you are using Windows or Linux, we recommend using VirtualBox. It is free, capable, and runs very fast on Windows and Linux. If you are using macOS then you can try VirtualBox. It works okay for some people, but most users report very poor performance and graphical bugs on macOS.
Download and install VirtualBox, if you haven't already.
On Debian-family Linux, run the following.
sudo apt-get update
sudo apt-get upgrade -y virtualbox
Note that the package virtualbox-guest-utils
is not free and open-source software, this package is licensed by Oracle. You will probably never need it. If you do, consult the license terms and ENF leadership to determine if we need to buy a license or if we can use it for free.
Follow these steps to create a new virtual machine.
- Open VirtualBox
- Create a new virtual machine
- Machine > New
- Click
Expert Mode
at the bottom - Give your virtual machine a name, like "Ubuntu 22.04.1"
- Make sure
Type
isLinux
- Make sure
Version
isUbuntu (64-bit)
- Set the memory size to between 8192 MB and half your system memory
- Ensure
Create a virtual hard disk now
is selected underHard disk
- Click
Create
- Change
File size
to at least 64 GB, 128 GB would be better.- It will not use this much space on your actual hard drive.
- Ensure
Dynamically allocated
is selected on the right underStorage on physical hard disk
- Click
Create
- Configure the virtual machine
- Click
Settings
- General
- Advanced
- Consider setting
Shared Clipboard
toBidirectional
- Consider setting
Drag'n'Drop
toBidirectional
- Consider setting
- Description - provide a useful description
- Advanced
- System
- Motherboard
- Uncheck
Floppy
because this isn't 2001 - Uncheck
Hardware Clock in UTC Time
- Uncheck
- Processor
- Set
Processor(s)
to some portion of your physical CPU cores. If you have a lot then you really don't need more than four. Put another way, the slider should be in the green part as far to the right as you can without touching the red part. For example:- If it says that you have 8 CPUs and four of them are green, choose 1, 2, or 3.
- If it says you have sixteen CPUs and all of them are green, you can choose up to 15, but four is plenty and I really wouldn't exceed 14.
- If it says you have two CPUs, choose one.
- Check any of the
Extended Features
that are available to you
- Set
- Motherboard
- Display
- Screen
- Turn
Video Memory
all the way up no matter how bad your computer is - Check
Acceleration: Enable 3D Acceleration
at the bottom
- Turn
- Screen
- Storage
- Click
Empty
with the little blue disk next to it - Click the little blue disk with the down arrow on the far-right
- Click
Choose a disk file...
- Select the
*.iso
file on your host (computer) for the operating system you are installing - Click
Open
- Click
- You can share folders between the host and guest under
Shared Folders
if you wish - Click
OK
- Click
Install Ubuntu using the default installation options.
- Click
Start
for your virtual machine - Click
Install Ubuntu
- Click
Continue
- Click
Continue
- Click
Install Now
- Click
Continue
- This will only effect the guest virtual machine, not your host computer
- Click
Continue
- Enter stuff here. The hostname or computer name must be unique from every other computer or virtual machine in your house.
Name: Zach Computer name: enf-jammy-vm Username: zach
- Enter a password, as well. I honestly use a simple password that is the same for all of my virtual machines because the virtual machine disk image is stored in your user/home folder so it is behind the security of your host, hopefully including full disk encryption and a strong password.
- Check
Log in automatically
- Click
Continue
- Once the installation finishes, follow the instructions to restart. For older versions of Ubuntu, you may have to use Machine > Reset
We will take a snapshot of a "clean install" with nothing installed or upgraded, and only minor setup. This will allow you to instantly revert to a "clean install" for testing later, if you need to.
- If prompted to upgrade anything, decline.
- Click through any welcome wizards until they are gone. Don't install anything.
- Change apps pinned to taskbar as desired.
- Un-pin any items on the left that aren't useful to you by right-clicking >
Remove from Favorites
. - Likewise, pin any items there that are useful to you by hitting Start/Windows/Super, typing the name of the application, right-clicking, then selecting
Add to Favorites
. HitEscape
to get out of the start menu or launcher. - Arrange the icons on the left taskbar as you like.
- Un-pin any items on the left that aren't useful to you by right-clicking >
- Shut down the guest (virtual machine).
- Select your new virtual machine on the left.
- Machine > Tools > Snapshots
- Click
Take
- Name it something useful, like "Ubuntu 22.04.1 clean install"
- Give it a useful description explaining what you have done so far. For exmaple:
A clean install of Ubuntu 22.04.1 with default settings. Icons were rearranged.
- Click
OK
.
We will install "guest additions," a suite of basic tools that will allow you to copy and paste between your host and guest, drag-and-drop, use "seamless" integration where you can have programs running on your guest appear in your taskbar like they are running on your host, and, most importantly, it allows you to easily resize your guest window instead of it being tiny. We will take a snapshot with this setup so that, if you bork your virtual machine, you can just restore it to a point where all this stuff is already setup but you haven't done anything to it yet.
- Click
Start
to boot the guest back up. - Once it has started, open a terminal in the guest.
[Ctrl] + [Alt] + [T]
- Update the guest.
sudo apt-get update sudo apt-get upgrade -y
- Install programs required by VirtualBox guest additions.
sudo apt-get install -y gcc make perl
- Select
Devices
>Insert Guest Additions CD Image...
.- Some versions of Ubuntu might prompt you to select
Run
orCancel
.Run
might work, but I always just clickCancel
and run the command in the next step.
- Some versions of Ubuntu might prompt you to select
- Install VirtualBox guest additions.
/media/$USER/VBox_GAs_6.1.38/autorun.sh
- This will prompt you for your guest password. If you run this script with
sudo
, it doesn't work for some reason.
- This will prompt you for your guest password. If you run this script with
- Once this finishes, press
[Enter]
. - Install caffeine, a program that allows you to keep the virtual machine from going to sleep or locking by clicking a little coffee cup in the system tray by the clock.
sudo apt-get install -y caffeine mkdir -p ~/.config/autostart/ ln -s /usr/share/applications/caffeine-indicator.desktop ~/.config/autostart/caffeine-indicator.desktop
- Make a work folder for your code, and make the terminal open there by default.
mkdir -p ~/Work echo 'cd ~/Work' >> ~/.bashrc
- Install any additional tools you want baked-in for developer work. Don't install too much, you probably want this to be as close to a clean install as possible for debugging. Don't forget that these tools weren't installed by default when you write documentation.
sudo apt-get install -y curl git jq
- Reboot the guest (virtual machine).
- Now you should be able to do things like resize your virtual machine window.
- After it reboots, right-click the CD icon on the desktop or in the taskbar and select
Eject
.- If it isn't there, look in the file manager. On some versions of Ubunut, it may no longer be in the pretend CD ROM drive.
- Shut down the guest.
- Select your new virtual machine on the left.
- Machine > Tools > Snapshots
- Click
Take
- Name it something useful, like "Ubuntu 22.04.1 + guest additions + caffeine, curl, gcc, git, jq, make, perl"
- Give it a useful description explaining what you have done so far. For exmaple:
A clean install of Ubuntu 22.04.1 with default settings. I installed caffeine, curl, gcc, git, jq, make, and perl. Then I installed VirtualBox guest additions and created a Work folder. Icons were rearranged.
- Click
OK
.
If you followed the whole guide, you can now restore any of your Ubuntu virtual machines to the state of a clean install with no modifications, an installation with guest additions and minimal tools, or any other point in time where you took a snapshot. You can use the snapshot process described previously to create as many snapshots at different points in time as you want.
- Select the virtual machine on the left
- Machine > Tools > Snapshots
- Click the snapshot you wish to restore from
- Click
Restore
- Choose whether or not to take a snapshot of the current state
- If you don't create a snapshot of the current state of your virtual machine, it will be gone forever
- Click
Restore
- If you left
Create a snapshot of the current virtual machine state
checked, follow the steps to create a new snapshot with a useful name and description - Click
Current State
- Sometimes it says
Current State (changed)
, don't worry about it...this will be the machine restored from your snapshot
- Sometimes it says
- Click
Start
Resuming a virtual machine from a snapshot or copying your virtual machine in any way (to another computer or on the same computer) has security implications. Mainly, the random number generator used for stuff like HTTPS or SSH could re-use the same random numbers. If you copy your virtual machine or resume from a snapshot then should assume none of those connections are actually safe. If you need them to be secure, do not restore snapshots, do not copy your virtual machine files (e.g. to another computer), and do not use virtual machines that you recovered from a hard drive backup like Apple Time Machine, Carbonite, Backup Tool, or similar.
While your host is mostly (but not entirely) protected from what happens in the guest, the guest is never more secure or safe than your host.