Friday 25 July 2008

X on Minix 3 AT LAST

I like to keep a load of Free Software operating systems around in hard drive images, but I've been rather annoyed at Minix 3. Until today I couldn't get either networking or X to run (although the latter may be a result of the former), however now I have and for myself and anybody Googling this in the future, here is how to get Minix 3.1.2 running nicely in KVM (and of course Qemu, upon which KVM is based). 3.1.3 has a bug which stops PCI/networking working in Qemu and KVM, so we'll have to make do with the slightly older 3.1.2 until an even newer release is made which fixes this regression.

0) Make sure you have a working installation of Qemu. This is outside the scope of this post, Google is your friend. Also keep in mind that I am writing this guide mainly for Linux. To use them on a Windows or OSX machine install this first.

1) Download the IDE CD of Minix 3 from the download page (3.1.2a as of this writing).

2) Whilst this is downloading you can make a hard drive image where we'll install Minix 3. You can do this by running the command "qemu-img create -f qcow2 MinixDrive 1G"

3) Decompress the downloaded CD image so it is regular ISO9660 format.

4) Run this command to start up your emulator (of course, replace the command and filenames to whatever you're using) "kvm -localtime -net user -net nic -m 512 -std-vga -cdrom MinixCD.iso -hda MinixDrive -boot d". This will run the Kernel-based Virtual Machine with 512MB of memory, VGA graphics and NAT-style networking, using MinixDrive as a hard drive and MinixCD.iso as a CD, booting from the CD.

5) Boot into the CD, press 1 to boot the regular Minix system and log in with the username "root".

6) Run the command "setup" and proceed through the steps (you can skip the bad block check since you're not using a real hard drive). For networking choose the Qemu emulated one (it tells you which that is).

7) When the setup is finished run the command "shutdown". Minix will shut down to a prompt, now close the virtual machine.

8) OK, Minix is installed so now we need to configure it. Run this command to boot into the virtual hard drive but keeping the CD accessible "kvm -localtime -net user -net nic -m 512 -std-vga -cdrom MinixCD.iso -hda MinixDrive -boot c".

9) Wait until you're prompted for the login and enter "root". Now that you're in we need to shut it down (trust me :P ). Run the command "shutdown", which will take you to the boot prompt again. Once here run this command "qemu_pci=1" then run "save" then run "boot", which will start Minix 3 back up again, only this time it has a hack to get Qemu's emulated PCI devices working.

10) Log in as root again and run "packman", the basic package manager which comes with Minix. Install a text editor from the CD (emacs, vi, etc., I'm not going to get into a flame war :P ) and use it to edit the file /etc/inet.conf. Make it say the following:

eth0 rt18139 0 { default; };

Then save it.

11) Using your editor once again make the file /usr/etc/rc.local read as the following:

rt18139_arg='DPETH0=pci'

Then save it. Shut down, close the virtual machine and start it up again using the last command we used. Congratulations, you should now be networked! Next up, graphics!

12) In Minix, as root, run "packman" and tell it that you want it to download a package list if it asks. Install the package X11R6.8.2 (the X graphics server), then install efltk, then ede. (I would go for the net ones over the CD ones unless your Internet connection is incredibly poor)

13) Quit the package manager then run "xorgconfig" to set up the X settings. Answer the questions as you normally would, but make sure you put the mouse device as /dev/kbdaux and make up values for monitor horizontal and vertical frequencies and video card RAM. Set the video card driver as "cirrus" (option 11 I think). Choose the resolutions you want the WINDOW SIZE to be, which are not neccessarily the same as that of your actual physical screen (unless you use it full screen with Ctrl-Alt-F).

14) When the tool has finished and written the /etc/X11/xorg.conf file we need to fiddle with it a bit, so open it up in your editor. Look for the horizontal and vertical frequency lines in the Monitor section and comment them out (put a "#" at the beginning). Under the video card make sure the video RAM line is also commented out. Look for the "Standard VGA" device and set its driver to "vesa", then under the "Screen" section set the Device to "Standard VGA" (we made the cirrus device as a backup, since Qemu can emulate both).

15) Save the file then give X a little more memory to work with using the command "chmem =80000000 /usr/X11R6/bin/Xorg"

16) Run the X server with the command "startx", and if all goes according to plan you should see X start up with some xterms open.

17) To run the minimalist, Windows-lookalike Equinox Desktop Environment you'll want to get the process ID of TWM using "ps ax | grep twm" then "kill 1234" (where 1234 is the process id for twm), then run "eworkpanel", "eiconman" and "edewm" to get EDE running. you can probably edit the startx script to do this, but I haven't gotten around to that yet.

Well that's it. I'm afraid there's not much available for Minix at the moment, but hopefully the availability of X, the lynx web browser, wget, CVS, SVN, Vi and Emacs will make Minix bearable as a bare development environment, thus facilitating the porting of more and more programs. Since Python is available it is also pretty easy to make housekeeping and convenience scripts to reduce some the roughness and backwardness.

Since PIX OR IT DIDN'T HAPPEN here's a screenshot (although, of course, a high-reliability microkernel UNIX system cannot really be captured by a screenshot :P )

PS: Saving two patients at once? I'm still not convinced...

2 comments:

Mike B. said...

Thanks for the blog entry about Minux 3.x. I wasted most of my weekend with Minix3 and VirtualBox before I found your post. Minix is rather slow and there are plenty of rough edges but your blog helped me realize which sharp edges we causing the most damage.

Thanks again,
Mike

Anonymous said...

thanks alot dude i had problem running the X window but 10qs to u i have a running window. keep up the dude work man thanks again

Rad