Kahibaro
Discord Login Register

1.3.4 Installing in a virtual machine

Why Install Linux in a Virtual Machine?

Installing Linux in a virtual machine (VM) lets you:

This chapter focuses only on installing Linux inside a VM. Creating a bootable USB, partitioning, and general installation steps are covered elsewhere; here we adapt those ideas to a virtualized environment.

Common Virtualization Options

There are many hypervisors (virtualization platforms). For a beginner, start with one of these:

On Windows or macOS, VirtualBox is usually the simplest first choice. On Linux, virt-manager or GNOME Boxes is very convenient if your distribution provides them.

Requirements and Planning

Before installing, make sure your computer and system are suitable.

Hardware Requirements

For a single beginner VM, a typical minimum is:

The host must be able to spare resources for the VM and still run your normal applications.

Virtualization Support (BIOS/UEFI)

Modern hypervisors rely on CPU virtualization features:

If your VM is slow or the hypervisor says “hardware virtualization not available,” you might need to:

  1. Reboot into your BIOS/UEFI firmware.
  2. Look for options like:
    • Intel (R) Virtualization Technology
    • SVM Mode
    • Virtualization
  3. Ensure they are Enabled, save, and reboot.

Getting the Installation ISO

You still need a Linux ISO file as if you were installing on real hardware:

The ISO will be attached to the VM like a virtual DVD.

Creating a New Virtual Machine (VirtualBox Example)

Details differ between hypervisors, but the overall steps are similar. Here’s the typical flow using VirtualBox; you can translate the ideas to VMware or others.

1. Create the VM

  1. Open VirtualBox.
  2. Click New.
  3. Enter:
    • Name: e.g. Ubuntu-Desktop
    • Machine Folder: where VM files will be stored
    • Type: Linux
    • Version: choose the closest match (e.g. Ubuntu (64-bit))
  4. Click Next.

2. Allocate Memory

When prompted for memory size:

3. Create a Virtual Disk

  1. Choose Create a virtual hard disk now.
  2. Disk type: VDI (VirtualBox Disk Image) is fine.
  3. Storage on physical hard disk:
    • Dynamically allocated: grows as needed up to a maximum size (recommended for most users).
    • Fixed size: slightly faster but uses full space immediately.
  4. Set the maximum size:
    • 25–30 GB for a general desktop system
    • More if you plan to store many files or install large applications

Click Create.

You’ve now defined a “virtual computer” with virtual RAM, CPU, and disk.

4. Attach the ISO

  1. Select your new VM and click Settings.
  2. Go to Storage.
  3. Under Controller: IDE or SATA, click the empty optical drive icon.
  4. Click the disc icon on the right → Choose a disk file….
  5. Select your downloaded Linux ISO.
  6. Ensure it is shown as the Optical Drive for the VM.

The VM will now “boot from” this virtual DVD on first start.

Booting the VM and Running the Installer

1. Start the VM

2. Choose Boot Options

You’ll usually see a menu similar to:

For GUI installers, pick Try or Install or directly Install. For server/minimal installers, you may see a simple text‑based menu.

3. Installer Inside a VM vs Real Hardware

Inside the VM, installation looks almost identical to installing on physical hardware. The key differences:

Follow the distribution’s normal installation questions:

When the installer finishes, it will prompt you to reboot.

4. Ejecting the ISO After Install

After the first reboot:

VM‑Specific Settings to Adjust

Once Linux is installed and booting from its virtual disk, fine‑tune the VM for a better experience.

CPU and Performance Settings

In the VM’s settings (before booting):

These settings help the VM feel responsive without starving the host.

Display and Resolution

Increase video memory and enable enhancements:

Shared Clipboard and Drag‑and‑Drop

Hypervisors often support:

These typically require guest additions or VMware Tools, described below.

Guest Additions / Tools

Guest additions are special drivers and utilities installed inside the VM to improve integration.

VirtualBox Guest Additions

  1. Start the Linux VM and log in.
  2. In the VirtualBox window menu, choose:
    • Devices → Insert Guest Additions CD image…
  3. A virtual CD is mounted inside the guest. On many distributions:
    • A window appears asking if you want to run the software.
    • If not, open a terminal and mount it manually (often under /media/<username>/VBOXADDITIONS*).
  4. Install required build tools and kernel headers (package details depend on the distribution).
  5. Run the guest additions installer script, usually:
   sudo sh /media/<username>/VBOXADDITIONS*/VBoxLinuxAdditions.run
  1. Reboot the VM.

After installation, you gain:

VMware Tools / Open VM Tools

On VMware:

Once installed, features are similar: better graphics, clipboard, time sync, etc.

Shared Folders Between Host and VM

Shared folders let you easily exchange files between host and guest without network setup.

VirtualBox Shared Folders

  1. Shut down the VM.
  2. In Settings → Shared Folders:
    • Click the add icon.
    • Choose a Folder Path on your host.
    • Set a Folder Name (this is how it appears inside the guest).
    • Tick Auto-mount and optionally Make Permanent.
  3. Boot the VM.

Inside Linux, the shared folder will typically be mounted under /media or /mnt (exact path depends on guest additions and distribution). Check with:

ls /media
# or
df -h

You can then use it like any other directory to move files between systems.

Other Hypervisors

VMware and KVM management tools offer similar shared folder features or use network shares. The principle is the same: configure on the host side, then access from the guest.

Taking Snapshots

Snapshots capture the VM’s current state (disk and sometimes memory), so you can revert if something breaks.

When to Take Snapshots

Good times to snapshot:

Using Snapshots (VirtualBox Example)

  1. Shut down or pause the VM (some hypervisors support live snapshots).
  2. In VirtualBox, select the VM and open the Snapshots view.
  3. Click Take and give it a meaningful name (e.g. Fresh install).
  4. Later, if needed, right‑click the snapshot and choose Restore.

Be aware that snapshots consume additional disk space, because changed data is stored separately.

Networking in a VM (Overview Only)

You’ll typically see at least one virtual network adapter in your VM. The most common modes for a beginner:

You can change this in the VM’s Network settings. Detailed network configuration inside Linux is covered elsewhere; from the VM’s perspective, the virtual NIC behaves like a regular network card.

Differences Between VM and Real Hardware Install

Most of the installation process is identical, but note these practical differences:

Because of that, VMs are ideal for learning, experimentation, and building small labs.

Troubleshooting Common VM Installation Issues

VM Hangs or Is Very Slow

“No Bootable Medium Found” Error

Guest Window Is Tiny / Resolution Is Limited

No Network Connectivity

Practice Ideas

Once your Linux VM is installed:

Because the VM is isolated and restorable, you can experiment freely without fear of breaking your main computer.

Views: 120

Comments

Please login to add a comment.

Don't have an account? Register now!