Project 2: GIMIX - Minix Setup
Assignment Day | September 01, 2009 |
Due Date | September 10, 2009 (Thursday) |
Collaboration Policy - Read Carefully
You must work on this project individually, but you may discuss this assignment with other students in the class and ask and provide help in useful ways, preferable over our email list so we can all benefit from your great ideas. You may consult (but not copy) any outside resources you including books, papers, web sites and people (but no penguins or sea urchins).
If you use resources other than the class materials, indicate what you used along with your answer.
You have probably guessed it by now - every project will have a similar paragraph to the one above but with slight variations, of-course.
Objective:
The main objectives for this assignment are:
- Set up your virtual machine emulator on your system, if you don't have one.
- Download, install and setup MINIX on an emulator/virtual machine, preferable VMware.
- Understand MINIX and software structure.
- Modify and 'rebuild' a MINIX Kernel.
- Add your shell, YOSH to MINIX.
- Learn about patching.
- Submit patch.
This tutorial/project is inspired by Darrel Long (and some materials are used by permission) and many others.
Tutorial / References
MINIX resources programming/tutorials:There are several MINIX resources that I found useful. http://en.wikipedia.org/wiki/MINIX_3 (see great links at bottom). http://www.minix3.org/doc/A-312.html (outlines the process nicely) http://wiki.minix3.org/en/UsersGuide/DoingInstallation (newer and above, but the first listed is still useful). http://wiki.minix3.org/en/UsersGuide/RunningMinixOnVmware(insights on running MINIX on WMware. http://www.minix3.org/manpages/index.html (Minix man pages) VMWare resources programming/tutorials:http://www.vmware.com/products/player/ (free VMware player) http://www.vmware.com/products/fusion/ (WMWare for mac and it links to 30-day trial - we are hoping to get/setup a 12 months license for our are waiting for an approval for this - it looks like a possibility right now - please email me if you are interested in this). |
If you find other resources please post links on the mailing list for the class. |
Background:
The MINIX operating system comes with a complete set of tools, including C compiler and linker as well as debugger. If you want the less wordy description skip to the bottom of this page and just do each bullet point.
Install VMware:
- Download VMware for free.
- Win/Linux=VMware player. (free version);
- Mac=VMwareFusion. (select "Get Free Trial" for now - 30 days)
- Install VMware (easy)
Before you install MINIX you need to install a platform where MINIX runs. Minix runs (and have been tested) on both actual hardware and machine emulators (or virtual machines as we called them in class). Maintaining a uniform machine for a large class is close to impossible we will use an emulator for the class.
Hardware emulators that I have tried (that also runs on a mac) include Bochs, QEMU (Q for mac), Virtual Box, VMware, Virtual Box and Parallels. We recommend (require) VMware for this project for the following reasons - we had the least problem with VMware, it has a nice interface, it performs well, and it has a large user base, including MINIX developers (and MINIX users).
For the obsessed shopper of emulators - here is a nice comparison chart from Wikipedia and here is a recent article from December 2008 comparing Parallels with VMware on a mac platform.
The free versions of VMware are fine for now 'VMware Players' for windows users and a limited 30-day trial, 'VMWare Fusion' for mac users (I feel singled having a mac now). After the 30 day period passes for us mac users we are hoping to obtain 12 months licenses for you soon - and it looks promising as they have indicated that we have been approved.
Install Minix:
After you installed your 'platform', you need to download and Install MINIX. Minix is distributed as a [compressed] CD image file (.iso file) - which are easily installed on VMware. An 'image file' is simple an archive of an optical disk, a signle file containg lots of smaller files.
It is '.iso' because the archive file format is a standard defined by the International Organization of Standards. ISO actually have a double meaning: the acronym (ISO) and isos which in Greek means equal - It was a deliberate double meanin and itsignifies the aim of the organization which is to equalize and standardize across different cultures.
You may have heard of other ISO standards from the organization, for example the ISO standard for speed of photographic film (ISO 5800), but in addition to file ISO and CD image file ISO, there are 17,500 other standards including the grading standard of Saffron (the world's most expensive spice) and the size of paper (A4 - european paper size). The CD image file is ISO 9660.
Back to business (there may be some variations if you use windows - e.g., a button may be in a slightly different location (bottom vs. top).
- Download MINIX from here:
- Use the pre-release 3.1.4 ISO:
- minix3_1_4_ide_r4817.iso (558 MB)
- direct link to iso.bz here.
- We do need to use the same version (so this is the required version).
- Yes - is a pre-release but it fixes a VMware quirk - and it is nicer to have something that work out of the 'box'.
- Use the pre-release 3.1.4 ISO:
- Check the Minix Wiki (here - I took notes - so follow along or skip).
- Start VMWare
- Create a new Virtual Machine (to use ISO).
- Click on 'new' bottom of window (for mac), Win/Linux chck command section of window.
- "Continue without disk"
- "Use an existing operarating system disk image file"
- then select ISO image from your download directory.
- Use 'Other' for OS type (not 64 bit, per the Minix Wiki)
- "Select Customize Setting" (menu pops up)
- Save as:
- Select name (VMware will use <Name> as a prefix of the VM later.
- I selected: Minix 3.1.4
- it is postfixed with .vmwarevm
- Hit "Save"
- You can change setting while VM is powered off storage
- 2 GB disk -> "apply" VMware creates a virtual disk
- 512 RAM
- Click to start booting from ISO
- Boot from ISO Image by clicking on VM image that appears on the left of the screen
- Chose "regular" if you have 16 MB of RAM o/w choose "small"
- log in as root (Yay!)
- no password (just hit return)
- You will now have access to several vitual terminals of your Minix OS, use (Mac=fn+option+F1/F2/F3) or (Win/Linux=Alt+F1/F2/F3) to see them.
- start setup script to install MINIX 3 on 'hard disk'
- just type:
- 'setup'
- works b/c it is in the default path /bin/setup
- answer the questions (straight forward)
- "lance" for ethernet (for VMware)
- 'setup'
- just type:
Shutdown Minix:
- Must be logged in as root: type 'shutdown -h'
- You can now suspend this VM, or close and exit if desired: (Win/Linux=WMwarePlayer->Troubleshoot->PowerOff and Exit) (Mac=VirtualMachine->PowerOff).
- To start again: Run VMware, click on your Minix virtual machine.
- Type
- boot at the prompt, or
- boot d0p0
- If that does not work, restart Minix:(Win/Linux=VMwarePlayer->Troubleshoot->reset) (Mac=VirtualMachine->Reset or ->PowerOn).
- or "send cntrl-d" from VMware to reboot.
Install Software
type packman and select additonal software, if you select all and have the same laptop that I have it will take 3 hours. Note you cannot select "update from internet", you have not set up networking (yet).
Use ftp to easily transfer files to/from Minix and your host OS:
- Start from Minix:
- Logged in as root, you can now add a user.
- Check the manpages on MINIX, man adduser.
- Example:
- adduser ingrid other /home/ingrid
- Example:
- Still logged in as root, set up telnet and ftp to run in the background on Minix so you can connect to it.
- See here:
- http://wiki.minix3.org/en/NetworkingConfiguration
- See here:
- Exit minix as root; 'exit'
- Login as your new user.
- You should be at your new user's home directory: 'pwd'
- Make a directory for your work: 'mkdir cs4730'; 'cd cs4730; 'mkdir project2;
- Create a sample file in there called 'test_on_minix.txt', using some text editor ('vi' or 'mined' (use ctrl+x to exit mined))
- Get Minix's IP address: 'ifconfig', this will be your current minix_ip_address
- Make sure you are connected to the outside world: 'ping atlas.cs.uga.edu'
- Problems?
- Try: Setting VMware to use NAT rather than bridged, and restart Minix (see instructions above for shutdown). (Mac=VirtualMachine->NetworkAdapter->NAT; Win/Linux= Devices->NetworkAdapter->NAT) This seems to solve most problems.
- Try: Setting your home router to use DHCP, and restart Minix (see instructions above for shutdown).
- Try enabling the services using the following command:
# intr -d tcpd telnet in.telnetd &
# intr -d tcpd ftp in.ftpd &
- Now, from your host machine
- Open a terminal window and cd to your class work directory.
- Create a sample file in there called 'test_on_host.txt', using some text editor.
- Connect to Minix via ftp: 'ftp minix_ip_address'
- Login as the user and password you just created.
- Check your location, you should be at the user's home dir. In your ftp window, type 'pwd'. Now cd to your work dir: 'cd csX730/project2'.
- Use ftp to move your files around. Use the commands 'get' and 'put' (or 'mget' mput' for multiple files) to push and pull your files. Try it:
- 'get test_on_minix.txt'
- 'put test_on_host.txt'
- Check both places and verify the files have been transferred.
- Type 'quit' to exit ftp and disconnect from Minix.
MINIX Familiarization
Once the network is active, you might want to install a few other applications to make your life easier (unless, of-course, you used the install all option above). For example, you might want an editor (such as vim), openssh (to exchange files between Minix and the outside world using scp), a new shell (such as bash), or a version control system (such as svn). Also, check out the source code of Minix that is located in /usr/src and get a feeling for which parts of the OS are located under which directories.
Once you have played around a little bit and have become more familiar with Minix, answer the following questions (you may use the Minix Wiki to answer these)
- What is the name of the application (utility) that you used to install new software in Minix?
- What is the command that you need to issue to rebuild the kernel and install it?
- What is the kernel source file that holds the Minix banner string (i.e., "MINIX 3.1.4. ...") that is shown when Minix boots up?
- What is the name of the Minix system call with the number 33 (decimal), and how did you determine this information?
- The answers to these questions have to be written in a plain ASCII file called discussion.txt, which you will need to submit as part of this project (see below for instructions).
Kernel Hack and Adding your Shell, YOSH to MINIX
At this point, it is time to rebuild the kernel. Go to:
/usr/src/tools and invoke make.
Check the options to see how a kernel can be rebuilt and installed. Make sure you select the third option "Start custom kernel" in the start screen so you run your new and freshly built and improved kernel.
When you are able to build a new kernel, it is finally time to make a small OS modification (and enter the realm of kernel hacking). First, however, you have to make a clean copy of the kernel source tree.
This is necessary for two reasons. First, when you later make changes that do not work and you want to have a reference that you can look at, the source is already there. Second, and more importantly, you need such a clean reference to create patches (see below).
So, just issue a cp -r /usr/src /usr/src.clean, and you are good to continue. Of course, you can additionally store (backup) your modified and clean source trees on a remote machine (using rsync or scp, for example) or using version control system.
For the kernel modification itself, you need to print out the name of every file that is being executed by the OS.
You should locate the kernel source file that implements the exec system call. Then, at the right point, you should insert a printf statement that outputs the string "executing ... " followed by the name of the file that is being executed. That is, when you type "ls" in the shell, you should see the string "executing ... " being printed to the console. More precisly, if a process executes /bin/ls, your code should print to the console "executing /bin/ls".
This should actually require only a single line to be added, but it provides you with some (very basic) debugging facilities. Once you have done your modification, rebuilt the kernel, install it, and reboot the system. When you were successful, you should now see a series of output statements that show you which programs the operating systems launches.
Your last task is to submit your changes to us. When dealing with large software systems (e.g., operating systems such as Linux), it does not make sense to send around the complete source code tree for every small change. For this, people invented patches. A patch captures the changes between two different files (oldfile and newfile). Given the oldfile and the patch, one can use the patch program to create the newfile. This is exactly what we want. So, when you have finished your kernel modification (including recompiling, installing, and testing everything), you switch to the /usr directory and produce a patch for each file that you have changed. For this, you invoke diff -c (path/to/oldfile) (path/to/newfile) and store the output in a file named mypatch. For example, when making a patch of the file /usr/src/servers/inet/clock.c, you would first change into the /usr directory and then do diff -c src.clean/servers/inet/clock.c src/servers/inet/clock.c. You can test whether your patch has worked by creating another copy of the source tree (e.g., /usr/test), change to /usr/test and run patch -p1 < mypatch. This should modify the clock.c file in the /usr/test tree accordingly. Also, note that this is how we test your patches, and we expect that they can be applied cleanly (without any warnings or errors).
Submitting:
Submitting:
|
Optional:
Install your shell that you created in project in the proper place and test it out and debug if needed.