Table of Contents
Why Install Linux in a Virtual Machine?
Installing Linux in a virtual machine (VM) lets you:
- Try Linux safely without touching your main system or disk layout
- Run multiple Linux distributions side by side
- Take snapshots and roll back if something goes wrong
- Practice administration tasks in an isolated lab
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:
- VirtualBox (Windows, macOS, Linux)
- Free and beginner‑friendly
- Great for learning and basic labs
- VMware Workstation Player (Windows, Linux)
- Free for personal use
- Slightly better performance and integration in some cases
- GNOME Boxes / Virt-Manager (KVM/QEMU) (Linux hosts)
- Use built‑in Linux virtualization
- Better performance and closer to “real server” setups
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:
- CPU: 2 physical cores (4 threads recommended)
- RAM:
- Host: at least 8 GB (16 GB strongly recommended)
- VM: 2–4 GB for a desktop distribution; 1–2 GB for a minimal/server install
- Disk space:
- Reserve at least 25–30 GB for the VM’s virtual disk
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:
- Intel: VT‑x (sometimes called Intel Virtualization Technology)
- AMD: AMD‑V (SVM)
If your VM is slow or the hypervisor says “hardware virtualization not available,” you might need to:
- Reboot into your BIOS/UEFI firmware.
- Look for options like:
Intel (R) Virtualization TechnologySVM ModeVirtualization- 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:
- Visit the distribution’s official website (for example, Ubuntu, Fedora, Debian).
- Download the appropriate ISO:
- Use a 64‑bit (x86_64) version.
- For desktops, choose the standard desktop/live image.
- For this chapter, we’ll speak generically of “the ISO”; the details of choosing a distribution are covered elsewhere.
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
- Open VirtualBox.
- Click New.
- 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)) - Click Next.
2. Allocate Memory
When prompted for memory size:
- For a desktop install:
- 2048 MB (2 GB) minimum
- 4096 MB (4 GB) more comfortable
- Make sure you leave enough RAM for your host OS. If your host has 8 GB, giving 4 GB to the VM is usually okay if you don’t run heavy applications on the host at the same time.
3. Create a Virtual Disk
- Choose Create a virtual hard disk now.
- Disk type: VDI (VirtualBox Disk Image) is fine.
- 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.
- 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
- Select your new VM and click Settings.
- Go to Storage.
- Under Controller: IDE or SATA, click the empty optical drive icon.
- Click the disc icon on the right → Choose a disk file….
- Select your downloaded Linux ISO.
- 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
- In VirtualBox, highlight the VM and click Start.
- A new window will open: this is your VM console.
2. Choose Boot Options
You’ll usually see a menu similar to:
Try or Install <Distribution>Install <Distribution>Try without installing
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:
- Disk selection: you will see only the VM’s virtual disk (e.g.
/dev/sdawith the size you configured), not your real host disk. This makes it much safer—you won’t affect the host. - Partitioning: you can generally accept guided / automatic partitioning and use the entire virtual disk. The VM is isolated from other data.
- Bootloader: installing GRUB to the default location is fine; it affects only the VM’s virtual disk.
Follow the distribution’s normal installation questions:
- Language, keyboard, time zone
- User account and password
- Desktop/server selection if applicable
- Optional software
When the installer finishes, it will prompt you to reboot.
4. Ejecting the ISO After Install
After the first reboot:
- Some installers eject the virtual ISO automatically.
- If you keep booting back into the installer, manually:
- Shut down the VM.
- Open Settings → Storage.
- Click the optical drive, then click the disc icon → Remove disk from virtual drive.
- Start the VM again; it should boot from the virtual hard disk into your new Linux system.
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):
- Processors:
- 1–2 virtual CPUs (vCPUs) is usually enough at first.
- Don’t allocate more than half of your physical cores to a single VM.
- Acceleration: ensure hardware virtualization (VT‑x/AMD‑V) is enabled in the hypervisor.
These settings help the VM feel responsive without starving the host.
Display and Resolution
Increase video memory and enable enhancements:
- In Display:
- Video Memory: raise to 64–128 MB or more if the hypervisor allows.
- Enable 3D acceleration (if supported and stable on your host).
- Inside the guest OS, you can change the display resolution as usual.
Shared Clipboard and Drag‑and‑Drop
Hypervisors often support:
- Shared clipboard: copy/paste text between host and guest.
- Drag‑and‑drop: drag files between host and guest windows.
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
- Start the Linux VM and log in.
- In the VirtualBox window menu, choose:
- Devices → Insert Guest Additions CD image…
- 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*). - Install required build tools and kernel headers (package details depend on the distribution).
- Run the guest additions installer script, usually:
sudo sh /media/<username>/VBOXADDITIONS*/VBoxLinuxAdditions.run- Reboot the VM.
After installation, you gain:
- Auto‑resize guest display when you resize the VM window
- Better graphics performance
- Shared clipboard
- Shared folders support
VMware Tools / Open VM Tools
On VMware:
- For many modern distributions, installing
open-vm-toolsfrom your package manager is enough. - Some hypervisors provide a menu option like Install VMware Tools that mounts an ISO with the tools.
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
- Shut down the VM.
- 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.
- 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 -hYou 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:
- Right after a clean OS install
- Before installing or testing new software
- Before system upgrades
Using Snapshots (VirtualBox Example)
- Shut down or pause the VM (some hypervisors support live snapshots).
- In VirtualBox, select the VM and open the Snapshots view.
- Click Take and give it a meaningful name (e.g.
Fresh install). - 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:
- NAT (default):
- VM can access the internet through the host.
- Other machines on your LAN cannot directly access the VM.
- Bridged:
- VM appears as another device on your physical network with its own IP address.
- Useful for learning server scenarios (SSH from other devices, etc.).
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:
- Safety: installing in a VM does not touch your real disk or bootloader.
- Performance: VM is slightly slower and graphics may be less smooth, depending on host hardware and guest additions.
- Hardware access: advanced hardware (GPUs, USB devices) might need specific pass‑through features and may not behave exactly like on bare metal.
- Portability: you can move a VM by copying its disk and configuration files to another host.
Because of that, VMs are ideal for learning, experimentation, and building small labs.
Troubleshooting Common VM Installation Issues
VM Hangs or Is Very Slow
- Check that hardware virtualization (VT‑x/AMD‑V) is enabled in BIOS/UEFI.
- Reduce VM RAM if you’ve allocated too much and the host is swapping heavily.
- Lower desktop effects or use a lighter distribution for low‑spec hosts.
“No Bootable Medium Found” Error
- The ISO is not attached correctly as an optical drive.
- Fix:
- Power off the VM.
- Reattach the ISO in Storage → Optical Drive.
- Start again.
Guest Window Is Tiny / Resolution Is Limited
- Install guest additions or tools.
- Increase video memory in the VM’s Display settings.
- Reboot the guest OS after changes.
No Network Connectivity
- Verify the VM’s network mode (NAT is simplest for internet access).
- Check the guest’s network status (e.g. the network manager icon or
ip a). - If NAT is used and host has a working internet connection, the VM should normally have one as well.
Practice Ideas
Once your Linux VM is installed:
- Take a snapshot of the clean install.
- Practice:
- Updating the system inside the VM
- Installing and removing software
- Creating and deleting users
- Editing files and using the shell
Because the VM is isolated and restorable, you can experiment freely without fear of breaking your main computer.