Read a sample: 1. Start With a Safe Storage Lab
Linux makes storage visible and manageable through a set of powerful tools. The same command line that can reveal a disk’s layout can also overwrite the information that makes its files accessible. A single incorrect device name can turn an ordinary administration task into a recovery problem.
The best place to learn is therefore not on a computer containing your only copy of important work. It is a disposable laboratory: a Linux virtual machine with a separate virtual disk that contains nothing you need to keep. In that environment, you can inspect storage, make mistakes, restore a checkpoint, and try again.
This chapter establishes that lab and a working habit that will matter throughout the book: identify the target, understand the action, and verify both before making a change. We will start with inspection rather than modification. You do not need to create a partition or format a filesystem yet.
A virtual machine, or VM, is a computer represented in software. It has its own operating system and virtual hardware, including one or more virtual disks. The VM runs on a host computer, but the two environments are not interchangeable: a command entered inside the VM ordinarily acts on what the guest operating system can see, while a command entered in a host terminal acts on the host.
For this book, use a lab with these components:
- A Linux VM that you can afford to rebuild.
- A system disk containing the VM’s installed operating system.
- A second, empty virtual disk used only for storage practice.
- A way to restore or recreate the VM and its practice disk.
- A user account that can obtain administrative privileges when needed.
A modest practice disk, such as 8 GiB, is sufficient for the introductory exercises. Choose a size that is clearly different from the VM’s system disk so that size provides one useful identifying clue. It is not, by itself, proof of identity.
The host computer needs enough available storage for the VM, the practice disk, and any snapshots or copies you create. Virtualization products handle disk allocation and snapshots differently, so consult the documentation for your chosen product before relying on its space estimates or recovery features.
Use a virtualization product with which you are comfortable, and install a mainstream Linux distribution in a new VM. A desktop or server installation can work; what matters is that you can open a terminal and access the VM’s configuration through the virtualization software.
During installation, create the ordinary virtual system disk required by the installer. Finish the installation, restart the VM, and sign in. Confirm that you know which window is the guest console and which applications belong to the host. If the virtualization product offers an option to connect physical disks or USB storage directly to the VM, leave it unused for this lab.
Avoid adding shared folders that contain valuable files unless you have a separate reason to use them and understand how the sharing is configured. A disposable guest can still have access to valuable host data through a shared folder, a network connection, or a passed-through device. “It is a VM” does not mean every resource visible to it is disposable.
Inside the guest, open a terminal and check that you are working in the environment you intended:
bash
hostname
pwd
The first command displays the guest’s configured hostname; the second shows the current directory. Neither proves that the environment is safe to modify, but both help you establish where you are. Consider giving the VM a recognizable name in the virtualization interface and a distinct hostname inside Linux. When multiple terminals are open, take a moment to confirm the active window before entering a command.
Shut down the guest using its normal shutdown procedure. In the virtualization product’s settings, add a new, empty virtual hard disk to the existing VM. Do not select an existing virtual disk file unless you have independently confirmed that it is disposable. Do not attach a physical disk.
Set the new disk to a distinctive capacity, such as 8 GiB, and attach it alongside—not in place of—the existing system disk. The exact menus and controller choices depend on the virtualization product. Record the disk’s configured capacity and, if the interface displays one, its virtual disk filename or other identifier. Keep this record outside the guest as well as in your lab notes.
Start the VM again. You now have two different perspectives on the same lab:
- The virtualization interface describes the virtual hardware attached to the guest.
- Linux reports the storage devices it detects inside the guest.
Both perspectives are useful. Neither should be reduced to “the second disk must be the one I want.” Device ordering can change, and a guest may expose additional devices depending on its configuration.
If you are using a cloud instance, a borrowed VM, or a machine managed by someone else, do not assume that attaching or modifying a disk is permitted or reversible. Build a lab under your control, or obtain clear authorization and a disposable environment before proceeding.
Before experimenting, decide how you will return to a known state. Depending on your virtualization product, you might create a VM snapshot or checkpoint, make a copy of the powered-off VM and its virtual disks, or plan to recreate the lab from the installation media.
A checkpoint is useful only if you…