How I work with Linux and Windows together
Published: 2020-12-08 11:56:30

I am a hobby programmer who loves to make games, desktop applications and websites. For some task, I use Linux, while for others I use Windows. But how do I manage to work with two different systems and file management? I'll give you an insight into my computer setup.

## My main workstation

Personally I love Linux. It's very easy to code for it: `apt-get install g++` and you're ready to compile your C++ program. `apt-get install terminator` and I'm ready to use my favorite terminal.

But I don't only use this computer for programming. Nearly everything else I do on a computer, such as watching videos or chatting with friends, I do here. I can do almost everything I need.

## Where Linux only is not sufficient

Unfortunately, there are some things I can't do on my Linux computer or what simply works better on Windows. Some computer games for example. Or some programs for creating games or music such as Unity or Cubase.

For that reason, I bought a second computer only for running Windows. I'm aware of dual-booting. I could simply shut down Linux, switch to Windows and vice versa. But it's too much time consuming, especially, if I only want to quickly test something out.

## Two computers, one keyboard

If you think about working with two computers, you might probably imagine also having two keyboards and two mice on your desk, or at least switching the cables every time you want to switch the computer. I don't have this!

On my desk, there's only one keyboard, only one mouse, and I can switch between the two computers instantly. There's a program on the internet that allows me to do so: [Synergy](https://symless.com/synergy). I install that programm on my Linux and on my Windows computer, configure it and tell the Linux instance, that this is my host. This is where my keyboard and mouse is physically connected to.

Now, I simply move with my mouse to the right out of the Linux monitor and it appears on my Windows monitor. All keyboard and mouse input is now redirected to my Windows comptuer. I move my mouse back to the left where my Linux monitor is and all keyboard and mouse input goes back to my host system. It's incredible magic and working really great!

By the way, it also allows me to copy and paste text :)

## File sharing

Now that I can seamlessly create my 3D models on Linux and create a Unity game on Windows, or code my game in C++ on Linux and make the music for it in Cubase on Windows, how do I get the files from one computer to the other?

### NAS

One thing I tried is a [network-attached storage](https://en.wikipedia.org/wiki/Network-attached_storage), or NAS for short. It works really fine for moving individual files and folders between my computers and backing up my files on the NAS.

However, when it's about to have whole projects living on the NAS instead on one of the computers, I feel the bottleneck - at least for my NAS. I created a new Unity project on Windows and I selected a folder on the NAS. I immediately noticed how much slower Unity was working if the whole project is living on the (local) network. I couldn't work really well with that, so I need a different solution.

### rsync

The next solution, I came up with quite recently, is working with [rsync](https://en.wikipedia.org/wiki/Rsync) on my Linux computer. First, I chose a folder on my Windows computer to share on the network. On my Linux computer, I can now mount that shared folder by adding a configuration into my [fstab](https://en.wikipedia.org/wiki/Fstab) file:

```
//192.168.0.4/share /windows cifs username=share,uid=tenry,gid=tenry,noauto,nofail,exec,dev,suid
```

My Windows computer is on a specific local IP address, let's say `192.168.0.4` for example. On the Windows share settings, I called the shared folder `share`, and I want it to be mounted on my Linux computer at `/windows` in the root.

Now I can easily access the shared Windows files on my Linux computer as if they were actually on my Linux computer.

Unfortunatly, I didn't find a way (yet) to share a whole drive (e.g. `C:` or `D:`) on the network, but maybe it's better to not do so. Instead, I created a new folder `share` where I put nearly everything I create or work with on Windows.

Now, that my Windows share folder is mounted, I can start working with rsync! I created a few shell script that allows me to quickly "push" some files from Linux → Windows or "pull" from Windows → Linux. So, let's say, I have a new project at `/path/to/my/project`, I simply `cd` into that directory on Linux, call my *push* script with no arguments or `.` for the current directory, and everything in the current folder becomes available as a copy on my Windows computer at `share\path\to\my\project`. And when I did some work on my Windows computer, I simply call my *pull* script on Linux.

I might go more into the details of my script in a different articel if you're interested.

## It's still not perfect

If I do something on one computer, the files are not immediately available on the other computer. I push and pull manually all the time, and all the files are just copies.

Also, my script does not delete any files I deleted from one of the systems for security reasons (unless I explicitly tell it to do so) and I'm not sure how good rsync is at detecting renames of files and folders.

What I would like the best is if both computers would actually access the very same storage, without any network bottleneck. But I already see two major issues here:

* Linux working with an ext filesystem and having everything at `/`
* Windows working with an NTFS filesystem and having something at `C:\`, `D:\` etc.

If you have any tips or tricks for me regarding the file management, I'm happy to know about them! I hope this article well help some of you setting up your own multi-computer systems.