Homework 2
Due on Gradescope at Feb 25, 23:55 hrs
This homework has two parts. Part I contains several written questions that you should answer based on material covered in recent lectures. Part II is a hands-on part of the homework that provides you with familiartity with virtualization and volunteer computing. Please submit both parts as a single document on gradescope.
Part 1
- What is it important to respect cache affinities of processes and threads in multiprocessor scheduling?
- Explain in a few sentences as to why distributed scheduling will not provide much benefits at both light and heavy utilization levels.
- Why does type 1 hypervisor not need a host operating system when booting up? Explain in 2-3 sentences.
- Does a Type 1 hypervisor using paravirtualization need special hardwarde support from the CPU like normal type 1 hypervisors? Why or why not?
- Does Docker use a form of hardware-level or OS-level virtualization? Explain your answer in 2-3 sentences.
- Why is OS virtualization more lightweight than hardware virtualiation?
- What is the primary difference between process and code migration?
- Why does VM migration not cause active network socket connections of processes to break even though the IP address of the physical machine does not move with the VM?
Part 2
1 Introduction
The purpose of this homework is to provide hands-on experience with hardware virtualization, OS virtualization and volunteer computing. Homeworks will alternate between written assignments and hands-on homeworks such as this one.
2 Virtual Box
For hardware virtualization, we will be using VirtualBox, which does binary translation to run unmodified Operating Systems as Virtual Machines. You can download VirtualBox for your platform here: https://www.virtualbox.org/wiki/Downloads
2.1 Installing an OS on a new VM
We will use a standard .iso
image to install an Operating System
onto a Virtual Disk, just like you would install an OS on an actual
physical hard disk. We will use Ubuntu as the Operating System
(although you can use any OS as you wish). You can download the 64-bit
server image
http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-server-amd64.iso or
the desktop version (with GUI)
http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-desktop-amd64.iso
If you have a 32bit OS (or a 32bit CPU), Virtualbox may be unable to run the 64bit versions. You will need to download and use the 32bit versions available at http://www.ubuntu.com/download/alternative-downloads
Create a New VM by clicking on the "New" tab. Give your VM a name, say
"ubuntu-vm
". For performance reasons, Virtualbox asks the type
(Linux/Ubuntu 32-bit).
2.1.1 Memory
The next step is to allocate some hardware for your VM. Give a
reasonable amount of memory to your VM. If you are planning to run a
desktop VM with GUI, 3 GB
is minimum. The memory that you allocate
also depends on the total physical RAM available in your
system. Memory allocated to the VM cannot be used by the other
programs and memory shortage on the host OS can lead to system
slow-down. If your system is memory constrained, consider installing
the server iso, which should be able to run in 1 GB
.
2.1.2 Disk
A virtual machine needs a virtual disk, and you can use a file as a
virtual hard drive. Create a virtual disk, and allocate the size. 5-8
GB
should suffice. There is a choice of image formats for the virtual
disk (vmdk, raw, qcow2, vdi, etc). You can pick any format.
When creating the virtual disk, note the location of the file that you
have created. Say you created the virtual disk in
/home/user/vbox/vdisk1.vmdk
. What is the size of vdisk1.vmdk?
2.1.3 Mount the iso
So far, we've allocated storage and memory and thus created a "blank"
virtual machine. To install the OS, we need to attach a CD-drive. Open
the Settings
for the VM, goto the Storage
tab, and add a CD/DVD
device. Choose the iso
disk downloaded earlier. We now have a
"virtual PC" with a CD-ROM drive, memory, and a hard disk.
2.2 Running Your VM
Start
your VM. The Ubuntu installer screen should appear since the
VM boots from the CD-Drive first. Install Ubuntu as you generally would.
2.3 Post-install
Once the OS is installed, Shut Down
the VM or Reboot
it. If the
installer screen pops up again, the VM is still booting from the CD
and not from the hard-disk. Remove the CD-Drive from the settings if
the OS was installed successfully. This should now cause the
hypervisor to pick the hard-disk to boot from instead of the CD.
Try logging in and running your favourite programs. Try
Pausing/UnPausing
your VM. What is the difference between
power-cycling the VM and pausing/resuming?
Note that if you change the VM settings, you will need to restart the VM
2.3.1 Network access
So far, we have not configured any network interface for the VM. If
you need network access for your VM, ensure that the Network Adapter
is enabled in the VM settings. It can be of a NAT
or a Bridged
type
. Try both and report which works on your system.
Note the IP address of your host system (sudo ifconfig
on the host)
and the IP address of the VM by issuing ifconfig
inside the VM. What
are the IPs?
2.3.2 CPU
Change the processor configuration in the System
tab. You can change
the number of CPUs exposed to the VM, and also enable/disable hardware
virtualization acceleration if your CPU provides it (VT-x/SVM).
Look through Virtul Box directory created on your machine and specifically look for the virtual disk file (which has the .vdi extension). This file acts as the virtual disk for your VM.
Write down your observations about configuration options as well as virtual disks.
3 Docker
3.1 Obtaining Docker
Install docker to your newly created virtualbox image.
Read instructions here here. These instructions will install docker into the linux VirtualBox VM that you created above. Docker now also provides installation options for Mac or Windows, where it uses the in-built Hyper-V virtual machine on Windows or HyperKit virtual machine on Mac to run Linux and docker containers. If you so wish, you can perform the steps below using Docker for Mac or Docker for Windows.. All three methods are equivalent since they use Linux containers for OS-level virtualization. After installation, you need to run the tasks mentioned below and report them in your writeup.
Note: For linux VirutalBox, you need to run Docker as root. Prefix sudo to all commands or run as root
Check if docker works: docker version
. What is the version?
3.2 Image repository
All public docker images are in the docker repository. Search for the
ubuntu docker images by calling docker search ubuntu
. Which images are listed?
3.3 Downloading the image
docker pull ubuntu
Verify its downloaded by docker images
3.4 Running a command inside a container
docker run -i -t ubuntu /bin/bash
This spawns the container and runs bash inside it. You can run
anything in the container. Examine the process tree inside it by
issuing ps
inside the container by using docker run: docker run ubuntu ps
In addition, run ps
in a terminal in the VirtualBox. Compare the processes listed
in both case and observe what you see. Comment on why processes listed in the container are
restricted.
Examine the file system tree inside the container. cd /
changes into
the root directory. Is this the same root directory of the system?
Install some package inside the container : docker run apt-get
install -y vim
The container has been changed, now we can save it.
3.5 Saving the container as an image
First, get the ID of the image docker ps -l
Say the ID is 6982a9948422
Next, commit the changes you have made: docker commit 698 ubuntu
You now have a new docker image which you can re-use, share etc.
3.6 Resource utilization
Now observe the process tree outside the container by calling ps
.
Does the container show up here?
See the hardware resources granted to the container by using the
docker inspect $image-id
command. What is the CPU/memory allocated
to the container?
Finally pull a pre-packaged docker container such as MySQL or another database and run it. What advantages do you see installing this database using docker over a traditional install method?
4 Volunteer Computing
Go to the Berkeley BOINC site here Download the volunteer computing software. Next you need to pick a project of your liking. Examine the projects listed on the projects page and their stated goals. Choose a project and run the BOINC software. Leave you machine idle and observe when the software activates. Can you determine how much resources (CPU, memory) were consumed by the software when idle?
Be sure to clean up and delete VM images and BOINC once your are done with the homework.5 What to hand in for Part 2
Write up about your experiences in running Virtualbox and Docker. Keep your answers brief.
- Which VirtualBox features did you try?
- What is the size of the virtual disk on the host? Issue
df
in the VM and report the size of the file-system that the VM sees. - How long (approximately) does it take to pause and unpause a running VM?
- Which networking option (NAT/Bridged) worked for you?
- How much RAM and disk space did you allocate to the VM?
- What configuration options did you examine for the VM?
- Did you install docker in the VM or try the online tutorial?
- Which docker commands did you try?
- What pre-packaged software / database did you try? What advantages did you observe?
- Compare the time required to start a container vs. starting a VM.
- Explore file system inside the container and examine if the root(/) is shared between the container and the system.
- Compare the ps output inside the container vs when run for the entire system.
- What is the CPU/memory allocated to the container?
- What project did you pick for the volunteer computing part?
- What resource usage did you observe when the machine was idle?