DT249/3 Computer System Architecture and Administration (CSAA) Week 3
“User-Mode Linux is a safe, secure way of running Linux versions and Linux processes.” “Run buggy software, experiment with new Linux kernels or distributions, and poke around in the internals of Linux, all without risking your main Linux setup.” User Mode Linux (UML)(http://user-mode-linux.sourceforge.net/) DT249/3 - CSAA - L03
DT249/3 - CSAA - L03 User Mode Linux (UML) • UML is a useful teaching tool, especially in courses where students need a dedicated machine in order to get the most out of it • UML is being used to teach OS development, network administration, and more general system administration. • These are all cases where having a virtual machine to practice on is far more convenient for everyone than using physical boxes.
DT249/3 - CSAA - L03 Why UML? • The UML kernel runs in a virtual machine that can be configured in ways that your physical machine can't. It can have more memory, more devices, and, soon, more processors. So you can do development and testing of hardware capabilities even when you don't have the relevant hardware. • Poking around inside a running system • Since you have a full OS running outside UML, it's pretty easy for the terminally curious to find ways of looking inside this kernel that are impossible for a native kernel. • As a secure sandbox or jail Processes inside the user-mode kernel have no access to the hosting machine or to the outside world that's not explicitly provided. So, a malicious application running inside it can do no harm to anything that matters.
DT249/3 - CSAA - L03 Why UML? • Virtual networking UML virtual machines are networkable, to each other, to the host, and to other physical machines. So, UML can be used to set up a virtual network that allows setting up and testing of experimental services. • As a test environment Testing of some types of software requires booting up a machine. With UML, this can be very easily automated.
DT249/3 - CSAA - L03 UML at the School of Computing • At present The School of Computing provides one system specifically for hosting UML sessions • wicklow.cs.dit.ie • The binary executable on wicklow which loads the Linux kernel for the UML environment is /usr/bin/umllinux
DT249/3 - CSAA - L03 Copy On Write • In UML, the entire file system is contained in a single file • By default the file used is root_fs in the current directory • If no command-line option is specified, the executable linux kernel will look for a file called root_fs in the current directoryThe Copy On Write mechanism (COW) allows many users to use the same base root_fs yet still make their own changes
DT249/3 - CSAA - L03 • This works by keeping a read-only copy of the root file system shared by all users and a copy-on-write file for each individual user • The copy-on-write (cow) file contains only those changes which an individual user has made to files • From the user’s point of view, their file system consists of two parts • root_fs (read-only and shared) • cow_fs (read/write and not shared) • To support the sharing of a single root file system among all UML users on wicklow, the master root file system is stored in • /opt/uml/rootfs.debian
DT249/3 - CSAA - L03 Personal cow file • To allow UML users on wicklow to store their own modifications to the root_fs file, each student has their own cow file • This cow file is located in their home directory on wicklow and is called • /uml/root_fs_cow_<your username> • Since this file reflects any changes you have made to the root_fs, if you delete this file all changes will be lost
DT249/3 - CSAA - L03 umllinux script • To start UML on wicklow, users use the umllinux script !/bin/sh /bin/linux.nfs ubd0=/uml/root_fs_cow_`whoami`,/opt/uml/rootfs.debian eth0=mcast • This tells the executable linux kernel /bin/linux.nfs to use the root_fs (/opt/uml/rootfs.debian) and the cow file specified (/uml/root_fs_cow_<your username>) • It also tells linux to provide one ethernet card, eth0
DT249/3 - CSAA - L03 Backup your cow file • If the user were to create a backup copy of their cow file at the start of each wicklow session, then they would have the ability to roll-back any changes that were made during a given session • In this way users could experiment with settings and installing software in the knowledge that undoing their changes would be a simple matter
DT249/3 - CSAA - L03 host_fs • One of the first questions asked in relation to UML is how to transfer files between the host and the UML session • UML supports the use of a specialised file system driver host_fs • This allows us to mount the file system of the host machine from within the UML instance • There are a number of ways of doing this • The first mechanism for mounting the host file system is to use the mount command as follows mount none /mnt/host –t hostfs
DT249/3 - CSAA - L03 • This will cause the root of the host’s file system to be mounted at the /mnt/host directory (which must exist) • Alternatively we could specify a non-root directory to mount • mount none /mnt/host2 –t hostfs –o /home/student/<name> • To make either of these mounts persistent, we can add the appropriate line to the /etc/fstab file • none /mnt/host hostfs /home/student/<name>