How to Install and Modify Plan 9 from Bell Labs inside Qemu to see the leftovers from old Unix!

Not_OlesNot_Oles Hosting ProviderContent Writer

What?

Plan 9 from Bell Labs is an operating system from the creators of the C Programming Language and the Unix operating system.

Although Plan 9 revolutionized many aspects of Unix, it nevertheless still remains possible in 2025 for Unix fans to access aspects of old Unix by installing Plan 9 inside Qemu and changing the Plan 9 boot procedure so that Plan 9 stays in the terminal rather than starting a graphical monitor.

Why?

  • This method provides a text-only terminal with "infinite" scrollback. Infinite scrollback is how paper terminals used to work before the curses interface and the Graphical User Interface ("GUI") were invented.

  • Plan 9 runs on the i386 processor architecture in addition to many other architectures.

  • Plan 9 has very few system calls compared to other operating systems.

  • Plan 9 comes with full source code and build tools.

  • The code for Unix userland utilities which remain in Plan 9 is shorter than later versions.

  • Plan 9 is fast!

Why not?

  • This method, which perhaps involves the conflation of text and terminal, is arguably a complete misunderstanding of everything that's truly the greatest about Plan 9. See this excellent discussion (but be a little careful when reading, because possibly not everything that's said is 100% correct).

How?

Download Plan 9. Options include the classic Plan 9 from Bell Labs (used here, see links just below), as well as, probably, 9legacy and 9front, neither of which were tested for this post.

wget http://9p.io/plan9checksums.txt 
wget http://9p.io/plan9/download/plan9.iso.bz2

# md5 sum for the bz2 file used here:
# 5183b2d0f11fded871461416f8c78cfb  plan9.iso.bz2

Make a qemu disk image for our Plan 9 install.

# qemu-img create -f qcow2 plan9-console.qcow2 10G

Use your favorite VNC app set to localhost:5900. Relaunch the app if it crashes when Plan 9 switches from terminal to grraphics.

# ssh tom@toto -L 5900:localhost:5900 # VNC via ssh tunnel to your server from your local machine.

Install Plan 9. Usually it's easy, just boot the ISO and accept the defaults. There are lots of tutorials and videos about the installing Plan 9. Here below is a qemu command to start the install. This command doesn't use KVM. Not using KVM makes slower output, which is easier to read, but you might need to wait a minute for longer operations. If you wish, add KVM with -enable-kvm.

qemu-system-i386 \ 
  -vnc 127.0.0.1:0 \ 
  -hda plan9-console.qcow2 \
  -cdrom plan9.iso \
  -boot d

After Plan 9 is installed, you see the graphical Plan 9 (screenshot above). Edit plan9.ini with the Plan 9 VT-100 emulator and the ed editor.

# In the Plan 9 rio terminal, type vt
# In the vt terminal, type '9fat:' (Don't forget the colon!)
# ed /n/9fat/plan9.ini : 
#   - remove last two lines (monitor, and size)
#   - add a line which says console=0

After you change plan9.ini, you don't need VNC, just ssh into your server and run Qemu.

qemu-system-i386 \ # Not using KVM makes slower output, which is easier to read.
  -nographic \
  -hda plan9-console.qcow2 \
  -boot c

Here below is the output of the above. We can launch the Plan 9 versions of old Unix commands like awk and ed. We can get infinite scrollback, almost like a paper terminal.

tom@toto:~/plan9$ cat 20250228a-boot-messages
# 20250228 Boot Plan9 in Qemu with plan9.ini changed to remain in host node shell

tom@toto:~/plan9$ ./start-plan9-console

SeaBIOS (version 1.16.3-debian-1.16.3-2)


iPXE (https://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+06FC6F60+06F06F60 CA00



Booting from Hard Disk...
MBR...PBS1...
Plan 9 from Bell Labpcirouting: BIOS workaround: PCI.0.1.3 at pin 1 link 96 irq 10 -> 9
 disk loader

cpu0:  3091MHz GenuineIntel Celeron (cpuid: AX 0x0663 DX 0x781ABFD)
ELCR: 0C00
497M memory: 497M kernel data, 0M user, 18M swap
found partition #S/sdC0/data 0 20,971,520
disks: sdC0 sdD0
trying sdC0....found 9pcf
.1121326.....................................................................................................0
entry: 0xf0100020

Plan 9
E820: 00000000 0009fc00 memory
E820: 0009fc00 000a0000 reserved
E820: 000f0000 00100000 reserved
E820: 00100000 07fe0000 memory
E820: 07fe0000 08000000 reserved
E820: fffc0000 100000000 reserved
cpu0:  3096MHz GenuineIntel Celeron (cpuid: AX 0x0663 DX 0x781ABFD)
ELCR: 0C00
igbe: p->cls 0x0, setting to 0x10
#l0: i82543: 1Gbps port 0xFEB00000 irq 11: 525400123456
128M memory: 54M kernel data, 74M user, 297M swap
usbinit...usbd.../boot/usbd: /dev/usb: no hubs
no /srv/usb...no usb disk...pickmethod...read #e/nobootprompt...read #e/bootargs...outin...root is from (tcp,[ . . . copy paste error] 
pickmethod done
bind #æ...bind #S...partinit...auth...user[none]: glenda
usbinit...usbd.../boot/usbd: /dev/usb: no hubs
no /srv/usb...no usb disk...mount usbd...boot: can't open /srv/usb: '/srv/usb' file does not exist
time...
fossil(#S/sdC0/fossil)...version...can't stat /srv/partfs.sdXX: '/srv/partfs.sdXX' file does not exist

init: starting /bin/rc
rio: can't open display: initdisplay: /dev/draw/new: no frame buffer
init: rc exit status: rio 30: display open

init: starting /bin/rc
term% who am i
glenda
term% awk 
Usage: awk [-F fieldsep] [-mf n] [-mr n] [-v var=value] [-f programfile | 'program'] [file ...]
term% ed
a
hello
.
w hello
6
Q
term% ls -l hello
--rw-rw-r-- M 8 glenda glenda 6 Feb 28 21:07 hello
term% fshalt
syncing.../srv/fscons...prompt: 
halting.../srv/fscons...
prompt: 
done halting
Ctrl-a x # Quit qemu
tom@toto:~/plan9$ 

I hope everyone gets the servers they want!

Thanked by (3)cmeerw imok Decicus

Comments

  • Not_OlesNot_Oles Hosting ProviderContent Writer

    @Not_Oles said:

    Plan 9 comes with full source code and build tools.

    For example, here are the sources for Plan 9's rc shell.

    term% cd /sys/src/cmd/rc
    term% wc -l *
        486 code.c
       1006 exec.c
         76 exec.h
         67 fns.h
        233 getflags.c
          7 getflags.h
        259 glob.c
        232 havefork.c
        211 haventfork.c
        153 here.c
        297 io.c
         28 io.h
        387 lex.c
         63 mkfile
        148 pcmd.c
         77 pfnc.c
        672 plan9.c
        151 rc.h
         34 rcmain.unix
         20 run.unix
        536 simple.c
         77 subr.c
         91 syn.y
         37 trap.c
        148 tree.c
        592 unix.c
         53 unix.h
         91 var.c
        561 win32.c
       6793 total
    term% 
    

    I hope everyone gets the servers they want!

Sign In or Register to comment.