DEV Community

Tenry
Tenry

Posted on

How I work with Linux and Windows together

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. 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, 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 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 file:

//192.168.0.4/share /windows cifs username=share,uid=tenry,gid=tenry,noauto,nofail,exec,dev,suid
Enter fullscreen mode Exit fullscreen mode

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.

Discussion (7)

Collapse
chrisgreening profile image
Chris Greening • Edited on

Hey!! Enjoyed reading your article, I’d recommend looking into the Windows Subsystem for Linux; it’s super easy to setup, is officially supported through Windows 10, and it accesses the same file storage as Windows.

It’s basically a Linux terminal running like any other Windows app that behaves pretty much exactly as you would expect a Linux terminal to. For programming it has been a godsend lol

Collapse
rapasoft profile image
Pavol Rajzak

There are problems with it (it is virtualized), like if tou want to run docker inside WSL and access it from Windows host. Also native Linux is much faster than WSL (when it comes to compilation time). But for some simple usecases WSL is excellent choice.

Collapse
mirrorbytes profile image
Bob • Edited on

Solution to that is install Docker on Windows, upgrade to WSL2, and integrate it on Docker's end.

Edit: I'd like to add that upgrading is by distro, as is the integration.

Collapse
tenry profile image
Tenry Author

Hey, thanks for your feedback! I'm actually aware of that subsystem, but I haven't worked much with it yet.

Linux shall stay my primary OS including the GUI, so I won't switch completely over to the subsystem. But maybe the subsystem can help me with the point regarding "one file system for all" 🤔

Collapse
nxml profile image
Arthur Michel

Look at this man, he made a linux host with a kvm windows vm with a second GPU and the same keyboard mouse as you
If you understand french or set subtitles :)
youtube.com/watch?v=9qKf8NEnjB8

Collapse
tenry profile image
Tenry Author

I don't understand French, but KVM Windows VM with a second GPU sounds interesting. I previously tried running Windows in VirtualBox on my single-GPU computer, and it didn't work out well.

One benefit of having two computers: I can attach additional monitors! My Linux computer supports up to 4 displays, and I have Windows running on a 5th monitor :)

Collapse
telmopbmarinho profile image
Telmo P. B. Marinho

Congratulations! It was good to read your article, Tenry.