______ Setting up a virtual system with Virtual Box (CS 273 (OS), Fall 2020)
Home
>>    




Setting up a virtual system with Virtual Box

CS 273 (OS), Fall 2020

Virtual Box is popular open-source software for creating and managing virtual machines. We will carry out the following steps as a lab.

Note: Complete the first two steps (before the line) before class, so you won't spend most or all of your class time downloading.
  1. Download and install Virtual Box on your laptop

  2. Obtain an ISO disk image of Ubuntu on your laptop


  3. Start Virtual Box

  4. Create a new virtual machine

    • New button -- New VM wizard

    • Preferred name: username OS ubuntu 64
      be sure to use your username, not the word "username"

    • OS: Linux; version Ubuntu

    • Memory: 2GB (2048 MB) for 64 bit? Could try 1GB, and increase later if we find we need it

    • Hard drive: choose "Create a virtual hard disk now"; bootable; VDI; dynamically allocated; location; 20 GB

  5. To connect the Ubuntu image you downloaded to your Virtual Box system:

    • click on Tools at the top of the left column, and select Media;,

    • click the Add icon in the top row, and browse to your .iso file;

    • now click on your virtual machine (VM) in the left column, then click on the line labelled Storage;

    • under Storage Devices (on the left), click on the round CD line;

    • then on the right, click on the round icon at the end of the Optical Drive line near the top;

    • finally, select the .iso file you added.

  6. Start your virtual machine for the first time

    • In the Virtual Box manager, click on the machine you just created, then click on start

      • Note: On many people's Mac computers in Fall 2020, starting the virtual machine (VM) using the Virtual Box user interface did not succeed. Instead, try starting your VM from the command line by entering the following command in a terminal window.

        VirtualBoxVM --startvm "username OS ubuntu 64"
        
        (using your username). See Piazza post 36

    • Browse to select your Ubuntu .iso file ("Startup disk")

    • Host key, mouse management...?

  7. Install the operating system

    • Install Ubuntu

      • Leave the following unchecked:

        "Download updates while installing..." -- we recommend updating manually below, for the experience.
        "Install third-party software..." -- we don't expect to need this

      • Choose "Erase disk and install Ubuntu". This will erase your the virtual disk you just made. Note: The installation is running on your new virtual machine, which only has access to your virtual disk, so there is no danger of damaging data on your laptop's disk (other than the virtual disk).

        We won't need the other options for the project.

      • There may be a pop-up warning concerning the partition structure changes that will be made to your virtual disk. Two partitions will be created on the virtual disk:

        • a partition for the main file system (ext4 format), which will also hold the bootable operating system kernel, installed software from Ubuntu distribution, etc.); and

        • A swap partition, for memory management (paging, swapping).

    • First-run wizard

      • For keyboard, click Continue (US keyboard will be selected by default)

      • Choose minimal installation

      • Computer name: avoid spaces

      • Username: please use your St. Olaf username (omit @stolaf.edu)

      • Password: It's better security to use a strong password that you don't use for anything else (e.g., avoid your St. Olaf password).

      • If you see a prompt to "remove installation media", just press Enter (Virtual Box automatically ejects the virtual media)

    • Select installation medium: Browse to the ISO image you downloaded

    • Mouse pointer messages...?

  8. Install some additional software on your virtual disk

    • Ubuntu software center - open this by clicking on the 9-dot icon in lower left corner of the screen, then starting to type the name into search box.

    • Install GNU Emacs 24 or another editor.

    • etc.

  9. Create an unprivileged user account

    • Start terminal window, by one of the following methods:

      • search in menu on left side, or

      • press Ctrl-Alt-t

      Press Enter to choose defaults for all questions other than password

    • sudo adduser user

      • The sudo command enables your account to behave like a superuser. Sudo capabilities need to be set up for accounts in general, but your default account automatically has those privileges in VirtualBox.

      • This command will prompt you for passwords three times:

        • First, for your default account's password (to authenticate for sudo)

        • Then, twice to supply a new password for your new account.

      • If you enter sudo multiple times within a short time period, sudo will only prompt you for the password once. After a period of inactivity, sudo will prompt you again for the password.

  10. Shut down your virtual system


  11. Restart your virtual system

    • This operation should first create a virtual machine (emulated hardware system), then boot Linux on that virtual machine, using the Linux kernel distributed with Ubuntu.

    • Try logging in with your unprivileged user account.

      Upon success, log out.

    • Log in using your privileged account, so we can do some system work

  12. Update development software to latest versions

      sudo apt install gcc
      sudo apt install libncurses5-dev
      sudo apt update && sudo apt upgrade
    
    Notes:
    • sudo

    • apt, command-line utility for managing software installations

    • The update/upgrade step could be long (perhaps 20 min, depending on your computer)

  13. Obtain source code for the Linux kernel from within your VM

    We will use this source code in the next lab in order to recompile the kernel. We will be using Linux version 5.0.21. You can obtain the "tarball" containing over 19 million lines of code in either of these ways:

    •   wget https://www.cs.stolaf.edu/t/os/linux-5.0.21.tar.xz 
      
      OR
    •   wget https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.0.21.tar.xz 
      

      Note: In November 2013 on arachne, this second wget command required a flag --no-check-certificate in order to retrieve the tarball from the standard kernel repository www.kernel.org .

  14. Unpack the tarball into your system's /usr/src directory

      sudo tar xvfJ linux-5.0.21.tar.xz -C /usr/src
    
    • tar, flags xvfJ

    Note: these commands use a capital J character (for uncompressing .xz files).

  15. Shut down your virtual system