Running Linux as a virtualization guest

Running Linux as a guest: how a virtual machine differs from a container, what has to be made unique when a system image is cloned, and what cloud-init is for.

Lesson 6 of 6 in objective 102. Linux installation and package management, part of LPIC-1 Exam 101-500.

Two kinds of guest, and the isolation is not the same. Virtual machine — Kernel: Its own; Starts in: Seconds — a full boot; A different OS?: Yes; Isolated by: Virtualized hardware. Container — Kernel: Shares the host kernel; Starts in: Milliseconds; A different OS?: No; Isolated by: Namespaces and cgroups Virtual machine Container Kernel Its own Shares the host kernel Starts in Seconds — a full boot Milliseconds A different OS? Yes No Isolated by Virtualized hardware Namespaces and cgroups
Two kinds of guest, and the isolation is not the same.

Virtual machines and containers are not the same isolation

A virtual machine runs its own kernel on virtualized hardware, so it can be a completely different operating system from its host, and it pays for that with the overhead of a second kernel and a full boot. A container shares the host kernel and is isolated by namespaces and cgroups, so it starts in milliseconds and cannot run a different kernel or a different operating system family. Guest drivers — virtio disks and network cards, or the vendor's guest additions — exist to give a virtual machine near-native speed by letting it talk to the hypervisor directly rather than pretending to drive emulated hardware.

Guest integration comes in two layers that are easy to run together, and separating them is what the question is for. Paravirtualized drivers move DATA: virtio disks and network cards, and their equivalents on other platforms. A guest AGENT takes ORDERS — it is a daemon inside the guest listening on a channel to the hypervisor, and it does the things no driver can: accepting a request to shut down cleanly rather than having the virtual power cord pulled, freezing and then thawing the filesystems so a snapshot is taken at a consistent moment, and reporting the guest's addresses back to the host. Each platform ships its own: qemu-guest-agent for QEMU and KVM, open-vm-tools for VMware, hyperv-daemons for Hyper-V. Without one the host can still stop the machine; it simply cannot ask.

What must be unique after cloning

Cloning a prepared system image is the normal way to create guests, and the things that must not be duplicated are the ones the exam asks about. SSH host keys in /etc/ssh must be regenerated, or every clone presents the same identity and a client cannot tell them apart. The D-Bus machine id in /etc/machine-id must be reset, since systemd and the journal key on it. Network configuration must not pin a MAC address or a static IP inherited from the template, and the hostname has to be set.

cloud-init is the standard mechanism for doing exactly that at first boot: it reads metadata supplied by the cloud platform — hostname, SSH keys, users, an arbitrary user-data script — and applies it before the machine is handed over. That is why an image can be generic and the instance made from it specific.

What a clone inherits, and what first boot has to make unique. In order: A prepared image is cloned (the normal way to create guests), then Every clone presents one identity (same host keys, same machine id), then cloud-init runs at first boot (reads the metadata the platform supplies), then Host keys and /etc/machine-id reset (hostname set, no MAC or IP from the template), then Handed over as an instance (generic image, specific machine). A prepared image is cloned the normal way to create guests Every clone presents one identity same host keys, same machine id cloud-init runs at first boot reads the metadata the platform supplies Host keys and /etc/machine-id reset hostname set, no MAC or IP from the template Handed over as an instance generic image, specific machine
What a clone inherits, and what first boot has to make unique.

Worth carrying in

virtio
Paravirtualized disk and network drivers; the guest talks to the hypervisor directly.
/etc/machine-id
The D-Bus machine id. Must be regenerated on a clone.
SSH host keys
In /etc/ssh. Duplicated across clones means duplicated identity.
cloud-init
Applies platform metadata — hostname, keys, users, user-data — at first boot.
container
Shares the host kernel; isolated by namespaces and cgroups.
qemu-guest-agent
The guest agent for QEMU and KVM: graceful shutdown, filesystem freeze for snapshots. open-vm-tools on VMware.

What the exam does with this

Objective
102. Linux installation and package management
Share of the exam
18.33% (the whole objective)
Questions in this lesson
6
Signed for by a person
0

Partly checked. None of the 6 questions here has been read against the cited source by a person. 6 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.

Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

Drill this lesson

A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.

Practise Running Linux as a virtualization guest

Questions in this lesson

Practise Running Linux as a virtualization guest

The rest of objective 102