
Jor1k: Run Linux in the browser with multicore and network support - hsnewman
https://github.com/s-macke/jor1k
======
rrauenza
I su'ed to root and then ran rm -rf.

It was really weird how my instincts fought me with every keystroke! I was
just sure I was going to screw up someone else's server - not this transient
VM in my browser.

It worked, btw -- I got a perfectly unusable system!

~~~
s-macke
Actually, this is not the end. Try "echo *" to simulate a "ls" command and
"cd" to change the directories. Also the busybox executable is still in memory
, so you might be able to extract the binary from /proc/{pid}/mem . Busybox is
a single static compiled executable which contains all the basic shell tools.
Probaby you can also just paste new executables into the shell via echo and
pipes.

~~~
dsamarin
Is there any hope to save the system during a system reboot? I guess I would
need to recreate the kernel binary from RAM memory.

~~~
s-macke
In this emulator the kernel is not stored in the filesystem. It is downloaded
separately and put into memory. But usually the kernel is at a fixed location
in physical memory. So you might be able to receive the kernel image from
/dev/mem. But, as far as I know the init routines memory is freed after boot.
So I guess crucial information is lost forever.

~~~
Doxin
Ah but couldn't you, once you've gotten your essential tools back to a working
state, get the missing kernel bits from the internet before you reboot?

It'd be an interesting challenge. Get a linux vm, sudo rm -rf everything, and
then see if you can get the system back to more or less the original state.

~~~
cipherboy
Wouldn't the easier path be to rewrite the filesystem table to undo the
deletions? You'd need to be very careful to only write necessary tools into
memory, but since deleting files typically only changes the filesystem table
and doesn't remove the contents of the sectors, you might be able to get
enough of a working system to reinstall what is left. I'd reach for photorec
since I'm lazy, but you'd need to bootstrap it with glibc and a few other
dependencies. Not sure how you'd mount the ramdisk though... just hexdump,
less, and dd would be minimally sufficient, though much, much harder.

~~~
s-macke
For this emulator the filesystem is a RAM filesystem and fully managed in
Javascript (virtio/9p filesystem as a device). No chance to recover.

------
pietroglyph
Very impressive! You can even start an X11 session (startx), open dillo (a web
browser), and open the emulator webpage within itself!

~~~
grapeli23
Two years ago I started Chromium under Bellard JSLinux. The only version (32)
I found that did not require SSE instructions.
[https://drive.google.com/open?id=0BwO8xuhb9OwrV1ZzT3ktX3hPb0...](https://drive.google.com/open?id=0BwO8xuhb9OwrV1ZzT3ktX3hPb00)

~~~
MuffinFlavored
Both this and JSLinux don't implement X86, right?

~~~
dwild
JSLinux is running an X86 emulator. You can start Windows 2000 on it.

------
ngaut
This is so cool. Now we are able to run operating system in the browser, and
we are able to run database in the browser([https://pingcap.com/blog/how-we-
compiled-a-golang-database-i...](https://pingcap.com/blog/how-we-compiled-a-
golang-database-in-the-browser-using-webassembly/)). So what's next?

~~~
bradknowles
I heard you like browsers, so I put a browser in your browser.

;)

~~~
JoshTriplett
[https://www.browserling.com/](https://www.browserling.com/)

------
tomcooks
Would this be a viable way to use a TAILS-like system without requiring a
physical computer to boot it?

~~~
flatiron
I think KVM is more appropriate and performant.

------
watersb
Boots and runs ok in Chrome on my Android 10 phone, but I guess I need an
external keyboard. Android doesn't see any need text input, so no on-screen
keyboard.

Does anyone happen to know if there is a general workaround for this
situation? I often hit this obstacle in other browser-based emulators.

~~~
nemosaltat
I’d love to know also. I’ve been goofing with ways to get more use out of the
massive display in my Model 3 (while parked obviously).

------
hoistbypetard
The demo oh-so-briefly freaked me out. It uses the same RFC 1918 subnet I use
on my VPN. So for about 10 seconds, I thought something local was leaking to
javascript that probably shouldn't.

This is really cool, and performance-wise feels like the (even-then-ancient)
surplus PC that I bought ca. fall 1995 to install slackware on. Which is to
say, shockingly not-bad when you think about the stack it's sitting on.

~~~
s-macke
Actually it was much faster some time ago. At least on Firefox. This emulator
is basically a microbenchmark of the switch/case implementation of the
browser. Firefox used a computed goto, which is perfect in this case. Now for
some reasons it got slower. I have to take a look at the generated code to be
really sure about what is happening here and what to do about it.

~~~
hoistbypetard
That is really interesting. I was using it in vivaldi on desktop and chrome on
android, fwiw. I have to wonder what wasm might help... maybe the additional
overhead on the VT and framebuffer would be so high it'd be a wash.

~~~
s-macke
WebAssembly does not work on this low level. You cannot choose the switch/case
implementation. Also it doesn't support goto. The reason is security and
speed. The wasm-binary should be checked in O(n) and not in O(n^2). But I am
curious about the future versions of webassembly.

There is already a wasm version of the CPU emulation. I will enable it at some
point as default. But there is no speedup yet.

------
z92
Next we need someone to come up with Docker in browser and then you can run
almost anything in the browser.

------
fredley
Exceptional Atwood's Law example.

[https://blog.codinghorror.com/the-principle-of-least-
power/](https://blog.codinghorror.com/the-principle-of-least-power/)

------
handoff
Looks really nice!

Seems to work better on Firefox than on Chrome

~~~
s-macke
This emulator was optimized for Firefox and its JIT compiler. One or two years
ago it was at least three times faster on Firefox than on Chrome. What
unfortunately always happens with extreme optimization is that every small
change in hardware or software can lead to massive performance problems.

------
m00dy
~ $ ping www.google.com

ping: bad address 'www.google.com'

:( I thought it was going to work out of box.

~~~
s-macke
It works for me. Maybe you didn't receive IP address from the dhcp server in
time. Just refresh the page and try again.

