Hacker News new | past | comments | ask | show | jobs | submit login
Jor1k: Run Linux in the browser with multicore and network support (github.com)
161 points by hsnewman 7 days ago | hide | past | web | favorite | 38 comments

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!

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.

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.

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.

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.

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.

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

You are free to try it. I think it is possible. The shell has enough built in functions such as echo. One decade ago I read some blog article describing a possible way. First step is to set an alias 'alias ls="echo *"'.

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

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...

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

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

This is interesting and very impressive, though if you go to a website like http://ifconfig.io you get a different IP then your own public IP.

Wouldn’t that be expected?

Not if it's running entirely in my browser and therefore using my network stack - in the same way "icanhazip.com" when looked at in your browser should show your own IP.

edit: `curl icanhazip.com` returns which seems to belong to digital ocean. It also matches the host relay.widgetry.org which is refered in the demo URL as as a "relayURL". I have no idea how it's working or why though - the lack of ip or ifconfig in the VM upsets me ;)

Maybe they tunnel all network requests through their server to make it work? Afaik you can't just make arbitrary tcp/udp request from a webpage to any host, so they must be tunneling the data via their own server.

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...). So what's next?

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


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.

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).

On iOS, you can type in the clipboard section. On Firefox on Android, it seems to work except for backspace. Chrome on Android doesn't seem to work at all, though.

EDIT: Hacker's Keyboard has an option to have a notification to bring it up

It works from here with an external keyboard for the text console, but the mapping of taps to mouse clicks in the X11 session is not quite right, so that part does not work.

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

I think KVM is more appropriate and performant.

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.

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.

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.

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.

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

Looks really nice!

Seems to work better on Firefox than on Chrome

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.

~ $ ping www.google.com

ping: bad address 'www.google.com'

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

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

I think your behind a proxy.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact