Run Linux in Browser [Qemu Javascript Emulator]

We often use emulators like Qemu, Virtualbox, VMWare to virtualize another Operating systems on a different platform.

Qemu is popular and open source emulator that lets you virtualize nearly any OS on any other OS. Qemu has now been ported to a new platform: Browsers. Most modern browsers like Chrome 11 and Firefox 4 can run this javascript based Emulator making it possible to run an actual Linux in your browser.

Since javascript is slower than native code, one would expect slower boot times for the Linux, but it boots amazingly fast. With a very minimal download and couple of seconds, your browser window boots into an actual Linux based on commandline. Ofcourse CLI-only makes the OS snappy for executing all your shell commands.

If you aren’t excited so far, read this again: “A PC emulator written in javascript, and running solely in browser“.

Try it now

Technical details of the Javascript based Qemu (read full)

This PC emulator is written entirely in Javascript. The emulated hardware is:

  • a 32 bit x86 compatible CPU
  • a 8259 Programmble Interrupt Controller
  • a 8254 Programmble Interrupt Timer
  • a 16450 UART.

The code is written in pure Javascript using Typed Arrays which are available in recent browsers. It was tested with Firefox 4 and Google Chrome 11 on Linux, Window and Mac. It doesn’t work with Opera.

CPU Emulation

The code is inspired from my x86 dynamic translator present in QEMU, but there are important differences because here it is an interpreter. The exact restrictions of the emulated CPU are:

  1. No FPU/MMX/SSE
  2. No segment limit and right checks when accessing memory (Linux does not rely on them for memory protection, so it is not an issue. The x86 emulator of QEMU has the same restriction).
  3. No CS/DS/ES/SS segment overrides. FS/GS overrides are implemented because they are needed for Thread Local Storage in Linux.
  4. A few seldom used instructions are missing (BCD operations, BOUND, …).
  5. No single-stepping
  6. No real mode
  7. No 16 bit protected mode (although most 16 bit instructions are present because they are needed to run 32 bit programs).

Most of these restrictions are easy to remove.

Linux distro & kernel

It runs 2.6.20 Linux kernel with configuration available here.

Boot

The disk image is just a ram disk image loaded at boot time. It contains a filesystem generated with Buildroot containing BusyBox. I added my toy C compiler TinyCC and my unfinished but usable emacs clone QEmacs.

Javascript Performance

PC emulator is about 2 times slower using V8 than Jaeger Monkey on 32bit desktops.

I still have to try this on mobile browsers, let me know if that works for you.

We write latest and greatest in Tech GuidesAppleiPhoneTabletsAndroid,  Open Source, Latest in Tech, subscribe to us@geeknizer on Twitter OR on Facebook Fanpage:

GD Star Rating
loading...
GD Star Rating
loading...
Run Linux in Browser [Qemu Javascript Emulator], 10.0 out of 10 based on 3 ratings

12 thoughts on “Run Linux in Browser [Qemu Javascript Emulator]”

  1.  To describe this as a port is misleading: it isn’t. It’s an x86 emulator, as is qemu, as are many other things.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  2.  To describe this as a port is misleading: it isn’t. It’s an x86 emulator, as is qemu, as are many other things.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  3.  Are you for real?  The entire text of this ‘article’ is just you copy-pasting from the original authors technical notes page.  Literally, you just ripped it verbatim.  Sad

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  4.  Are you for real?  The entire text of this ‘article’ is just you copy-pasting from the original authors technical notes page.  Literally, you just ripped it verbatim.  Sad

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
  5.  Does NOT work on the android native browser, however….

    It runs ((VERY VERY SLOWLY)) under Firefox mobile on Android.
    Unusable, yes. Awesome. Also yes.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply
    • Actually, it works on the native browser (on Android 2.3.4 at least), which boots in 140 seconds on my Desire. Firefox mobile can boot it in 86 seconds, but it’s impossible to type anything at the prompt.

      GD Star Rating
      loading...
      GD Star Rating
      loading...
      Reply
  6.  Does NOT work on the android native browser, however….

    It runs ((VERY VERY SLOWLY)) under Firefox mobile on Android.
    Unusable, yes. Awesome. Also yes.

    GD Star Rating
    loading...
    GD Star Rating
    loading...
    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.