I installed Debian 12 and CentOS Stream 9 VMs in VirtualBox with sensible partitioning, bridged networking, and guest additions. A clean base image cloned in minutes became the reproducible starting point for every later lab.

Objective & Context

A disposable VM is the safest place to learn. This lab builds both a Debian- and an RHEL-family base so commands can be tested across package managers, the substrate for the server-admin and KVM labs.

Learning Objectives

  • Create and register VirtualBox VMs entirely from the command line.
  • Attach ISO media and step through Debian and CentOS installers.
  • Verify a successful boot and identify the installed release.
  • Take and restore snapshots of a clean base system.
  • Compare Debian-family and RHEL-family defaults side by side.

Environment & Prerequisites

Prerequisites

  • VirtualBox 7.x installed with VT-x/AMD-V enabled in firmware.
  • Debian 12 and CentOS Stream 9 ISO images downloaded.
  • At least 4 GB RAM and 20 GB free disk for the guests.
  • A host OS that runs VirtualBox (Linux, macOS, or Windows).

Step-by-Step Execution

1. Create the VM disk from CLI

VBoxManage createvm --name debian12 --register && VBoxManage createmedium disk --filename debian12.vdi --size 20480

Expected output:

Virtual machine 'debian12' is created and registered.
Medium created. UUID: 8f3a2c1e-...
(debian12.vdi, 20 GB dynamically allocated)

What this teaches: VBoxManage createvm registers the VM definition; createmedium builds a dynamically allocated disk that grows with use instead of consuming 20 GB up front. The --size value is in megabytes.

1b. Attach storage and the installer ISO

VBoxManage storagectl debian12 --name SATA --add sata --controller IntelAhci
VBoxManage storageattach debian12 --storagectl SATA --port 0 --device 0 --type hdd --medium debian12.vdi
VBoxManage storageattach debian12 --storagectl SATA --port 1 --device 0 --type dvddrive --medium ~/iso/debian-12-amd64-netinst.iso
VBoxManage modifyvm debian12 --memory 2048 --cpus 2 --boot1 dvd --boot2 disk
VBoxManage startvm debian12 --type headless

Expected output:

Waiting for VM "debian12" to power on...
VM "debian12" has been successfully started.

What this teaches: A registered VM boots from nothing until you wire a storage controller, attach the VDI as the hard disk, and attach the ISO as a virtual DVD with boot order DVD first. Without the controller and attachments, the installer would report no bootable medium. The headless start keeps the lab scriptable; connect over VRDE or the GUI console to walk the installer.

2. Verify the install booted

cat /etc/os-release | head -2

Expected output:

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"

What this teaches: /etc/os-release is the standard distro identification file; PRETTY_NAME confirms which family you booted, which decides whether apt or dnf applies in later labs. Run this inside the guest after the installer finishes and the VM reboots from the virtual disk.

3. Snapshot the clean base

VBoxManage snapshot debian12 take clean-base

Expected output:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: 8f3a2c1e-4b5d-4c6e-8a7f-9b0c1d2e3f4a

What this teaches: Snapshots capture disk plus VM state; naming the clean base lets you revert any future experiment instantly, which is what makes a VM a safe lab sandbox. Snapshot the VM while powered off for the cleanest base image.

How It Works

VirtualBox is a type-2 hypervisor: it runs as an application on your host OS and uses CPU virtualization extensions (VT-x/AMD-V) to execute guest code nearly natively. The VDI disk is a file on your host that the guest sees as a real hard drive; dynamically allocated VDIs grow as the guest writes, trading a little speed for host disk savings.

Installing two families side by side is deliberate pedagogy. Debian 12 uses apt, predictable interface names, and a conservative release cadence; CentOS Stream 9 uses dnf, SELinux enforcing by default, and a rolling pre-RHEL stream. Labs later in the series assume you can translate commands between the two, and this is where that fluency starts.

Snapshots implement copy-on-write checkpoints: the base VDI becomes read-only and new writes go to a differencing image. Restoring discards the differencing image, returning the VM to the exact captured state in seconds. This undo button is why every destructive lab in the series starts from a snapshot.

Validation & Testing

Boot each VM, confirm networking reaches the internet, and clone from the snapshot to verify reproducibility. Pass criteria: both distros install cleanly, have working bridged networking, and a snapshot restores a pristine base.

Troubleshooting

SymptomLikely causeFix
VT-x/AMD-V is disabled errorVirtualization extensions are off in firmwareEnable Intel VT-x or AMD-V in BIOS/UEFI settings
Installer cannot see the virtual diskWrong storage controller type for the guestUse SATA for modern guests; IDE for very old ones
Guest is extremely slowToo little RAM/vCPU or no Guest AdditionsRaise allocation and install Guest Additions for paravirtual drivers
No network in the guestAdapter attached to the wrong network modeNAT gives outbound access; bridged gives a LAN address for SSH
Snapshot restore lost recent workRestore discards the differencing image by designTake a new snapshot before restoring when the current state might matter
CentOS installer hangs at network stepStream installer waiting on a mirrorCheck connectivity or pick a closer mirror during setup
Advanced: Troubleshooting
  • No 64-bit option: enable VT-x/AMD-V in the host BIOS.
  • No network: switch the adapter to bridged or confirm NAT DNS.
  • Slow VM: install Guest Additions and allocate more vCPU/RAM.

Key Results

  • Built reproducible Debian and CentOS base images.
  • Captured clean snapshots that clone in minutes.
  • Verified bridged networking on both distros.
  • Established a safe, disposable lab environment.

Key Takeaways

  • VBoxManage scripts the entire VM lifecycle reproducibly.
  • Dynamically allocated disks save host space.
  • /etc/os-release identifies the distro family reliably.
  • Snapshot the clean base before any experiment.
  • Debian versus RHEL differences start at the package manager and defaults.
  • NAT is the default safe NIC mode; bridged exposes the guest to your LAN.
  • Write down the guest additions steps for each family; they differ.

Practice Challenges

Challenge 1: Headless provision

Goal: create, install (unattended), and snapshot a Debian VM without ever opening the VirtualBox GUI.

Hint: VBoxManage unattended install plus modifyvm for VRDE.

Challenge 2: Family diff sheet

Goal: boot both VMs and document five concrete defaults that differ (package manager, firewall, SELinux, network config, default shell).

Hint: compare systemctl, sestatus, and /etc/os-release.