Setting up the OSC labs

From SOFTICE

Jump to: navigation, search

Contents

This page describes how our laboratories can be installed. We are assuming here that either they are meant to work on an existing single Linux server or that they will be supported by one of our clustering solution. Please refer to System Administration page for more detailed information.


Installing OSC labs on your server

An installation of the course material provided by the SOFTICE project has very few requirements on the server:

  • You need the uml-utilities package installed
  • You need to have the wget tool installed

You need to download softice-osc-install and run it as root in order to download the virtual machines images and other scripts necessary to operate the labs.

The rest of this page will details the scripts available to you and the structure of the OSC laboratories' virtual machine infrastructure.

In case of issues, refer to the following wiki pages;

Optionally, you might also want to set up a kernel code browsing tool to help your students in their forays inside the Linux kernel;


What you find on your system after installation

Everything should be in /softice/. You will find the following sub-folders;

/softice/bin/
  • Link to /softice/osc/bin
/softice/osc/bin/linux-uml
/softice/osc/bin/softice-osc-run
/softice/osc/bin/softice-osc-setup
/softice/osc/bin/smb-user-add
/softice/osc/bin/softice-user-add
/softice/osc/bin/softice-user-del
  • Scripts to handle adding / removing students accounts
  • Scripts to run the virtual machine for OS labs
  • linux-uml is a kernel compiled with ARCH=um and GCC 4.0 inside a UML virtual machine using the patched kernel source below (patches enable some features required by labs)
/softice/osc/fs/core-debian.rfs
/softice/osc/fs/ks.2.6.16.20.2xpatched.rfs
  • The file systems used by the students' VMs
  • Each student will have a COW version of them (cf. below)
  • Also make sure the sleuth toolkit is installed in the students' UML virtual machine if you deploy your own core-debian.rfs and intend to use lab OSC: File Systems.
/softice/osc/homerun
  • Everything that needs to be installed in the students' ~/.softice-osc/ directory (cf. below)

The linux-uml kernel has been compiled inside this UML virtual machine since it has the 2.6.16.20 sources already patched for our labs. It also has gcc 4.0 already installed which was needed.

Make sure that you use the same environment if you need to recompile a UML kernel and do not want to use our VM.

Also, make sure that you apply the patch described in the OSC: System Call Interception laboratory and which enables the students' LKMs to see the sys_call_table symbol in order to hijack system calls.

Make sure that you enable the following options in the kernel when compiling;

  • User Mode Linux options
    • Host FS (to allow your students' VMs to see their server's home directories)
  • File Systems
    • DOS/FAT/NT filesystems
      • VFAT (for lab OSC: File Systems)
      • (default codepage = 437, default charset = iso 8859-1)
    • Native Language Support
      • code page 437
      • NLS ISO 8859-1


Creating students accounts

Upon installing the softice courseware for the OSC labs, you will have a softice-add-user script available to the root user to help you create accounts for your students / instructors. The script takes 3 parameter;

  • course name (1 word, e.g. cop4610)
  • Student login name (1 word, e.g. JSmith)
  • unencrypted password

You could, for instance, create a test account with the following invocation;

 
softice-user-add cop4610 JSmith VeryStrongPassword

The script will add a user JSmith to the group students and set the password. The home directory of the user will be created in /home/students/CourseName/LoginName. This home directory will contain the default configuration files available in /etc/skel/ along with a subdirectory .softice-osc which will contain the following:

config.rfs A tiny virtual disk image which will be mounted when the student's virtual machine boots to configure it. See section below "Configuring the student's UML at boot time"
07-vfatdisk.rfs A virtual disk image formated with the FAT32 file system which is used in the OSC:File_Systems lab.

When the student starts his/her virtual machine for the first time, more files will be added. These are explained in the section "Starting virtual machines" describing the softice-osc-run script.

Starting Virtual Machines

When using softice-add-user, you prepare the .softice-osc subdirectory in the students' home directory. Starting the virtual machine is as simple as issuing the following command:

softice-osc-run

The softice-osc-run script will ensure that the appropriate files are in the .softice-osc subdirectory in the user's home directory. If the environment is not there, the softice-osc-setup script will be invoked.

Similarly, since students need only a single virtual machine to work on this course, the script will also check that no other UML virtual machine is already running this student. If there is one, it will be shutdown using the uml_mconsole command.

When a student starts his/her virtual machine for the first time two new files are created in their .softice-osc directory;

core-debian.cow This file is a COW version of the 1GB Debian image shared by all students. Only modifications this student made to the shared image are stored in this COW file to save disk space
ks-2.6.16.20.cow Same thing for the shared disk image containing the sources of the linux kernel and mounted read only by every student's virtual machine to enable them to develop LKMs inside of it

Configuring the Student's UML at boot time

What it is

