Assignment: VM

Purpose

The purpose of this assignment is to familiarize yourself with the environment we will use in future assignments and make sure you have it setup before the first more substantial assignment.

We intend to test assignments in this class using a x86-64 Ubuntu 20.04 environment. This is our definitive platform for testing assignments, though it is our intention, to the extent possible, that assignments wil function in other x86-64 Linux environment. (Because some assignments depend on the exact contents of shared libraries and layout of memory, this may not always be practical.)

We have a webpage that includes a VM image you can use or instructions on how to setup a VM image yourself.

Unix exercise and deliverable

  1. Acquire a suitable virtual machine environment – or install a suitable Linux environment in some other way.
  2. Open a terminal window.
  3. Open a text editor, such as gedit or pico or emacs or vim or VS code, and create a file called hello_world.c in your home directory containing the following:

    #include <stdio.h>
    int main(int argc, char **argv) {
        printf("Hello world! I am a Wizard in Training.\n");
        return 0;
    }
    
  4. Run clear command to clear the terminal
  5. Compile the C source file you created with for 64-bit with gcc -o hello64.exe hello_world.c
  6. Run this file and to make sure it works with ./hello64.exe
  7. Compile the C source file you created with for 32-bit with gcc -m32 -o hello32.exe hello_world.c
  8. Run this file and to make sure it works with ./hello32.exe
  9. Run the command uname -a
  10. Take a screenshot of your terminal window. There are several options for doing this: a. Research, for example with web search, how to do this in your host OS. b. Take screenshot in the VM’s OS using gnome-screenshot -i. c. Research an alternate way to take a screenshot in your host OS.
  11. Submit the screenshot to the submission site (link TBA).

Useful VM tricks

We also recommend figuring out how to access files on your VM from your host OS. One way to do this is to use VMWare’s shared folders feature which lets you access folders on the host OS from inside your VM. You can configure this from the VM settings. (You might need to reboot the VM to have this take effect.)

VT-x support

For 64-bit VMs, VirtualBox requires some hardware support from your processor. This support is present on almost all processors made recently (including all laptop or desktop processors introduced by Intel since 2013). However, some computer manufacturers disable this support by default. When they do this, you can usually reenable the feature in BIOS or “the Setup Utility”.

How you access the BIOS/Setup varies between manufacturers. Common ways include pressing Enter or F2 or F12 or Del while booting the machine. If you are using Windows 10, you may need to first shut down the machine while holding shift – some Windows 10 installations default to not performing a “complete” shut down. You should be able to lookup full instructions online for accessing BIOS/Setup based on the model of your laptop or desktop.

Once in the Setup utility, the option to change is likely to be called something like “Intel VT-x” or “Intel Virtualization Technology”. Confusingly, this setting is sometimes under category called “Security” instead of something more obvious. After changing it, save the settings and reboot.

The exact steps involved in acccessing the setup utility and changing this setting will vary. But, for example, on my laptop, a Lenovo Thinkpad T460, I did the following:

If you have trouble setting getting 64-bit VMs to work on your machine, please do not hesitate to contact the course staff for assistence.

In the unlikely event that you have a laptop that does not support running 64-bit VMs with VirtualBox, we will make alternate arrangements such as making the assignments only use 32-bit, or finding a way for you to do the assignments by remote logging into department machines.