Remote OS

in remoteos •  7 years ago 

2 computers.jpg
Feb 20, 2018

For logistical reasons over the last couple of weeks, I needed to work on multiple computers (even switching machines more than once in the same day). This issue inspired me to write about the various ways of achieving reproduction of work environment on multiple machines.

Say your are the CTO of a VR and your computer breaks! You could buy another one and move on, or you could have fun and discover how to seamlessly your linux workstation from both VR computers at all times. I develop on linux. I find it easier for some reason. But concerning video card drivers, Windows is where you’re really able to harness the true graphic power needed for VR. So I was confronted with the problem of having to run a single environment in Linux on a windows computer that I wasn’t able to reboot all day long.

The specs
I need to be able to run:

an Archlinux based distribution. I’ve been using this distro for a few years (since ‘09, after I gave up trying to install Gentoo ^^) and I really like it.
accessible from 2 workstations
at anytime with internet
have access to windows to run VR at anytime
have the same workstation configuration on both computer at all times
usable workspace (no lag)
Spec 4. alone renders dual booting an archlinux partition on both laptops impossible.

The solutions
SSHing into a server from both windows machines
Setting up a server is tough. But services like Digital Ocean make it affordable to have something pretty cool. Unfortunately, Digital Ocean doesn’t offer Archlinux anymore, so I setup an Ubuntu, spec 1 is missed.

Installing Putty on both Windows machines allows me to connect to the server from windows. I now have access to the same computer from both windows machines over the wire. I can be on one computer one moment and in the next moment be on the second machine while maintaining access to the same computer. Emacs -nw gives me a more powerful tmux on top of that inside Putty, the dream.

That’s all pretty sweet, but developing over SSH is unfortunately never ideal. You’re confronted with latency problems and connection drops. And there is nothing more infuriating than waiting longer than necessary for you editor to catch up with your keyboard.

So how did we do on the spec ?

miss
yes
yes
yes
yes
miss
SSHing from emacs on both windows
The better way to edit remote files with emacs is to run it natively and ssh from emacs. The lag disappears. In my case however, that implied keeping 2 windows configurations of emacs in sync. Not ideal, but very doable (we’ll investigate some of the ways later in this article).

Virtual machines
Luckily, we’re a VR startup, so virtual machines are a possibility. Setting up an Arch image would allow me to boot on to Linux from the Windows machines without requiring a reboot. Performance is affected, but gamer computers are strong and it’s worth a try. Once installing VirtualBox on both Windows computers, it’s just a matter of keeping the images in sync. Note that the images could be as much as 50 gig. This image would be my actual computer.

Obviously one has to be careful syncing this way. I recommend to never have both VirtualBox opened to make sure there is never any write order race condition between the 2 computers.

Keeping the images in sync
RSync
RSync is a utility that allows to sync to remote repositories over the wire. So I can keep a folder in sync from two different computers. On a local area network, that’s pretty fast. What’s interesting is that RSync is efficient in the way it keeps the folders in sync. When I install a package on my Archlinux and save the image, I wouldn’t want to have to re-sync the entire image. RSync is smart and does a binary diff in order to sync only the difference in byte between folders to be kept in sync.

Dropbox
Dropbox allows for the same thing as RSync, with binary diff as well, but over the cloud. Latency is hurt because when switching computers, computer A saves the image, uploads the diff to Dropbox, while computer B then gets notified before finally downloading the diff and merging it.

Conclusion
There are a multitude of ways that allow us to keep 2 workstations in sync, each with its own set of catches. I found that keeping my image over Dropbox was a good enough deal. Although syncing time can take a small while. I will try to switch to rsync between the 2 Windows machines. But I can’t really bare using Windows anymore. It’s too different from what I expect a computer to do…

Worth mentioning
SSHFS
You can mount a remote folder as a partition using SSHFS. The problem however being that you download every file every time you open it. SSHFS has a cache but for development with npm and pip, it’s not ideal since folders can have so many files, read access needs to be fast which it is not with SSHFS.

VNC
I’d rather use VMs, which I do. Much better performance.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!