Debian
This activity puts into practice the concepts from the Virtualization and Virtual Machines lecture. You will install a hypervisor, configure a Debian guest, run the snapshot safety-net workflow end to end, and observe how NAT and host-only networking modes differ in practice. By the end you will have a running VM you can control, break, and recover from in seconds.
What You Will Need
Section titled “What You Will Need”- A laptop with at least 8 GB of RAM and 20 GB of free disk space
- Administrator access to your laptop
- VirtualBox installed before class: download the installer and Extension Pack from virtualbox.org/wiki/Downloads
- Debian 12 netinstall ISO downloaded before class:
- Apple Silicon (ARM):
debian-12.x.x-arm64-netinst.isofrom cdimage.debian.org/debian-cd/current/arm64/iso-cd/ - Intel/Windows/Linux (x86-64):
debian-12.x.x-amd64-netinst.isofrom cdimage.debian.org/debian-cd/current/amd64/iso-cd/
- Apple Silicon (ARM):
Set Up the Virtual Machine
Section titled “Set Up the Virtual Machine”Install a Hypervisor
Section titled “Install a Hypervisor”A hypervisor is the software layer that creates and manages virtual machines on your laptop. Without it, there is no way to run a second operating system alongside your host OS. We will use a Type-2 (hosted) hypervisor, meaning it runs as a regular application on top of your existing operating system. We will use VirtualBox, which runs on macOS, Windows, and Linux.
- Download VirtualBox from virtualbox.org and install it.
- Also install the VirtualBox Extension Pack from the same page (enables USB 3.0 and other features).
- Open VirtualBox. You do not need to create a VM yet.
Download a Guest OS ISO
Section titled “Download a Guest OS ISO”An ISO file is a disk image: a single file that contains the exact contents of a bootable installation disc. The hypervisor can present this file to the VM as if it were a physical DVD drive, so the VM boots the installer without any physical media. We will use the Debian 12 (Bookworm) server netinstall ISO. Debian installs quickly, runs with a low memory footprint, and is available for both ARM and x86-64.
Download the arm64 netinstall ISO from cdimage.debian.org.
Look for a filename like debian-12.x.x-arm64-netinst.iso.
Download the amd64 netinstall ISO from cdimage.debian.org.
Look for a filename like debian-12.x.x-amd64-netinst.iso.
Create the Virtual Machine
Section titled “Create the Virtual Machine”Before starting the installer, we define the VM’s virtual hardware: how many vCPUs, how much RAM, and how large a virtual disk. These choices shape the VM’s behavior for the rest of the activity. The goal is to start conservative (not generous) because it is easy to increase resources later and because over-allocating on a laptop starves your host OS.
- Click New.
- Name:
debian-lab. Type: Linux. Version: Debian (64-bit) on Intel/Windows/Linux, or Debian (arm64) on Apple Silicon. - Hardware:
- Memory: 1024 MB
- Number of CPUs: 2
- Disk Size: 20 GB (you can use less but partitioning might be finicky for this specific activity)
- Use EFI
- After the VM is created, open Settings > Network > Adapter 1 and set Adapter Type to Paravirtualized Network (virtio-net). VirtualBox defaults to an emulated Intel NIC; VirtIO gives you a paravirtualized network adapter instead.
Install Debian
Section titled “Install Debian”Starting the VM boots the Debian installer from the ISO, exactly as if you had inserted a DVD into a real machine. The VM window becomes the VM’s virtual monitor: it shows only what the virtual machine is outputting. Your laptop’s own desktop continues running normally behind it.
-
Start the VM. The Debian boot menu appears in the VM window. Select Install to use the text-mode installer.
-
Follow the installer prompts:
- Language: English
- Location: United States
- Keyboard: American English (or whatever matches your physical keyboard)
- Hostname:
debian-lab - Domain name: leave blank
- Root password: set one you will remember
- New user: create a regular account (you can use your ONID username, e.g.,
ulbrical) with a password - Timezone: Pacific (or your local timezone)
- Partitioning: Guided - use entire disk, then All files in one partition
- Package manager mirror: United States - debian.osuosl.com
- Software selection: uncheck everything except SSH server and standard system utilities
The software selection step is significant. Deselecting the desktop environment means the installed system boots to a text prompt with no graphical interface. This is a deliberate choice that reflects real server practice: a GUI consumes memory, installs more software (more attack surface), and is simply unnecessary on a machine you will manage remotely.
-
Let the installer finish. It downloads packages from the internet during installation (5-15 minutes depending on network speed).
-
When prompted, eject the ISO and reboot.
Using the VM’s Terminal
Section titled “Using the VM’s Terminal”After reboot, the VM window shows a plain text login prompt: no desktop, no mouse cursor. This is the virtual console: the equivalent of a physical keyboard and monitor directly connected to a server. Type your username and press Enter, then enter your password (it will not echo to the screen; this is normal).
Everything in the sections below is typed into this console. The VM’s terminal behaves exactly like any Linux terminal: commands you type run inside the VM, not on your laptop. Your host OS is completely unaffected by anything you do here. This isolation is the whole point of a VM.
Verify Paravirtualized Drivers
Section titled “Verify Paravirtualized Drivers”The hypervisor can expose virtual hardware to the guest in two ways: fully emulated (slower, universally compatible) or paravirtualized (faster, requires a cooperative driver in the guest). Here we check which type is active for storage and networking, because the difference is measurable.
-
Check which storage devices the kernel sees:
Terminal window lsblk -d -o NAME,TYPE,TRANlsblklists block devices. The-dflag shows disks only (no partitions), and-o NAME,TYPE,TRANselects name, type, and transport. You will see something like:NAME TYPE TRANsda disksr0 romThe disk appears as
sdabecause VirtualBox uses a VirtIO SCSI controller, which uses SCSI device naming. The TRAN column is empty becauselsblkdoes not report a transport for virtio. -
Confirm the VirtIO controller is active by checking the PCI device list:
Terminal window lspci | grep -i virtioYou should see lines containing
Virtio SCSIfor storage andVirtio networkfor networking. -
Install
ethtoolto query the network driver. On Debian,sudois not installed by default, so switch to root first:Terminal window su -apt updateapt install ethtoolexit -
Find your main network interface name:
Terminal window ip link showYou will see at least two interfaces:
lo(loopback) and your main interface, named something likeenp0s3,eth0, orens3. Note the name. -
Check which driver is managing the network interface (substitute your interface name):
Terminal window ethtool -i enp0s3 | grep driverExpected output:
driver: virtio_net. This confirms paravirtualized networking is active. If you sawe1000orpcnet32, it would indicate a fully-emulated NIC.
Collect Baseline Metrics
Section titled “Collect Baseline Metrics”Before making any changes to a system, record what “normal” looks like. This baseline is your reference point: if something feels slow later, you can compare current numbers to these.
-
Sample the CPU idle percentage:
Terminal window top -b -n 3 | grep "Cpu(s)" | tail -1top -b -n 3runs three samples in batch mode and exits. Each sample produces aCpu(s)line showing percentages for user, system, and idle time. Taking the last sample withtail -1avoids the startup spike. A freshly booted VM should show idle above 90%. -
Check memory usage:
Terminal window free -hThe key column is available: the kernel’s estimate of memory realistically free for new processes, including cache that would be released if needed. “Available” is almost always lower than “total” because the kernel uses free RAM for disk caching. This is normal; unused RAM is wasted RAM.
-
Check disk usage on the root filesystem:
Terminal window df -h /The
Use%column is what to watch over time. On a freshly installed Debian system it should be well under 20%. -
Check uptime and load average:
Terminal window uptimeuptimereports three load average figures (1-minute, 5-minute, 15-minute): a rolling count of processes waiting to run. On a 2-vCPU VM, a sustained load average above 2.0 indicates the CPU is saturated.Record all four values. They give you a baseline to compare against after you start running services.
The Snapshot Safety-Net Workflow
Section titled “The Snapshot Safety-Net Workflow”Before making any risky change to a running system, a snapshot gives you a guaranteed rollback path. Rather than spending time carefully reversing each change if something goes wrong, you revert the entire disk to the pre-change state in seconds. This part runs that workflow end-to-end so the steps are instinctive before you need them in a real scenario.
Confirm a Healthy Baseline
Section titled “Confirm a Healthy Baseline”Log in to the VM and verify the SSH service and disk state are clean before creating the snapshot. Taking a snapshot of a broken system is not useful.
-
Verify SSH is running and the disk has free space:
Terminal window systemctl status sshdf -h /Both should show normal output: SSH active and running, root filesystem with free space. If SSH shows failed, resolve it before continuing.
Take a Pre-Change Snapshot
Section titled “Take a Pre-Change Snapshot”- With the VM selected, open Snapshots, right click on “Current State” and click “Take…”.
- Name it
pre-change-1and click OK.
Make a Destructive Change
Section titled “Make a Destructive Change”We will simulate a common real-world mistake: a typo in a configuration file that breaks a service. Here we corrupt the SSH config with an invalid port value.
-
Append a bad config line and reload the service:
Terminal window su -sh -c 'echo "Port INVALID_VALUE" >> /etc/ssh/sshd_config'systemctl reload sshexit -
Verify the damage:
Terminal window systemctl status sshsshd -Tsystemctl status sshshows the service still active (running) but with the reload marked as failed.sshdkeeps the existing process alive when a reload fails so active connections are not dropped.sshd -Truns in test mode, validating the config without starting a daemon. You should see output likeBadly formatted port number.
Attempt an In-Place Fix (and Give Up)
Section titled “Attempt an In-Place Fix (and Give Up)”-
Look at the end of the SSH config:
Terminal window tail -10 /etc/ssh/sshd_configYou can see the
Port INVALID_VALUEline at the end. In this simple case the culprit is obvious. In a real incident the bad line might be buried in a 200-line config that was auto-generated by a deployment script, or the problem might be an interaction between two valid-looking settings. This is the decision point: keep debugging, or spend five seconds reverting to the confirmed-working state.
Revert the Snapshot
Section titled “Revert the Snapshot”Shut down the VM gracefully before reverting (e.g., shutdown now), since most hypervisors require the VM to be powered off to restore a snapshot.
Revert to pre-change-1:
- Open the Snapshots panel for the VM.
- Right-click
pre-change-1and choose Restore. - Uncheck Create snapshot of current state and click Restore.
Start the VM and verify recovery:
-
Confirm everything is clean:
Terminal window systemctl status sshsshd -Ttail -5 /etc/ssh/sshd_configAll three should be clean: SSH active, no config error, no
INVALID_VALUEline.
Delete the Snapshot
Section titled “Delete the Snapshot”Once recovery is confirmed and you are satisfied the system is working, delete the snapshot:
- Open the Snapshots panel.
- Right-click
pre-change-1and choose Delete Snapshot.
Deleting a snapshot merges the delta file back into the base image and removes the extra layer. Snapshots are meant to be short-lived: the longer you keep one, the larger the delta grows, and the more layers the hypervisor must traverse on every disk read.
Networking Modes
Section titled “Networking Modes”The networking mode you assign to a VM determines what it can reach and what can reach it. This matters immediately: if you configure a VM to host a service, the networking mode decides whether other machines on your network can connect. This part lets you observe the practical difference between NAT and host-only directly.
Observe NAT Behavior
Section titled “Observe NAT Behavior”Your VM currently uses NAT. In NAT mode, the hypervisor acts like a router: the VM gets a private IP address on a virtual network, and the hypervisor forwards outbound traffic on the VM’s behalf using the host’s real IP address. This means the VM looks like the host to the outside world.
-
Check the VM’s IP address:
Terminal window ip addr showip addr showlists all network interfaces with their assigned addresses. Look for aninetline on your non-loopback interface. The address is typically10.0.2.15on VirtualBox. Note that this is a private address in a virtual subnet managed entirely by the hypervisor. -
From your laptop’s terminal (not inside the VM), try to ping the VM:
Terminal window ping -c 3 <vm-ip-address>This will time out. The VM can initiate connections outward, but nothing outside the hypervisor’s virtual network can initiate a connection to the VM. The hypervisor has no port-forwarding rule telling it where to send incoming packets addressed to the VM.
-
Confirm the VM still has outbound internet access; run this inside the VM:
Terminal window ping -c 3 debian.orgThis should succeed: the VM can reach out through the hypervisor’s NAT, even though the reverse direction is blocked.
Switch to Host-Only Networking
Section titled “Switch to Host-Only Networking”Host-only creates a private virtual network that exists only between the host and its guests. There is no connection to the physical network or the internet; the hypervisor does not perform NAT. This mode is useful for lab setups where you want VMs to communicate with each other and with your laptop, but you do not want them reachable from outside.
-
Power off the VM:
Terminal window shutdown now -
Change the network adapter to host-only:
- In the main VirtualBox Manager window, open the Network tab (separate from the VM) and click Create to add a host-only network if none exists.
- Open your VM Settings > Network > Adapter 1.
- Change Attached to from NAT to Host-only Network and select the network you just created.
- Click OK and start the VM.
-
Check the new IP address inside the VM:
Terminal window ip addr showThe address will be on a different subnet than NAT, typically
192.168.x.xfor host-only. -
From your laptop, ping the VM:
Terminal window ping -c 3 <new-vm-ip>This should succeed. Your laptop and the VM are on the same virtual host-only network.
-
From inside the VM, test internet access:
Terminal window ping -c 3 debian.orgThis will fail. The host-only network has no default gateway pointing to the internet; traffic has nowhere to go beyond the host. You can test the host’s IP on the host-only network to confirm the VM can still reach the host:
Terminal window ping -c 3 <host-only-ip-of-host>That IP address is typically the gateway for the host-only network, and it should respond to pings from the VM.
Wrap-Up
Section titled “Wrap-Up”Before moving on, let’s have a little fun:
-
Install cowsay and fortune:
Terminal window su -apt install cowsay fortuneexit -
Run them together:
Terminal window fortune | cowsay
Going Further
Section titled “Going Further”- Work through the Vagrant Quick Start to see how Vagrant defines VM configuration in code rather than through a GUI. Vagrantfiles are versionable and shareable, which solves the “works on my machine” problem for development environments.
- Read VirtualBox networking modes in the official manual for the full picture of NAT, Host-only, Bridged, and Internal networking.
- Try creating a second VM and connecting the two using an Internal network adapter so they can communicate without touching the host or the internet.