A Grand Tour of the Hardware in Our VirtualBox Virtual Machine
In Building a Virtual Machine, I talked about what a computer is and we went on to “build” one. We didn’t physically build a computer, though — we built a virtual one. (Confused? Check out I Want to Learn How to Build a Computer From Scratch, but I Have No Money. Now What? It’ll be worth it — there’s a meme waiting for you there.)
We started building this virtual machine because of two assumptions:
- We don’t have the money to build a real computer, and
- This claim I made in The Simple Path Towards Cybersecurity Expertise:
90% of cybersecurity ultimately boils down to extreme system administration and networking expertise. The other 10% is learning to think the way that hackers think.
This post illustrates some of the fundamentals that build up to what I mean by “extreme system administration”.
At the end of Building a Virtual Machine, we discovered that our new virtual machine doesn’t actually do anything useful. We’re now headed down a path towards making it do useful things. Specifically, our next move will be to install an operating system on it.
But…
What is an operating system?
Your computer’s hardware — whether physical or virtual — is a finite resource. An operating system is software that manages your computer’s finite hardware resources.
Just like how the conductor of an orchestra coordinates many individuals so that they perform together as one voice, an operating system coordinates many individual hardware devices so that they function as a single unit.
Before we install an operating system, it’s very important to understand the hardware inside of our computer. And so, in this post, we’re going to take a closer look at the virtual hardware devices in our new virtual machine. In the next post, we’ll get down to actually installing an operating system.
In Building a Virtual Machine, I said:
There are four main jobs for a piece of hardware in a computer, and all of them concern data:
1. Input
2. Storage
3. Processing
4. Output
Let’s explore each job and the hardware in our new virtual machine that are responsible for them.
Input/Output
I’m combining Input and Output into a single group for convenience. I won’t go out of my way to explicitly point this out for each device, but just keep it in mind that some hardware devices only provide input to a computer, some only help the computer produce an output, and some hardware devices do both.
BIOS
When you press the power button on your computer, how does it know what to do next?
For PCs, desktops, and laptops, the Basic Input/Output System (BIOS) provides the answer. From simple wiki:
The BIOS is a computer program embedded on a chip on a computer’s motherboard that recognizes and controls various devices that make up the computer. The purpose of the BIOS is to make sure all the things plugged into the computer can work properly. It brings life to the computer, and the term is a pun on the Greek word βίος, bios meaning “life”.
I’d never heard of the connection between BIOS and βίος until I started researching this post. What an amazing pun!
“Booting”, sometimes called “Booting up” is the process that the computer completes to get it ready to use when it is first turned on. When the computer turns on, the BIOS starts up and performs a Power-On Self Test (POST). During the POST, the BIOS will check various devices in the computer like the computer processor, memory, the video card and others to make sure they are present and functioning. Once the POST has completed successfully, the BIOS looks for an operating system to load, which is usually located on the computer’s hard drive. When it finds one, it starts to load it. At this point, the operating system takes over control of the system.
All computers generally follow this process, whether or not they call that first program “BIOS”. In my experience, VirtualBox exposes fewer capabilities in its own “BIOS” compared to what I’m used to in physical PCs. But it still achieves BIOS’s ultimate objective, which is that it:
…looks for an operating system to load, which is usually located on the computer’s hard drive. When it finds one, it starts to load it. At this point, the operating system takes over control of the system.
BIOS & Boot Order
So how does BIOS “look for an operating system to load”?
BIOS usually lets you define a prioritized list of hardware devices. After it completes the POST, it starts with the device at the top of its list, and checks that device to see if has an operating system. If it does, BIOS loads the operating system, and the operating system takes over. If not, it moves on to the next hardware device on its list and tries again. It continues this trial and error process until it finds an operating system to load or it runs out of hardware devices to try.
This is precisely what we observed at the dramatic conclusion of Building a Virtual Machine — our computer checked every hardware device that it knew about, but couldn’t find an operating system. This is what that looks like:
The ordered list of hardware devices that BIOS should check is called the “Boot Order”. VirtualBox lets us define that list here:
We have no plans to use floppy disks. So let’s rearrange our Boot Order a bit, to reflect that.
We’re disabling all floppy drives, by unchecking the “Floppy” check box. Then we move optical drives and hard disk above floppy drives. This tells VirtualBox that it should first check out optical drives (CD/DVD drives) for an operating system to load. If it doesn’t find one, it should then move on to look for operating systems on our hard disks. Because “Floppy” and “Network” are unchecked, VirtualBox won’t even bother to check those devices for an operating system.
Pointing Device
The pointing device is the hardware that provides the input to a computer that tells the cursor where to go. In other words, it’s your mouse.
Our virtual machine defaulted to using the “USB Tablet” pointing device, but we have other options.
We’re going to select “PS/2 Mouse”.
If you happen to have a computer that still has a PS/2 port, you’ll know it because it looks like this:
PS/2 was mostly used to hook up keyboards and mice. Most keyboards and mice come with USB plugs today, if they come with cables at all.
So…PS/2 is obsolete. Why select it? The simpler the technology, the more confidence I have that it’s going to be totally reliable. Relative to our USB choices, PS/2 is simpler, very well understood, and has been around for a long time.
Network
Networking is one of those components that really deserves of its own post. I think it’s enough, for now, to say:
- VirtualBox gives us the option of up to 4 network connections, but only enables one by default.
- Without going into the details, NAT makes it simple for our virtual machine to connect to the Internet, but challenging (but not impossible!) for other machines to make network connections to our virtual machine.
Serial Ports
If PS/2 has been around for a long time, serial ports have been around for a very long time.
Thanks to USB, serial ports are much less common today, although they still have their place when working with networking gear, industrial hardware, and embedded devices. It’s also possible to use serial ports to build out-of-band management solutions. All of the use cases are fascinating. However, we won’t be diving into them here, which is why we won’t enable any serial ports.
USB
Universal Serial Bus. This replaced serial ports, and made it much simpler for people to connect hardware to their computers.
VirtualBox has the ability to “see” USB hardware that we physically connect to our host computer from inside of our virtually machine. We’ll leave this turned on, but we won’t dive into this any time soon.
We’ll talk more about what controllers are, shortly.
Shared Folders
Shared folders are unique to virtual machines — it’s not something that we’d expect to find, if we had built a physical computer.
Shared folders let our virtual machine “see” folders that exist in the host operating system.
Storage
CD/DVD Drive
CD/DVD drives are much less common in physical computers today. The average computer user probably doesn’t have much need for one. But our virtual machine comes with a virtual CD/DVD drive by default, nonetheless.
It turns out that a CD/DVD drive still serves at least one very important function, though: booting from a DVD is still probably the simplest and most common way to install an operating system.
CD/DVD Drive — IDE Controller
Note that VirtualBox is showing that our CD/DVD drive is attached to an IDE controller.
A controller enables a disk to communicate with the computer. It’s a standard that defines the logic, as well as the electrical wires, needed to transfer data between the computer and disk.
We’re going to have to unravel several acronyms to understand IDE.
IDE is…
- …short for Integrated Drive Electronics.
- …also known as Advanced Technology Attachment (ATA)
- …also known as Parallel ATA (PATA)
Armed with that knowledge, you can easily find excellent information about IDE/PATA, on Wikipedia and in places like Chapter 3 of Scott Muller’s book Upgrading and Repairing PCs: The ATA/IDE Interface.
If you look closely, you’ll discover VirtualBox’s attention to detail. Hiding just behind the blue minus sign, you see can see a small icon that looks just like an IDE cable.
Here’s a physical IDE cable. See the resemblance?
You plug this:
Into this:
If we had built a physical computer with a physical DVD drive, our DVD drive would have an IDE port, our computer would have an IDE port, and we’d connect the two with an IDE cable.
If we take a look at the drop-down menu, labeled Optical Drive…
…we get four choices. Primary and Secondary refer to the first and the second IDE ports on the computer’s motherboard, respectively.
A single IDE cable can connect two hardware device through a single IDE port on the motherboard (using an IDE cable with three IDE plugs). Master and Slave are terms that IDE uses to delineate between device one and device two.
To make this a little clearer, take a look a this:
CD/DVD Drive — Disk Images
Recall that CD is short for Compact Disk and DVD is short for Digital Video Disk. Functionally, a DVD drive is backwards compatible in the sense that it can be expected to read both DVDs and CDs.
Our virtual CD/DVD drive will be useless if we can’t insert a disk into it. And, of course, since our CD/DVD drive is virtual, we can’t insert a physical disk into it. Fortunately there are types of files called disk images. A disk image contains an exact bit-for-bit copy of an original, physical disk.
Of course the makers of virtual machine software recognize this, and all virtual machine platforms should give you a way to load a disk image into your virtual CD/DVD drive.
Here’s what it looks like in VirtualBox:
Note the types of disk images that VirtualBox can handle:
We’re just going to focus on *.iso files, in future posts.
Hard Drive
In Building a Virtual Machine, we created an 80GB, dynamically allocated VDMK (Virtual Machine Disk), which is supposed to be “Split into files of less than 2GB.” Here’s a refresher of what we did:
Note that our disk is connected to a SATA controller.
SATA is short for Serial ATA. Remember — ATA is also known as Advanced Technology Attachment. SATA is much more common than IDE these days.
Similar to IDE, you see can a small icon that looks just like a SATA cable, hiding just behind the blue minus sign.
You plug this:
Into this:
Note that our virtual hard drive is plugged into Port 0:
Unlike a real computer, we’ve got our choice of up to 30 SATA ports:
In a real computer, you might get 6 to 10 SATA ports. 30 ports is a lot for a physical machine! But it’s no big deal for a virtual machine.
If we wanted, we could swap out our current virtual hard drive with another hard drive, like this…
Note that VirtualBox can handle a bunch of different types of virtual hard disk files.
We’ll stick with the virtual hard drive we’ve got, so you can just hit Cancel.
Back out on the Storage screen, there’s one more thing worth checking out — the Information section.
Specifically, note the following:
Virtual Size: 80.00 GB
Actual Size : 12.56 MB
Details : Dynamically allocated storage split into files of less than 2GB
Let’s take a closer look at what that really means.
We have 41 vmdk files. Almost all of them are 320 KB big.
Some quick, lazy math:
Inside of a virtual machine, it will appear to be 80GB large. But on our host operating system, that 80GB virtual disk only takes up 12–13MB. That is possible because we chose to make this disk “dynamically allocated”. Had we not done so, instead of taking up 12–13MB, our 80GB virtual disk would take up 80GB. As we start to fill the virtual disk with data, however, these vmdk files will grow larger and approach, but shouldn’t exceed, 80GB.
Note that the only vmdk file that does not have a numbered suffix in its filename is simply a text file. So we can look inside of it like this:
There appears to be a line that corresponds to each vmdk file with a numbered suffix in its filename. Hmmm.
Each line of the second section describes one extent. The extents are enumerated beginning with the one accessible at offset 0 from the virtual machine’s point of view. The format of the line looks like one of the following examples:
Some quick math:
Google to the rescue for converting bytes to GB.
So each vmdk file represents about 2GB, just about as we expected. (Remember, we created the vmdk, we told VirtualBox to “Split into files of less than 2GB”. Close enough!)
One last final note, for this section. We focused so much on the vmdk files that we neglected the vbox files. It turns out that a vbox file is just XML. So it’s easy for us to open up that file and see what’s inside, like this:
Processing
Central Processing Unit (CPU)
The CPU does simple math with binary numbers very, very, VERY fast — particularly addition.
When people describe a computer as “32-bit” or “64-bit”, that is a specific reference to the CPU. It tells us about the biggest number that the CPU can handle in a single operation. A “64-bit” machine means that its CPU can do math with binary numbers that have 64 digits.
Bill can explain it better than I can:
This badly oversimplifies things, but, at a very high level, a single CPU can only do one math operation at a time. If you have more than one CPU, your computer can do more than one thing at a time.
We’ll stick with one CPU for now — that’s enough for our needs.
We will turn on “Enable PAE/NX”, though. Generally, PAE/NX helps 32-bit operating systems deal with huge amounts of resources (like RAM).
Turning this on will help us to avoid some issues when we go to install an operating system.
System Clock
The system clock plays a big role in coordinating all of the electrical signals from all of the hardware plugged into the computer.
From VirtualBox’s documentation:
If selected, Oracle VM VirtualBox will report the system time in UTC format to the guest instead of the local (host) time. This affects how the virtual real-time clock (RTC) operates and may be useful for UNIX-like guest OSes, which typically expect the hardware clock to be set to UTC.
We’re going to install Linux, which is a UNIX-like OS. So, we want to make sure that “Hardware Clock in UTC Time” is checked.
What’s Next?
Whew! You made it through the grand tour of our hardware!
Next time, we’ll install an operating system, where lots of the knowledge you gained here will start to pay off.