Note: This process is currently broken and seems to throw up unexpected errors. I am trying to look for a solution but the internet is just not helping me at the time of writing this. Until I figure out a way to fix this, I recommend trying out NachOS or xv6 for your OS cravings.
PintOS is one brilliant skeletal Operating System and, given the right time and effort, is a great way to consolidate your knowledge on the design of modern operating systems. However, its installation can be quite a pain especially since the instructions on Stanford’s official site can be a tad bit confusing at times. Here I will walk you through the installation instructions. If you would rather just install than spend time reading my post, feel free to download an install script I wrote to automate the installation process from here: pintosInstall.
If you are using the script, please remember to change the file extension as WordPress does not accept .sh files. After that just run “bash pintosInstall.sh”, without the quotes, from a terminal for a completely automatic process. Also, while I can guarantee you the script runs well on Ubuntu in a folder you have root access to, the script is simple and generic enough for you to hack and customize to your distribution if required.
- Install some pre-requisites: GCC, Perl, QEMU, Make, GDB. Just run:
sudo apt-get install gcc binutils perl make qemu gdb
- Create and installation folder. The script makes a folder ‘co302’ (the course number for OS in my college).
- Download the PintOS tar from here and extract it in the installation folder. I used the totally awesome wget tool in Linux (just like Mark Zuckerberg in the Social Network 😛 ).
- We need a folder where the PATH variable can point to, as it will have some executables that we need to run when coding the OS. I made a folder ‘bin’ in the base installation directory i.e. co302/pintos/bin.
- Move all the perl scripts from the src/utils folder of PintOS to the bin/ folder. The important ones are ‘backtrace’, ‘pintos’, ‘pintos-gdb’ and ‘pintos-mkdisk’.
- Edit your .bashrc file to add the path for the above bin/ folder. At the end of the .bashrc file, simply add the line
Again for this, I have used the awk tool as it provides a convenient, independent way to edit files programmantically.
- Now we have to make a change to one of the PintOS files. Open up the ‘pintos-gdb’ file (in Emacs I hope) and edit the GDBMACROS variable to point to the ‘gdb-macros’ file in misc directory of the src directory. At this point, you have officially installed PintOS, so give yourself a pat on the back.
- Time to compile the utilities. Head over to the pintos/src/utils directory and run
. If you get a “Undefined reference to ‘floor’ ” error, simply open the Makefile and substitute LDFLAGS for LDLIBS and run make again.
- Copy the ‘squish-pty’ file to the PATH pointed bin directory.
- Head over to the pintos/src/threads/ directory and edit the ‘Make.vars’ file. Change the SIMULATOR variable from bochs to qemu, which should mostly be the last line of the file.
- Run make on the threads folder.
- Now we need to edit the ‘pintos’ util file in the bin directory with 3 edits. Many other sites will give you the line numbers, but I will not use that as it is too variable and you get a chance to experiment with the text processing features of your favorite editor:
- Change $sim = bochs to $sim = qemu to enforce qemu as the simulator.
- Comment out the line push (@cmd, ‘-no-kqemu’); by prepending it with #.
- Put in the absolute path wherever required as Perl doesn’t seem to be able to interpret the ~ shorthand. Do this especially for the kernel.bin location path.
- Finally, edit the ‘Pintos.pm’ file in the bin directory and put in the absolute path for the line having the location of the loader.bin file.
- Congrats, you now have PintOS set up on your machine. Try running pintos run alarm-multiple as a test.
There you have it. A pretty easy and straightforward way to install a great experimental skeletal OS from Stanford University. I bet it took more work for me to write this up that it will take you to install PintOS. The good part about this little adventure of mine is that I got a chance to dabble in sed and awk, 2 Unix tools that no hacker can afford to not know the basics of. Add to that some wget magic and Emacs power, and you can potentially become a hacking superstar. Infact, this hack has proven really useful as the Computer Engineering department of my college has used it to install PintOS on all the machines so that the students can do meaningful OS practicals. My small way of giving back, you could say. 🙂
As a final note, at the time of writing, this post is as comprehensive a set of instructions you can get. This may not hold true forever as tomorrow someone might make some script-breaking changes. So if you find some change that I need to include, please feel free to comment and let me know about it.