When the students' UML virtual machines boot, they are mounting a virtual disk image named config.rfs (actually they do so through the config.cow COW file) which contains some data and scripts which are going to be used to configure on-the-fly the UML instance.

This is used mainly for two reasons:

  • to fix on the fly potential bugs in the core-debian.rfs images you might build yourself (e.g. presence of the /lib/tls threading library). These scripts should be able to catch the problems you might inadvertently introduce when building your own virtual disk images.
  • make sure the students have access to their account data on the physical server from within their UML instance. The directory /root/SOFTICE-USER-ACCOUNT/ inside their UML is mounting, via HostFS, the /home/students/ directory on the physical server. This makes is easier for students to exchange file between the physical host and their virtual machine or even, for courses in which this is applicable, between virtual machines. This also allow students to use their favorite text editors on the physical host to modify files in their home directories without forcing us to install more software in the virtual machines. Files can be edited, saved and immediatly visible from within the UML instance.

How to use it with your own core disk images

Remember that for this configuration system to work when you are using your own core virtual disk images it is necessary for it to mount this configuration device and call the script that are on it. To do so, start your UML for the first time after creating a new core disk image and mount on /mnt/config the configuration device config.rfs. Now add the script softice-osc-init to your startup scripts by doing:

 
cp /mnt/config/init/softice-osc-init /etc/init.d
update-rc.d softice-osc-init defaults 99 

This script will simply invoke /mnt/config/init/softice-osc-uml during the boot process in order to take care of initializing correctly your virtual machine.

Structure of the config.rfs

If you inspect the contents of the config.rfs you will find the following directories:

bin

Contains a copy of the make-lkm script which is used by students in the laboratories to compile their LKMs inside their UML instance

etc Contains a bashrc which sets the prompt for the root user of the UML instance. It will be copied into /root/ by softice-osc-uml

# ~/.bashrc: executed by bash(1) for non-login shells.

export PS1='UML:\w\$ '
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

This subdirectory also contains a fstab file which will be copied over the /etc/fstab of the UML instance by softice-osc-uml to ensure that the kernel sources and configuration small virtual disk images are appropriately mounted. Be aware that if you modify the command line arguments used in [[script: softice-osc-run|softice-osc-run] then you'll need to modify these mount options as well

# UNCONFIGURED FSTAB FOR BASE SYSTEM
# /etc/fstab: static file system information.
#
# file system   mount point     type    options         dump    pass
/dev/ubd0       /               ext2    noatime         0       0
#/dev/ubd1       /usr/src/linux  ext3    ro             0       0 
/dev/ubd6       /mnt/config     ext2    ro              0       0

#swap not used in our first tests
#/dev/ubd1      swap            swap    defaults        0       0
#
none            /proc           proc    defaults        0       0
none            /dev/pts        devpts  gid=5,mode=620  0       0


init This subdirectory contains the script softice-osc-init which has been installed in your core disk image (core-debian.rfs) using update-rc.d so that it executes at boot time As you build your own disk image, make sure you install this script as startup script as well. It also contains the script softice-osc-uml which is invoked form the above and takes care of configuring your disk image at boot time


username.dat Lastly, the configuration device contains a text file username.dat which will tell softice-osc-uml what part of the host's file system will be mounted inside the UML instance at /root/SOFTICE-USER-ACCOUNT/ using the HostFS feature

The Virtual disks images

These disk images are located in /softice/osc/fs/ and shared by all students' UML instances. The softice-osc-run script uses a COW version of these to store the difference between the shared images and the modifications done by each individual virtual machine in the .softice-osc subdirectory of each student's homedir.

Refer to the uml_moo utility to merge back the contents of a COW file into its backing core image.


core-debian.rfs and core-debian.cow

Your students's UMLs will be booting from a so-called root file system (rfs). In our setting, each student account has a directory ~/.softice-osc/ which containts a core-debian.cow file representing the student's personal version of the shared /softice/osc/fs/core-debian.rfs virtual disk image. This virtual hard drive is the root file system the students UML instances boot from.

When building your own image, make sure you follow the advices given in the following wiki pages:

What you need in your core-debian.rfs;

  • compile the kernel (from the virtual device ks2.6.16.20.rfs mounted through /dev/ubd1 on /usr/src/linux) and install the modules
  • /etc/fstab: mount the config device /dev/ubd6 in /mnt/config
  • make sure the /mnt/config/init/softice-osc-init is update-rc.d'ed in the image, it will then take care of everything else (hostfs)
  • /etc/inittab: to have ^c working in the uml


ks2.6.16.20.rfs

This small device contains the kernel source tree and is mounted inside the students' UMLs core-debian.rfs at /usr/src/linux read only. The mounting is done in the config.rfs scripts so that you don't even have to worry about it in the core-debian.rfs