cat /dev/brain/rand > /srv/tumblr

Mar 13 2011

Plan 9 CPU server on a floppy

One of the nice things about Plan 9 is that it has separate cpu, auth, and file servers. This means it’s possible to have a diskless CPU server for running numerical stuff that connects to a remote auth and file server. This quite a useful case for me, as I can for example quickly setup any machine as a CPU server and use it to run my numerical code off my file server. I’m going to outline the steps needed here to create a boot floppy (yes floppy) for launching a CPU server. In particular, I’ve been looking at doing this using virtualisation via QEMU.

The first step is to create a kernel that is small enough to fit on a floppy. This can be accomplished by removing fossil and venti from the kernel — as we’re creating a pure CPU server there’s no need for these file systems anyway.

    cd /sys/src/9/pc
    cat pccpuf | sed 's,^.*fossil/fossil.*,#&,' | sed 's,^.*venti/venti.*,#&,' >pccpufu

I’m using KVM on multicore machines, so I want to have SMP capabilities. Unfortunately, I had some trouble with the APIC code in the Plan 9 kernel with KVM virtualised processors. To get it to boot with multiple processors I had to disable the LAPIC frequency check (not a good solution) in /sys/src/9/pc/apic.c:

    344c344
    <           if(lapictimer.hz > hz+(hz/10))
    ---
    >           /*if(lapictimer.hz > hz+(hz/10))
    346c346
    <                   lapictimer.hz, hz);
    ---
    >                   lapictimer.hz, hz);*/

Now the kernel can be compiled:

    mk 'CONF=pccpufu'

The next step is to create a plan9.ini boot file specifying which kernel to load and what fileserver and authservers to use. This is fairly straight forward:

    ramfs
    cat > /tmp/plan9.ini << EOF
    nvr=fd!0!plan9.nvr
    bootfile=fd0!dos!9pccpufu.gz
    bootargs=tcp
    nobootprompt=tcp
    mouseport=ps2
    sysname=rubis
    fs=192.168.0.2
    auth=192.168.0.2
    EOF

The last three lines should be changed depending on your network configuration. If fs and auth are not specified it will be prompted for during boot. Now the boot floppy can be created, mounted, and the kernel copied across:

    pc/bootfloppy /tmp/cpusrv.img /tmp/plan9.ini
    dossrv
    mount -c /srv/dos /n/a: /tmp/cpusrv.img
    gzip < /sys/src/9/pc/9pccpufu > /n/a:/9pccpufu.gz
    unmount /n/a:

That’s it, /tmp/cpusrv.img should be a boot floppy. Launching it using KVM should be as simple as

    qemu -no-kvm-irqchip -fda cpusrv.img -net nic -net user -redir tcp:17010::17010

Of couse you may wish to use more than one cpu (-smp) and more ram (-m).

Bugs

  • The hack I used to get it to boot under QEMU with SMP is obviously not a good solution. The problem may well lie with QEMU not with Plan 9 and I need to investigate more thoroughly.
  • Probably related, but it does not boot under QEMU with more than 8 CPUs.

References

11 notes

  1. enki2 reblogged this from jbedo
  2. jbedo posted this
Page 1 of 1