Wednesday, June 14, 2006

Running Minix under qemu

Qemu is an open source CPU emulator. It can be used to run Minix quite nicely. I use Linux as my main operating system so these instructions are geared towards running qemu under Linux but it's possible to run under Windows too. Qemu version 0.8.1 is the version I used. I tried earlier versions but had some networking problems.

The first step is to create a disk image for Minix. This will appear to Minix running inside qemu as a hard drive. I use a 2GB image but smaller images are quite workable. Minix 3 with all contributed binaries installed takes about 500MB. Without the contributed binaries it's about 80MB I think. The reason I went for the 2GB image is to enable including all the source for all the included programs and to be able to develop software as well. Create the image using 'qemu-img':
qemu-img create minix.img 2G

This will create a 2GB file. Qemu does have a 'copy on write' format which grows the file as needed. You can try that with:
qemu-img create -f qcow minix.img 2G

I had random segfaults when trying this but it may have been due to other issues. The nice thing about it is the initial file is very small.

With the file created and the Minix 3 IDE CD-ROM image downloaded you can start the install process:
qemu -localtime -net user -net nic -m 128 -cdrom IDE-3.1.2a.iso -hda minix.img -boot d

This command will boot Minix from the IDE CD-ROM image inside of qemu. The '-m 128' indicates we want 128MB of memory to be provided to the Minix system. Any amount can be used here, the more the better if you want to use X11.

The initial boot process will take you through to a login prompt. Login as 'root', no password and run 'setup'.
# setup

From here work through the prompts. The main thing to watch out for is the request for the network card type. Use option (4), the Realtek 8029, as this is emulated by qemu.

As a disk image is being used you can safely avoid the check for bad disk blocks by pressing CTRL+C.

Once the 'setup' is completed, use 'shutdown' to safely close Minix down. When the boot prompt appears after the 'shutdown' command, close qemu.
# shutdown
fd0>

Now we restart qemu but change the '-boot d' parameter to '-boot c' to boot off our newly installed Minix image. We need to make one important change before the system boots to enable the network card though. Minix requires a parameter to be set, qemu_pci=1. This can be done once and saved to the image. The easiest approach is to start the new image, ignore the network errors, login as root, shutdown, set qemu_pci=1, save it, then reboot:
qemu -localtime -net user -net nic -m 128 -cdrom IDE-3.1.2a.iso -hda minix.img -boot c
...login as root...
# shutdown
d0p0s0> qemu_pci=1
save
boot

This system will boot again and the network card should work. From now on you can start by using the qemu command as above, there's no need to set the parameter again.

You should change your 'root' password as soon as possible. Use 'passwd' to do this:
# passwd

Once logged in as root you can use 'packman' to install packages:
# packman

This will bring up a list of packages which you can install, including gcc, X11, various GNU tools, etc.

Categories: , ,

18 Comments:

Blogger ozzmosis said...

Just FYI - I tried booting the Minix 3.1.2a CD using KQEMU with QEMU 0.8.1 but the kernel freezes after loading init. I had to use -no-kqemu to get it to boot.

- ozz

6:08 PM  
Blogger Chris Double said...

Thanks for the note, I hadn't tried it with kqemu.

9:28 AM  
Anonymous Felipe Caballero said...

Hi there.

Nice Blog you have.

I just did what you where talking here (qemu_pci=1). networking works fine but I get a big list of errors when minix starts loading.
Is it Normal?

What about xsm, it's not working for me. Do you know what to do?


Cheers.

5:13 PM  
Blogger Mattieous said...

Hi,

I tried to launch qmenu as you wrote (qemu -localtime -net user -m 128 -cdrom IDE-3.1.2a.iso -hda minix1.img -boot d)
and I got this message :
"Could not open '\\.\kqemu' - QEMU acceleration layer not activated
qemu: could not load PC bios '/c/Program Files/Qemu/bios.bin'"
I use Windows Xp Professional.

any help

thanks

12:17 AM  
Anonymous Anonymous said...

mattieous: qemu -L . etc..
read the README-en.txt

3:54 AM  
Anonymous Swampfootjoe said...

Great !!!!,
Thanks a lot, this qemu-pci thingie works great for me.

6:23 AM  
Blogger wayo said...

I just used this tip this morning doublec. Thanks! (dharmatech)

8:13 AM  
Anonymous StormSilver said...

Fantastic. Minix 3 runs!

Question: Has anyone had any experience with mounting their Minix QEMU image on the host OS (such as Linux)?

1:28 PM  
Blogger Chris Double said...

I haven't tried, sorry. Hopefully someone else can help.

10:58 AM  
Anonymous Anonymous said...

The minix filesystem has changed with minix3, in order to support it you'll need to patch your Linux kernel. I haven't been able to mount the minix image either, but http://www.terra.es/personal2/danarag and (for mounting qemu-images) http://kidsquid.com/cgi-bin/moin.cgi/HurdOnQemu would be good places to start.

cheers,
Alex

6:33 AM  
Blogger Arindam Roy said...

Great post. I think your and my blogs put together can easily become a good tool for installing minix.
Thanks,
Arindam

6:39 AM  
Anonymous Anonymous said...

I tried to launch qmenu as you wrote (qemu -localtime -net user -net -m 128 -cdrom IDE-3.1.2a.iso -hda minix1.img -boot d)
and I got this message :
"Could not open hard disk image 'IDE-3.1.2a.iso "
I am using Debian

2:38 PM  
Anonymous Anonymous said...

Hi

I tried to launch qemu as you wrote (qemu -localtime -net user -net -m 128 -cdrom IDE-3.1.2a.iso -hda minix1.img -boot d)
and I got this message :
"Could not open hard disk image 'IDE-3.1.2a.iso "
I am using Debian

Any help?

Thanks

2:41 PM  
Blogger sancho1980 said...

I tried with your steps but every time I try to install minix on the vm I get "Probing for disks. This may take a short while..Floating exception - core dumped Autopart tool failed. Trying again. /dev/ is not a block device."

7:05 AM  
Anonymous Anonymous said...

Thanks for the info, very useful. I've taken the liberty of using your notes to edit the minix wiki entry on running minix under qemu at http://wiki.minix3.org/wikis/minix3/Running_MINIX_3_on_Qemu

8:21 PM  
Blogger Stijn Leenknegt said...

Nice post. But my the network step doesn't work for me. It give me "Panic PCI".

8:55 AM  
Anonymous Sudhansu Goyal said...

Hello

i was also trying to run Minix 3 on windows using Qemu i was getting this error---

qemu: could not load PC BIOS '/c/Program Files/Qemu/bios.bin'

than i used this command and got success in running Minix on Qemu in windows---

qemu -localtime -net user -net nic -m 256 -cdrom IDE-3.1.2a.iso -hda minix.img -boot d -L "c:\Program Files\Qemu" -no-kqemu

9:40 PM  
Blogger JP-) said...

I downloaded the MINIX 3.1.2a and I have the same freezing problem just after loading the init. Even using the paramether -no-kqemu or running it on Windows XP, the error persisted.

However the 3.1.0 (book version) has worked just fine.

10:42 PM  

Post a Comment

<< Home