Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 6

Installing Linux in a VM

Recommended resources

Hello! Welcome to your sixth lesson in the "Linux Fundamentals and System Startup" module.

In our last lesson, you successfully set up your virtual lab environment by installing VirtualBox and creating an empty virtual machine (VM). You also downloaded the Ubuntu 22.04 LTS installation file (the .iso image).

Today, we'll bring that empty VM to life. This lesson is fully hands-on and will guide you through the process of installing a full Linux operating system into the virtual machine you created. This will give you the safe, practical environment you need for the rest of this course and your CompTIA Linux+ studies.

This lesson directly fulfills the learning outcome: Install a Linux distribution within a virtual machine.

1. Final VM Configuration and Attaching the ISO

Before we power on the VM, let's make a few final adjustments for better performance and, most importantly, tell the VM where to find the Ubuntu operating system installer.

  1. Open VirtualBox and select the Ubuntu VM you created in the last lesson (it should be powered off).
  2. Click the Settings button (the gear icon).
  3. Adjust Resources (Optional but Recommended):
    • Go to System -> Processor. You can increase the number of CPUs allocated to the VM. A good rule of thumb is to stay within the green area of the slider, perhaps increasing it to 2 or 4 cores if your computer has them available. This will make your VM more responsive.
    • Go to Display -> Screen. Increase the Video Memory as high as it will go (e.g., 128 MB).
  4. Attach the Installation ISO: This is the most critical step. It's the virtual equivalent of putting an installation CD into a new computer.
    • Go to Storage.
    • Under the "Storage Devices" list, you will see a CD icon labeled "Empty" under the "Controller: IDE" section. Select it.
    • On the right side, click the small CD icon next to the "Optical Drive" dropdown menu.
    • Choose "Choose a disk file..." and navigate to the ubuntu-22.04...desktop-amd64.iso file you downloaded in the previous lesson.
    • You should now see the name of the ISO file next to the CD icon in the storage list.
  5. Click OK to save the settings.

The video below demonstrates these settings adjustments and the process of attaching the ISO file.

How to Install Linux on a Virtual Machine using VirtualBox

The video 'How to Install Linux on a Virtual Machine using VirtualBox' by ProgrammingKnowledge2 clearly shows these configuration steps. We'll pick up where the presenter is about to configure a new VM.

Watch from 06:45 to 09:25. The presenter goes through the VM settings, adjusting the processors and, most importantly, attaching the Ubuntu ISO file under the 'Storage' section. Follow these steps for your own VM.


2. The Ubuntu Installation Process

With the ISO attached, you're ready to start the installation. This process is guided by a wizard, much like installing any other software.

Select your VM in the VirtualBox Manager and click Start.

The VM will boot up and, instead of finding an empty hard drive, it will load the Ubuntu installer from the ISO file you attached.

The following video provides a complete walkthrough of the Ubuntu installation wizard. You can pause it at each step to follow along in your own VM.

How to Install Linux on a Virtual Machine using VirtualBox

We'll continue with the ProgrammingKnowledge2 video, which provides a step-by-step guide through the entire Ubuntu installation.

Watch and follow along from 09:30 to 13:53. Pause as needed at each screen to make your own selections. Key stages you will encounter are: Try or Install Ubuntu: Choose 'Install Ubuntu'. Keyboard layout: Select your preferred layout. Updates and other software: 'Normal installation' is fine. Checking the box for 'third-party software' is recommended for better hardware compatibility. Installation type: Select 'Erase disk and install Ubuntu'. (See the note below!) Where are you?: Set your time zone. Who are you?: Create your user account and password. Choose a password you will remember!

A Crucial Note on "Erase Disk"

The installer will present a screen with the option "Erase disk and install Ubuntu." This is often a point of concern for beginners.

Rest assured, this action will ONLY affect the VIRTUAL hard disk you created for this VM. It will not touch any files on your main (host) computer. The VM is a completely isolated sandbox.

Test your understanding!

When you select "Erase disk and install Ubuntu" during the installation process inside your virtual machine, what is actually being erased?

  1. The main hard drive of your physical computer (e.g., your Windows C: drive).
  2. The USB drive you used to install VirtualBox.
  3. The blank virtual hard disk file (the .vdi file) that you created and allocated for this VM.
  4. The Ubuntu .iso installation file.
Show answer

The correct answer is 3. The blank virtual hard disk file (the .vdi file) that you created and allocated for this VM.

The virtual machine is an isolated environment. All its operations, including disk formatting, are contained within the virtual hardware files that VirtualBox manages. Your host operating system and its files are completely safe and unaffected.

Once you complete the user creation step, the installation will begin copying files. This is a good time for a short break. After it finishes, it will prompt you to restart.


3. First Boot and Installing Guest Additions

When the installation is complete, click "Restart Now". You may see a message like "Please remove the installation medium, then press ENTER". You can just press Enter; VirtualBox typically handles detaching the ISO automatically.

The VM will reboot, and you'll be greeted by the Ubuntu login screen. Log in with the user and password you created.

Your Ubuntu system is now running! However, you'll notice the screen resolution is fixed and small, and features like copy-paste between your host and guest don't work. To fix this, we need to install VirtualBox Guest Additions.

Guest Additions are a set of device drivers and system applications that optimize the guest operating system for better performance and usability.

How to Install Linux on a Virtual Machine using VirtualBox

The final part of the ProgrammingKnowledge2 video guides you through installing these essential Guest Additions. This involves running a few commands in the terminal, which is excellent practice.

Watch and follow along from 13:53 to 19:43. The key steps are: Update your system: Open the terminal and run sudo apt update. Install prerequisites: Run sudo apt install build-essential linux-headers-$(uname -r) (The video shows a slightly different command, but this one is more robust). Insert the Guest Additions CD: From the VM window menu, go to Devices > Insert Guest Additions CD Image... Run the installer: A pop-up will appear in Ubuntu. Click 'Run'. Enter your password when prompted. Restart: Once the installation is finished in the terminal, restart your VM.

After your VM reboots, try resizing the window. The Ubuntu desktop should now automatically scale to fit the window size. You have successfully installed and configured your Linux lab environment!


Conclusion

Congratulations on this major milestone! You have moved from theory to practice by installing a fully functional Linux operating system in a safe, virtualized environment. This is the workbench where you will hone your command-line skills for the CompTIA Linux+ exam.

Key Takeaways:

  • Installing an OS in a VM involves attaching an .iso file to the VM's virtual optical drive.
  • The installation process is guided by a wizard that configures language, users, and partitioning on the virtual disk only.
  • VirtualBox Guest Additions are crucial for a smooth user experience, enabling features like automatic screen resizing and shared clipboard.

In our next lesson, we will begin using this new system. You'll learn how to navigate the built-in help systems using the man and info commands, a fundamental skill for any Linux user or administrator.