UML Basics ---------- Choose a Linux computer in the lab and log in as yourname. Look at the contents of the /usr/uml/457-init script. % more /usr/uml/457-init Run the /usr/uml/457-init script to create a brand new clean copy of the UML environment on the computer that you are using. This will probably take 3-5 minutes or so. % /usr/uml/457-init Change directory to your UML place in the /tmp directory and take a look at what is there. You should see either a Fedora version of UML, or a CentOS version. % cd /tmp/yourname/uml % ls -l Look at the contents of the startuml script. % more startuml Run the startuml script. % ./startuml (If you see any fatal error messages at this point, such as "mod probe binfmt 464c", it means that you are on a computer that does not support the current version of UML. Manually kill all your processes and log out. Find a different computer and start over.) The startuml script creates 4 terminal windows for you to log in to UML. Choose one of the windows and log in as root with no password. (You can also do the steps above to run UML remotely on a departmental computer such as csc, cse, or csl, but only one of the terminal windows will work; the other 3 will give you error messages for a few minutes. Using "ssh -X" might help suppress this annoying error message problem.) Try some simple commands such as "ls", "date", "ps", and such. You are the superuser in this UML world! When you are done in UML, do a graceful shutdown. % shutdown -h now This should return you back to Linux in the /tmp/yourname/uml directory. There is a subdirectory called "linux". Go there. This is where you need to be when compiling a new version of the kernel. Look at the huge Makefile. Look for the Linux kernel image file. % cd linux % ls -l % more Makefile % ls -l linux % ls -l vmlinux % diff linux vmlinux To compile a new kernel image, use the "make" command as follows: % make linux ARCH=um CC=gcc CXX=g++ This will automatically recompile any source code files that have been modified, and create a new kernel image file. If the compile fails, error messages will appear here. These compile errors need to be fixed before you can create a new kernel. If you want to run your new kernel, move back up to run startuml. % cd .. % ./startuml Beneath the "linux" directory is the "kernel" source code directory. Go there. Look at some files such as fork.c, sched.c, signal.c, timer.c, user.c, and others. % cd kernel % more fork.c % more sched.c % more signal.c % more timer.c % more user.c Choose a file and modify the code a bit, perhaps by adding a "printk" statement. Save the file. Move up one level to compile kernel. If it works, then move up one level to run your kernel to see your message. NOTES: User Mode Linux (UML) is a virtual machine environment. You are a superuser (root) in this world, but the set of commands, shells, editors, compilers, and tools available inside UML is rather limited. Thus you will be doing most of your development work OUTSIDE of UML, while you do all of your testing INSIDE the UML environment. You will need to keep track of where you are at all times. There will be at least 3 different places you will be working: (1) Your own directory: As a regular undergrad student in CPSC, you have access to the files and such in your own directories on the CPSC file server. (2) The /tmp directory: In setting up your UML environment, you create a temporary set of files (about 600 MB worth) in the /tmp directory on the computer you are using. In particular, all your UML stuff is in the /tmp/yourname/uml directory. Please note that this is a TEMPORARY directory, and can go away at any time, for example when the machine is rebooted. If there are any files that you want to keep (e.g., to hand in), then you should remember to copy them to your own home directory at some point. It is also a good idea to keep a backup working copy of any kernel source file that you are modifying, so that you can back out any changes in case of serious UML problems. (3) The UML world: Inside UML you may need to compile and run some small programs. However, there are very few editors and compilers available here, and there are no "user accounts". Furthermore, you do not have any access to your regular files from your home directory (1) or the /tmp directory (2) while inside UML. If you do want to move files between your home directory and UML (in either direction), then you should do the following inside UML as superuser: % mkdir /host % mount none /host -t hostfs -o YOURHOMEDIRECTORY where YOURHOMEDIRECTORY is the name of your home directory such as /home/ugrads/yourname If the mount worked successfully, then you should be able to see your usual files. Try the following: % cd /host % ls You can then copy ("cp") files to or from the UML environment.