A cloud machine instead of a laptop
Video 016 of 140 in Virtualization Foundations, in the unit “Setting up your lab machine”. 3:24, with English and Hindi audio.
Some learners do not have a laptop that suits the lab. A rented cloud machine can be the lab host instead, if it allows nested virtualization. Nesting means a hypervisor runs inside a virtual machine. This article explains what that adds to the stack, what it costs in speed and money, how to choose a machine, and how to check that nesting is on.
What you will learn
- Nested virtualization runs a hypervisor inside a virtual machine, so your lab runs one layer deeper.
- The cloud machine must allow nesting, and the setting must be switched on.
- Nesting adds a layer, so lab machines run more slowly than on a good laptop.
- A rented machine charges by the hour, so stop it when you finish a session.
What nested virtualization adds to the stack
A hypervisor is the program that runs virtual machines. Normally it runs directly on real hardware. Nested virtualization means a hypervisor runs inside a virtual machine, and that virtual machine itself runs on the cloud's hardware.
- At the bottom is the provider's physical server, with a real processor, memory and disks.
- Above it is your cloud virtual machine, running KVM. This rented machine becomes the lab host.
- On top are the practice machines you create inside the lab host.
That is one layer more than a laptop. Each layer adds a little work, so the practice machines run more slowly.
How to choose a cloud machine for the lab
- Choose an Intel or AMD machine type. The lab packages are built for those processors.
- Choose a machine family that allows nested virtualization. Some providers need you to switch it on when you create the machine.
- Log in with an SSH key, and open only the ports you need. A machine on the internet is probed quickly.
Note: You pay for every hour the cloud machine runs. Stop it when you finish a session, so that it does not charge you while idle.
How to check that nesting is on
Start inside the cloud machine. The first command shows whether the processor's virtualization help is visible to this machine. Inside a cloud virtual machine, you should see VT-x or AMD-V.
lscpu | grep VirtualizationIf the help is missing here, the provider has not passed it through. No setting inside Ubuntu can fix that. If the help is visible, check that the KVM device file exists. It appears only when KVM can run on this machine.
ls /dev/kvmLast, read the nested setting of the Intel KVM module. The answer Y means nesting is on. On an AMD machine, read the file for the kvm_amd module instead.
cat /sys/module/kvm_intel/parameters/nestedNote: If nesting is off, change the machine's setting in the provider's console, then start the machine again.
A laptop or a cloud machine: how to decide
- Cost: a laptop you already own costs nothing extra. A cloud machine costs money by the hour.
- Speed: a laptop is usually faster for this work, because a cloud machine adds one more layer.
- Setup: on a laptop you turn virtualization on in the firmware. In the cloud you turn nested virtualization on in the provider's settings.
A cloud machine still works when no suitable laptop exists. Choose it for that reason, and accept the slower speed.
Check that nesting is on
Run these three commands inside the cloud machine, not on your own computer. Each one checks a different layer of the nested stack.
Check that the virtualization help is visible inside the cloud machine. If nothing shows, the provider has not passed it through.
lscpu | grep VirtualizationWhat you should see: You should see VT-x or AMD-V. No line means the provider has not passed the help through.
Check that the KVM device file exists, which shows that KVM can start on this machine.
ls /dev/kvmWhat you should see: The device file appears. It is missing when KVM cannot run on this machine.
Read the nested setting of the Intel KVM module. On an AMD machine, read the kvm_amd file instead.
cat /sys/module/kvm_intel/parameters/nestedWhat you should see: The answer Y means nesting is on. Any other answer means you must change the setting in the provider's console.
Terms
- Nested virtualization
- Running a hypervisor inside a virtual machine, so that virtual machines can run inside it.
- Hypervisor
- The program that runs virtual machines and shares a computer among them.
- SSH key
- A pair of files that lets you log in to a machine securely, without typing a password.
Check yourself
What does nested virtualization add to the stack?
One more layer: a hypervisor runs inside a virtual machine, which itself runs on the provider's physical server.
What does a Y from the nested setting mean?
Nested virtualization is switched on, so a hypervisor can run inside this cloud machine.
Why should you stop a rented cloud machine when you finish?
The machine charges for every hour it runs, so stopping it saves money while you are not using it.
Previous: Saving and restoring your lab's state. Next: What a CPU does, step by step.