A computer inside a computer
You want to test a risky program. You do not want to harm your laptop. So you make a second computer inside the first one. You try the program. Then you delete the second computer, and your laptop is not changed.
This is a virtual machine: a computer made of software. People use it everywhere, from small labs to very large data centres. A data centre is a building full of servers.
Key words
| Word | What it means | Example |
|---|---|---|
| Virtual machine | A computer made of software, running inside a real one. | A Windows computer inside a laptop |
| Virtualisation | Making a computer, or its parts, in software. | Ten servers on one machine |
| Host | The real computer that runs the virtual machines. | A powerful server |
| Guest | A virtual machine running on a host. | One virtual server |
| Hypervisor | Software that runs virtual machines and shares the host's parts between them. | The software that starts each guest |
| Operating system | The main program that runs a computer. | Windows, Linux |
| CPU | The processor, which runs a program's instructions. | The brain of a computer |
| Network | Computers joined to share data. | The college network |
| Router | A device that joins networks and sends data the right way. | A home router |
| Snapshot | A saved copy of a virtual machine at one moment, to go back to later. | Before a risky change |
| Emulation | Making one computer act like a different one. | An old games console on a laptop |
The cells students fill in are left blank in this preview.
Match the word to its meaning
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Type 1 and type 2
flowchart TB
subgraph T1["Type 1: runs on the hardware"]
hw1["Hardware"] --> hy1["Hypervisor"] --> g1["Guest 1"]
hy1 --> g2["Guest 2"]
end
subgraph T2["Type 2: runs on an operating system"]
hw2["Hardware"] --> os2["Host operating system"] --> hy2["Hypervisor program"] --> g3["Guest 3"]
hy2 --> g4["Guest 4"]
end
A whole network can be virtual
A virtual machine can be a client, such as a virtual PC for a student. It can also be a server, such as a web server.
The network parts can be virtual too. A virtual switch joins virtual machines together. A virtual router joins virtual networks. So a whole network, with computers, switch and router, can live inside one real computer.
Type 1 and type 2 compared
| Type 1 (no operating system below it) | Type 2 (hosted) | |
|---|---|---|
| Runs on | Directly on the hardware | On a normal operating system |
| Speed | Faster: fewer layers | Slower: more layers |
| Used for | Data centres and servers | Laptops, learning and testing |
| Example | A server in a data centre | A student laptop |
The cells students fill in are left blank in this preview.
Quick check
Have a go
Quick check
4 questionsExtra: Real hypervisors
| Type 1 (bare metal) | Type 2 (hosted) |
|---|---|
| KVM, Xen, Hyper-V, VMware ESXi | VirtualBox, VMware Workstation, Parallels |
The cells students fill in are left blank in this preview.
Extra: Ask this lab what it is
systemd-detect-virtA command for the lesson’s lab terminal. It is shown here and not run.
Extra: How many virtual CPUs?
nprocA command for the lesson’s lab terminal. It is shown here and not run.
Extra: How much memory does it have?
free -m | head -2A command for the lesson’s lab terminal. It is shown here and not run.
Extra: You are inside a virtual machine
Note
The lab you are using is a virtual machine. The first command named the hypervisor technology that this lab runs on. The numbers you saw are the small share of CPU and memory the host gave to this guest.
Seven key features
| Feature | What it means | Example |
|---|---|---|
| Increased security | Risky work stays inside the virtual machine | Open a suspicious file in a VM |
| Managed execution | The hypervisor controls and can pause, save or move a VM | Pause a VM and take a snapshot |
| Sharing | Many VMs share the parts of one real computer | Ten VMs on one server |
| Aggregation | Many real machines are joined and shown as one big shared amount (a pool) | A group of hosts that gives one big pool of memory |
| Emulation | A VM can act like different hardware or another system | Run an old program on a new computer |
| Isolation | A problem in one VM does not reach the others | One VM crashes, the other VMs keep working |
| Portability | A VM is a set of files, so you can copy or move it | Move a VM to a new host |
The cells students fill in are left blank in this preview.
Which feature is it?
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Try it: sharing one host
# A host has 8 CPUs and 16 GB of memory. Each VM takes a share.
cpus_left = 8
gb_left = 16
names = ["web", "mail", "files"]
cpus = [2, 2, 2]
gbs = [4, 4, 8]
for i in range(3):
cpus_left = cpus_left - cpus[i]
gb_left = gb_left - gbs[i]
print(names[i], "started. Left:", cpus_left, "CPUs and", gb_left, "GB")
# Add a fourth VM: put "games" in names, 2 in cpus, 4 in gbs.
# Change range(3) to range(4) and run it. Does it fit?
Make a free account to save your work and track your progress.
Your turn: will they fit?
A host has some CPUs and some gigabytes of memory. Each virtual machine needs some CPUs and some memory.
- Write can_host(vm_cpus, vm_gb, host_cpus, host_gb). The first two are lists, one number for each virtual machine.
- Add up the CPUs and the memory of all the virtual machines.
- Give back True if they all fit on the host. Give back False if not. Exactly full is fine.
Press Run Tests to check.
def can_host(vm_cpus, vm_gb, host_cpus, host_gb):
# vm_cpus is a list: the CPUs each virtual machine needs.
# vm_gb is a list: the gigabytes of memory each virtual machine needs.
# Give back True if the host has enough CPUs and enough memory for all of them together.
return False
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go