1.3.4. Installing in a virtual machine
Table of Contents
Why Install Linux in a Virtual Machine
Installing Linux in a virtual machine lets you experiment safely inside a window on your existing system. The virtual machine behaves like a separate computer, but it is implemented in software. You can try different distributions, break things while learning, and delete everything with a few clicks, all without changing your main operating system.
Virtual machines are especially useful for beginners who are not yet ready to repartition disks, erase an existing system, or set up dual booting. They are also convenient for trying out multiple Linux environments side by side.
A virtual machine uses your existing hardware resources. If your computer is low on RAM or CPU power, running a virtual machine will feel slow. Do not assign all your RAM or CPU cores to the virtual machine, or your host system will become unstable.
Choosing Virtualization Software
To install Linux in a virtual machine, you need a hypervisor, which is the program that creates and runs virtual machines. On a typical desktop or laptop, you will most often use:
On Windows or macOS, beginners commonly start with VirtualBox or VMware Player / VMware Fusion. On Linux, you can also use VirtualBox, but many distributions provide tools built on KVM such as virt-manager.
When choosing, consider license, ease of installation, and whether there are convenient graphical tools. For basic learning, VirtualBox is usually sufficient and simple to begin with.
Preparing to Create the Virtual Machine
Before creating the virtual machine, you should have:
A Linux installation ISO file, which is the disk image of the installer. You get this by downloading an ISO from your chosen distribution.
A check of your hardware virtualization support. Most modern CPUs support virtualization. In many computers you must enable this feature in BIOS or UEFI settings. Look for settings named Intel VT-x, Intel Virtualization Technology, AMD-V, or similar. If virtualization is disabled, your hypervisor may run very slowly or refuse to start 64-bit guests.
On your host operating system, install your chosen hypervisor using its normal installer. Once installed, you usually get a graphical interface for creating and managing virtual machines.
Creating a New Virtual Machine
The exact appearance of the dialog varies among hypervisors, but the steps are conceptually similar. You define a new virtual machine by specifying a few fundamental properties.
You first choose the name and type. You can name the machine something descriptive, such as Ubuntu-Desktop or Debian-Test. You then select the operating system family as Linux and then pick the approximate version. This helps the hypervisor choose defaults, but it does not change the Linux installer itself.
You then allocate memory. This is a key decision. If your host has, for example, 8 GB of RAM, a common configuration is to give the virtual machine between 2 GB and 4 GB. Too little and Linux will feel sluggish. Too much and your host system may struggle.
A useful basic rule of thumb is:
$$\text{VM RAM} \le \frac{1}{2} \times \text{Host RAM}$$
but you should adjust according to what you will do and how much the host needs.
Next you choose CPUs. Many hypervisors let you assign virtual CPUs that map to host CPU cores or threads. For a typical dual core or quad core laptop, giving the virtual machine 1 or 2 virtual CPUs is usually enough. Avoid assigning all cores to the virtual machine.
Do not assign more CPU cores or more RAM to the virtual machine than your host can spare. Leaving some resources for the host is essential for a responsive system.
Creating a Virtual Disk
Every virtual machine needs its own virtual disk file. This file lives on your host filesystem, but Linux inside the virtual machine sees it as its own hard drive.
When you create the virtual machine, the hypervisor will ask whether you want to create a new virtual disk or use an existing one. For a first install, create a new virtual disk.
You then choose a size. For a simple desktop test system, a virtual disk of 20 GB to 40 GB is usually enough. If you plan to install many programs or keep large files, choose more.
Most hypervisors offer two kinds of virtual disks. One is dynamically allocated, where the file on your host grows as the guest uses more space. The other is preallocated, where the full size file is created immediately. Dynamically allocated disks save host disk space at first, but they can become fragmented over time. For beginners, dynamic allocation is usually fine.
You then select the virtual disk format, such as VDI, VMDK, or QCOW2, depending on the hypervisor. For basic local use, the default choice is acceptable. The format only matters if you plan to move the disk file between different virtualization systems.
Connecting the Installation ISO
Before you can install Linux inside the virtual machine, you must simulate inserting the installation media. Instead of a physical DVD or USB, you attach the ISO file to the virtual machine’s virtual optical drive.
In your hypervisor, you typically open the settings of the virtual machine, go to the storage or CD/DVD section, and select the ISO file as the virtual disk. From the point of view of the virtual machine, this is exactly like having a DVD with the installer inserted.
If you forget to attach the ISO as a virtual CD/DVD, the new virtual machine will often show a “No bootable medium” or similar error when you start it.
Once attached, configure the boot order so that the virtual optical drive comes before the virtual hard disk. This ensures the virtual machine boots from the installer ISO the first time.
Running the Installer inside the VM
With the ISO attached and the virtual machine defined, you start the virtual machine from your hypervisor’s interface. A new window opens, representing the screen of the virtual machine.
Inside this window, you follow the Linux distribution’s normal installer that you would also use on real hardware. The installer does not know that it is running in a virtual machine. It sees a virtual disk, virtual network card, and virtual display as if they were physical devices.
During the installation, when you reach the partitioning step, the installer will only see the virtual disk that you created, not your host disk. This makes installation much safer than installing directly on your hardware. You can follow the partitioning guidance that applies to normal installations, but you are working inside an isolated virtual disk file.
After the installer finishes copying files and configuring the system, it will usually ask you to reboot the virtual machine. At this point, it is important to remove or detach the ISO from the virtual drive, otherwise the virtual machine may boot the installer again instead of your new system.
Post Installation Adjustments in the VM
Once Linux boots from the virtual disk, you can log in and use it as a normal Linux system. However, there are a few virtual machine specific adjustments worth making.
Most hypervisors provide special guest tools. For example, VirtualBox has Guest Additions, VMware has VMware Tools, and KVM based systems can use packages like qemu-guest-agent. These tools improve integration between the host and guest. They usually provide:
Better graphics support and automatic screen resizing when you change the VM window size.
Improved mouse integration so you can move the cursor in and out of the VM window smoothly.
Clipboard sharing between host and guest.
Optional shared folders between host and guest for easy file transfer.
To install these tools, you typically mount a virtual CD from the hypervisor menu inside the running guest and follow the instructions. Some modern distributions already include integration packages or make them available through their package manager.
You can also configure networking. By default, many hypervisors use NAT networking, where the virtual machine shares the host’s connection. For beginner use, NAT is usually enough. Other modes, such as bridged networking or host only, affect how visible the virtual machine is on your local network and can be explored later.
Managing Resources and Snapshots
Over time, you may want to adjust how many resources the virtual machine uses. Most hypervisors let you change RAM, CPU count, and some other parameters while the VM is powered off. If your host system feels slow, you might reduce the RAM or CPUs allocated to the VM. If your guest feels slow and your host is comfortable, you might increase them.
Another important feature of virtual machines is snapshots. A snapshot captures the state of the virtual machine at a point in time, including disk state and sometimes memory. This is very helpful when you are learning. You can create a snapshot before making major changes or experiments, then revert to that snapshot if something goes wrong.
Relying only on snapshots is not a complete backup strategy, but snapshots are very useful for quickly undoing experimental changes inside a virtual machine.
Snapshots are specific to the hypervisor and usually cannot be moved easily between different virtualization systems. Use them mainly to manage risk inside a learning environment.
Benefits and Limitations of Learning in a VM
A virtual machine is excellent for trying commands, installing software, exploring different desktops, and learning system administration concepts. You can create multiple virtual machines with different distributions, experiment with networking between them, and practice installations without touching your real disks.
However, some things behave differently compared to real hardware. For example, direct hardware access, such as graphics drivers for high performance gaming, or power management on laptops, may not be fully representative. Performance in a VM is usually lower, especially for graphics intensive tasks.
Despite these limitations, for most beginners the virtual machine environment provides a safe, flexible, and forgiving way to become comfortable with Linux installation and basic use before moving on to real hardware or more complex setups.
Views: 0
Where to Move
Move chapter:
- ☰ 1. PART I — Linux Fundamentals (Beginner)
- ☰ 1.1. What Is Linux?
- ☰ 1.1.1. What is an operating system
- ☰ 1.1.2. History of Unix and Linux
- ☰ 1.1.3. The Linux kernel
- ☰ 1.1.4. GNU and the Free Software Foundation
- ☰ 1.1.5. Open source philosophy
- ☰ 1.1.6. Where Linux is used today
- ☰ 1.1.7. Desktop vs server vs embedded Linux
-
- ☰ 1.2. Choosing a Linux Distribution
- ☰ 1.2.1. What is a distribution?
- ☰ 1.2.2. Package formats (deb, rpm, pacman)
- ☰ 1.2.3. Popular distributions
- ☰ 1.2.3.1. Ubuntu
- ☰ 1.2.3.2. Debian
- ☰ 1.2.3.3. Fedora
- ☰ 1.2.3.4. Arch Linux
- ☰ 1.2.3.5. openSUSE
-
- ☰ 1.2.4. Rolling vs fixed release
- ☰ 1.2.5. Choosing the right distribution
-
- ☰ 1.3. Installing Linux
- ☰ 1.3.1. Creating a bootable USB
- ☰ 1.3.2. Installing on real hardware
- ☰ 1.3.3. Dual booting with Windows
- ☰ 1.3.4. Installing in a virtual machine
- ☰ 1.3.5. Partitioning
- ☰ 1.3.5.1. `/` (root)
- ☰ 1.3.5.2. `/home`
- ☰ 1.3.5.3. Swap
-
- ☰ 1.3.6. First-time setup
-
- ☰ 1.4. First Steps After Installation
- ☰ 1.4.1. Desktop environment basics
- ☰ 1.4.2. Updating the system
- ☰ 1.4.3. Installing essential tools
- ☰ 1.4.4. Setting up drivers
- ☰ 1.4.5. Using the software center
-
- ☰ 1.5. Linux Filesystem Hierarchy
- ☰ 1.5.1. Overview of the root filesystem
- ☰ 1.5.2. Important directories
- ☰ 1.5.2.1. `/etc`
- ☰ 1.5.2.2. `/var`
- ☰ 1.5.2.3. `/usr`
- ☰ 1.5.2.4. `/tmp`
- ☰ 1.5.2.5. `/dev`
- ☰ 1.5.2.6. `/proc`
- ☰ 1.5.2.7. `/sys`
-
- ☰ 1.5.3. File types
- ☰ 1.5.4. Absolute vs relative paths
-
- ☰ 1.6. The Linux Graphical Environment
- ☰ 1.6.1. GNOME
- ☰ 1.6.2. KDE Plasma
- ☰ 1.6.3. XFCE
- ☰ 1.6.4. File managers
- ☰ 1.6.5. System settings
- ☰ 1.6.6. Workspaces and window management
-
-
- ☰ 2. PART II — Command Line Essentials
- ☰ 2.1. Terminal and Shell Basics
- ☰ 2.1.1. What is a shell?
- ☰ 2.1.2. Bash vs Zsh vs Fish
- ☰ 2.1.3. Command structure
- ☰ 2.1.4. Environment variables
- ☰ 2.1.5. Getting help
- ☰ 2.1.6. Command history and autocomplete
-
- ☰ 2.2. Files and Directories
- ☰ 2.2.1. Listing files
- ☰ 2.2.2. Navigating directories
- ☰ 2.2.3. File operations
- ☰ 2.2.4. Wildcards and globbing
- ☰ 2.2.5. Searching files
-
- ☰ 2.3. Viewing and Editing Text Files
- ☰ 2.3.1. Viewing tools
- ☰ 2.3.2. Editing with nano
- ☰ 2.3.3. Introduction to vim
- ☰ 2.3.4. Input/output redirection
-
- ☰ 2.4. Users, Permissions, and Ownership
- ☰ 2.4.1. Users and groups
- ☰ 2.4.2. Permission types (r, w, x)
- ☰ 2.4.3. Changing permissions
- ☰ 2.4.4. Changing ownership
- ☰ 2.4.5. Using sudo
-
- ☰ 2.5. Package Management
- ☰ 2.5.1. Software repositories
- ☰ 2.5.2. APT (Debian/Ubuntu)
- ☰ 2.5.3. DNF (Fedora/RHEL)
- ☰ 2.5.4. Pacman (Arch Linux)
- ☰ 2.5.5. Snap, Flatpak, AppImage
- ☰ 2.5.6. System upgrades
-
- ☰ 2.6. Working with Processes
- ☰ 2.6.1. What is a process?
- ☰ 2.6.2. Viewing processes
- ☰ 2.6.3. Killing processes
- ☰ 2.6.4. Foreground and background jobs
- ☰ 2.6.5. System services and daemons
-
- ☰ 2.7. Introduction to Shell Scripting
- ☰ 2.7.1. Writing your first script
- ☰ 2.7.2. Variables
- ☰ 2.7.3. Conditionals
- ☰ 2.7.4. Loops
- ☰ 2.7.5. Functions
- ☰ 2.7.6. Making scripts executable
-
-
- ☰ 3. PART III — Intermediate System Administration
- ☰ 3.1. Systemd and Service Management
- ☰ 3.1.1. What is systemd?
- ☰ 3.1.2. Managing services (systemctl)
- ☰ 3.1.3. Boot targets
- ☰ 3.1.4. System logs (journalctl)
- ☰ 3.1.5. Creating custom services
-
- ☰ 3.2. Storage and Filesystems
- ☰ 3.2.1. Devices and partitions
- ☰ 3.2.2. Filesystems (EXT4, XFS, Btrfs)
- ☰ 3.2.3. Mounting and unmounting
- ☰ 3.2.4. Disk usage tools
- ☰ 3.2.5. Archiving and compression (tar, gzip, xz)
-
- ☰ 3.3. Networking Fundamentals
- ☰ 3.3.1. IP addressing
- ☰ 3.3.2. Subnets and routing
- ☰ 3.3.3. DNS and hostnames
- ☰ 3.3.4. Networking tools (ip, ss, ping)
- ☰ 3.3.5. Editing network configuration files
-
- ☰ 3.4. User and Group Administration
- ☰ 3.4.1. User information files
- ☰ 3.4.2. Creating and removing users
- ☰ 3.4.3. Password policies
- ☰ 3.4.4. Managing groups
- ☰ 3.4.5. Shell configuration
-
- ☰ 3.5. System Monitoring
- ☰ 3.5.1. CPU and memory monitoring
- ☰ 3.5.2. Disk and I/O monitoring
- ☰ 3.5.3. Log files in /var/log
- ☰ 3.5.4. Boot performance
- ☰ 3.5.5. Monitoring running services
-
- ☰ 3.6. Backup and Restore
- ☰ 3.6.1. Backup strategies
- ☰ 3.6.2. Using rsync
- ☰ 3.6.3. Creating tar archives
- ☰ 3.6.4. Using snapshot systems
- ☰ 3.6.5. Automating backups
-
- ☰ 3.7. Basic System Security
- ☰ 3.7.1. Firewalls (UFW, firewalld)
- ☰ 3.7.2. Authentication policies
- ☰ 3.7.3. SSH security basics
- ☰ 3.7.4. SELinux and AppArmor overview
- ☰ 3.7.5. Intrusion detection basics
-
-
- ☰ 4. PART IV — Advanced Linux Skills
- ☰ 4.1. Advanced Shell Scripting
- ☰ 4.1.1. Script structure
- ☰ 4.1.2. Error handling
- ☰ 4.1.3. Debugging scripts
- ☰ 4.1.4. Scheduled tasks (cron)
-
- ☰ 4.2. The Linux Boot Process
- ☰ 4.2.1. BIOS vs UEFI
- ☰ 4.2.2. Understanding GRUB2
- ☰ 4.2.3. Kernel loading
- ☰ 4.2.4. initramfs
- ☰ 4.2.5. Troubleshooting boot issues
-
- ☰ 4.3. Kernel Management
- ☰ 4.3.1. What is the kernel?
- ☰ 4.3.2. Kernel modules
- ☰ 4.3.3. Kernel parameters
- ☰ 4.3.4. Compiling a custom kernel
- ☰ 4.3.5. Kernel versioning and updates
-
- ☰ 4.4. Advanced Filesystems and Storage
- ☰ 4.4.1. LVM concepts
- ☰ 4.4.2. Logical volumes
- ☰ 4.4.3. RAID levels
- ☰ 4.4.4. Full disk encryption (LUKS)
- ☰ 4.4.5. Snapshots and rollbacks
-
- ☰ 4.5. Network Services
- ☰ 4.5.1. SSH server configuration
- ☰ 4.5.2. NFS
- ☰ 4.5.3. Samba
- ☰ 4.5.4. FTP/SFTP
- ☰ 4.5.5. Firewalls in depth
-
- ☰ 4.6. Logging and Auditing
- ☰ 4.6.1. Systemd logging
- ☰ 4.6.2. Traditional logs in /var/log
- ☰ 4.6.3. Auditd
- ☰ 4.6.4. Log rotation
- ☰ 4.6.5. Creating custom logs
-
- ☰ 4.7. Virtualization and Containers
- ☰ 4.7.1. Virtual machines (KVM/QEMU)
- ☰ 4.7.2. Linux containers (LXC/LXD)
- ☰ 4.7.3. Docker fundamentals
- ☰ 4.7.4. Podman vs Docker
- ☰ 4.7.5. Container networking
-
-
- ☰ 5. PART V — Server Administration (Expert)
- ☰ 5.1. Web Servers
- ☰ 5.1.1. Apache basics
- ☰ 5.1.2. Nginx basics
- ☰ 5.1.3. Virtual hosts
- ☰ 5.1.4. SSL/HTTPS
- ☰ 5.1.5. Reverse proxy concepts
-
- ☰ 5.2. Database Servers
- ☰ 5.2.1. MySQL/MariaDB
- ☰ 5.2.2. PostgreSQL
- ☰ 5.2.3. Database backup strategies
- ☰ 5.2.4. Database hardening
-
- ☰ 5.3. Email Services
- ☰ 5.3.1. SMTP fundamentals
- ☰ 5.3.2. Configuring Postfix
- ☰ 5.3.3. IMAP/POP3 with Dovecot
- ☰ 5.3.4. Spam filtering systems
- ☰ 5.3.5. Email routing concepts
-
- ☰ 5.4. DNS and DHCP
- ☰ 5.4.1. Understanding DNS
- ☰ 5.4.2. Setting up BIND
- ☰ 5.4.3. DNS zones and records
- ☰ 5.4.4. DHCP server configuration
- ☰ 5.4.5. DNS troubleshooting
-
- ☰ 5.5. Load Balancing
- ☰ 5.5.1. HAProxy fundamentals
- ☰ 5.5.2. Nginx as a load balancer
- ☰ 5.5.3. Session persistence
- ☰ 5.5.4. High availability concepts
-
- ☰ 5.6. Clustering and High Availability
- ☰ 5.6.1. Failover principles
- ☰ 5.6.2. Pacemaker
- ☰ 5.6.3. Corosync
- ☰ 5.6.4. Cluster resource management
- ☰ 5.6.5. Distributed filesystems
-
-
- ☰ 6. PART VI — DevOps and Cloud
- ☰ 6.1. Linux for Developers
- ☰ 6.1.1. Compiler toolchains (gcc, make)
- ☰ 6.1.2. Git fundamentals
- ☰ 6.1.3. Debugging tools (gdb, strace)
- ☰ 6.1.4. Build automation (Makefile, CMake)
-
- ☰ 6.2. DevOps on Linux
- ☰ 6.2.1. CI/CD principles
- ☰ 6.2.2. YAML basics
- ☰ 6.2.3. GitHub Actions
- ☰ 6.2.4. GitLab CI/CD
- ☰ 6.2.5. Automated testing
-
- ☰ 6.3. Configuration Management
- ☰ 6.3.1. Ansible basics
- ☰ 6.3.2. Playbooks and inventories
- ☰ 6.3.3. Puppet overview
- ☰ 6.3.4. Chef overview
-
- ☰ 6.4. Infrastructure as Code
- ☰ 6.4.1. Terraform fundamentals
- ☰ 6.4.2. Providers and resources
- ☰ 6.4.3. Modules
- ☰ 6.4.4. Cloud provisioning with Terraform
-
- ☰ 6.5. Cloud Computing with Linux
- ☰ 6.5.1. Linux on AWS
- ☰ 6.5.2. Linux on Azure
- ☰ 6.5.3. Linux on GCP
- ☰ 6.5.4. Cloud networking basics
- ☰ 6.5.5. Scaling and monitoring
-
-
- ☰ 7. PART VII — Master Topics
- ☰ 7.1. Hardening a Linux System
- ☰ 7.1.1. Hardening principles
- ☰ 7.1.2. Kernel hardening
- ☰ 7.1.3. File integrity monitoring
- ☰ 7.1.4. Vulnerability scanning
-
- ☰ 7.2. Forensics and Incident Response
- ☰ 7.2.1. Collecting evidence
- ☰ 7.2.2. Log and file recovery
- ☰ 7.2.3. Analyzing suspicious processes
- ☰ 7.2.4. Incident response workflow
-
- ☰ 7.3. Performance Tuning
- ☰ 7.3.1. CPU tuning
- ☰ 7.3.2. Memory tuning
- ☰ 7.3.3. Disk and I/O optimization
- ☰ 7.3.4. Profiling tools
-
- ☰ 7.4. Writing Linux Tools
- ☰ 7.4.1. Bash-based tools
- ☰ 7.4.2. Python command-line tools
- ☰ 7.4.3. Writing tools in C
- ☰ 7.4.4. Using Linux system APIs
-
- ☰ 7.5. Linux Internals
- ☰ 7.5.1. Process lifecycle
- ☰ 7.5.2. Memory management
- ☰ 7.5.3. Signals and IPC
- ☰ 7.5.4. Namespaces
- ☰ 7.5.5. cgroups
-
- ☰ 7.6. Becoming a Linux Expert
- ☰ 7.6.1. Career paths
- ☰ 7.6.2. Certifications (RHCE, LFCS, LPIC)
- ☰ 7.6.3. Building a homelab
- ☰ 7.6.4. Contributing to open source
-
-
Comments
Please login to add a comment.
Don't have an account? Register now!