Stop dual-booting: get the best of both worlds. Windows 10 + Ubuntu.
If you have used both Windows 10 and Ubuntu for at least 2 years, you will agree with me that they are both very good operating systems; the only problem, they are not good at everything. In this write-up, I will show you how you can effectively get the best of both worlds: the top-notch development tools, the flexibility and the minimalism of Ubuntu, and the cutting edge UI and hardware support on Windows 10. But let me first start by highlighting why simply having one of the two is not enough.
The good and the ugly: Windows 10
Since the times of MS-DOS which made Linus Torvalds so unhappy that he resorted to building his own kernel; Linux, Windows has made very significant improvements ranging from increased open-source software support to the introduction of the Windows Subsystem for Linux(WSL). Despite all the strides, one thing still remains constant, it's an ugly platform for software development. Unless you are working with Android Studio or Visual Studio, the support community is very minuscule and getting tools like Docker and Ruby to work can be a nightmare.
The good
When it comes to usability, aesthetics and hardware support, there is no denying: Windows 10 gets the medal. Other notable advantages include:
- WSL - Because Microsoft now listens, it responded to the complaints of developers and tried to make us happy ??, WSL was born. It was a very exciting announcement by Microsoft considering that I personally prefer the windows user experience and its large pool of drivers for hardware support so I tried it. Read more on WSL here and if you want to try it go to this link. In case you do not know what this is, WSL is an attempt by Microsoft to bring the features that developers love about Linux to Windows 10.
- UI/UX - With its support for the trending dark theme, the Windows 10 User Interface (UI) is nothing compared to Gnome or Unity despite their lightweight nature but when it comes to user experience; Windows gets the prize. I know the Linux community will want to grill me for saying this but guys, Windows is a beauty ??.
- Visual Studio - If you are working on anything that requires C#, SQL Server and the .Net framework don't even think of switching to Linux. The support for these tools on Windows is light-years ahead. Starting from the copy and paste options between Excel and the SQL Server to the tightly coupled development tools in Visual Studio: there is just no other option that comes close. However, visual studio is a serious resource hog. You will need SSD storage to appreciate it really.
- Windows 10 Defender - While Windows still remains the number one target for user-centred attacks: Microsoft has decided to beef up its security. Windows Defender is now the kind of security you would hire if you had a pool party for Wrestlers. Defender now gets regular updates and the results are commendable. It is for this reason that I now use it as my primary security solution. Generally, I do not use any third-party tools for media, security and basic tasks on Windows 10 these days; except for chrome of-cause.
The ugly
Windows is not exactly perfect. Here are it's shortcomings:
- WSL - As I mentioned earlier, Windows 10 now has a solution for developers but this solution is very limited. Because of different file permission architectures, it is nearly impossible not to encounter permission issues each time you manipulate your development files. And when it comes to file systems, I can not say no more than this author has. The last issue I would like to mention here is that of slow IO operations. IO operations can be painfully slow in the WSL especially for relatively large files.
- Docker - If you use Docker for your development, Windows 10 quite all right supports it but not as naturally as Ubuntu/Linux does. Docker for Windows 10 still requires a Linux image that runs on either Virtualbox, Vmware or Windows own Hyper-v so unless you opt for Windows containers you will not find development so natural with this. Essentially, you can make Docker work; however, you will need to make a few painful adjustments. For example, you will most likely need to enable remote connections by exposing the daemon on port 2375 which is not recommended as it makes you vulnerable to remote code execution. File sharing between the VM and the host machine is also not smooth. It can be frustratingly slow at times.
- File systems - Unlike Linux, Windows does not support all file systems. By design, Linux has a virtual file system (VFS) which acts as the primary interface to all underlying subsystems so it natively supports all file systems. Read more on the architecture of the Linux file system here. On the other hand, Windows only supports a select few file systems: FAT32, NTFS and exFAT.
- Permissions - Like file systems, the file permissions for Linux and windows are not compatible. While both are able to achieve the same goals, Linux gives you more control and flexibility to your files so choose wisely ??.
- Symbolic links - Think of symbolic links as Windows shortcuts but on Linux. Also called soft links. For a more detailed description see this. Again, like I said, Windows' NTFS is implemented differently from Linux's EXT4. Although Windows now supports its own version of symlinks, they don't really work as required. If you have worked on a Laravel project that required the use of symlinks for linking the storage directory to the public directory, you will agree with me that this doesn't work on Windows 10.
The good and the ugly: Linux
The good
- Memory management - Not before long, Ubuntu only required a minimum of 512MB RAM but due to its rapid growth and the growing need for more features, it has grown but to only about 2GB which is still half the required minimum for Windows. This is largely due to their different kernel architecture styles. While Windows takes the Monolithic Architecture where all the modules are loaded to the Random Access Memory (RAM) at boot time, including the device drivers, Ubuntu takes another approach: the Micro-kernel architecture. With this architecture, only vital modules are loaded at boot time: the Scheduler, Memory and Network Management Systems are loaded while the others are loaded on demand during usage. As a result, you will naturally find Ubuntu to be snappier as compared to its counterpart.
- Package Management - There is no denying that when it comes to package management: Linux ult-rightly gets the Oscar. From it's built-in apt utility to it's well organised open source repositories: all you need is a command. In my second year when I was being introduced to Linux, my lecturer told me, "Once you are comfortable with the Linux terminal, you are like Harvey Specter: You can practically get yourself out of any complex situation through commands." Well, except for sudo rm -rf /.
- Software Development tools Ubuntu comes pre-configured with most of the essential software development tools: Java, C and its compiler GCC, Python, Ruby as well as vim; a rich customisable text editor. Ubuntu's terminal is one other built-in tool that is very versatile, handy and Unix-compliant.
- Software Center - Ubuntu comes with a rich software centre by defualt where all apps and tools can be downloaded. Think of the software centre as the apple or play store for ubuntu. Very handy! Ubuntu had this way before it was introduced in Windows 10.
The bad
- Hardware and Driver Support - Until I purchased my first ultrabook, I was a staunch Linux pioneer so I immediately switched from the default Windows 10 pro to Ubuntu 18.04 as my daily driver. Firstly, the process of switching itself is not straight forward. I had a couple of challenges but luckily, I wasn't the first. Linux enthusiasts enjoy a large supportive community so I managed to get through; however, I had to sacrifice a few hardware features because there was no proper driver support. My fingerprint reader, sim card and hibernation were not working. While hibernation wasn't completely failing, it just wouldn't work at times. I would put my machine to sleep but only to find it's awake, active and hot as a gold mine. At times, it just refused to awaken from its deep sleep until I do a force shutdown then restart. Not pretty for a new machine.
- Refer to 1
- Refer to 2
In all honesty, it's hard: literally hard to find a lot of bad things about Ubuntu. Maybe I should just sacrifice a few hardware features on my ultrabook and stick with Ubuntu?????♂?? But then, what am I paying the premium price for? Everything should work, right? That is why I found my own solution. Read on.
My solution
Enough with the discussions. We have talked about the ins and outs of choosing one platform over the other. It's about time that we now discuss my favorite solution. It has worked for me for the past 3 years and each time I switch machines, I do not have to spend a week or 2 preparing my development environment. All I do is export my environment to an external media storage, wait for a couple of minutes on some coffee and I am ready to go. Like a boss??
Vagrant + Homestead
Since Windows 10 has better hardware support and requires more resources to run smoothly, I made it my host OS. So you will have to make Windows 10 your host OS to make the most out of this. Using:
- Vagrant, a tool for building and managing virtual machine environments in a single workflow with a focus on automation. Read more on this link and download it from here.
- Homestead, a vagrant box built for Laravel development. Think of homestead as an ubuntu environment preconfigured for your PHP development. Read more here and download from here.
You will most likely have difficulties downloading homestead on most ISP's so here is a trick. Run the command: vagrant box add laravel/homestead once the download begins, copy the download URL with has the suffix "virtualbox.box" form your terminal and download the box using IDM or your preferred download manager. When the download is complete, navigate to the download location and ensure that the file extension is ".box" if not, change it so that it has this extension. Now run the command: vagrant box add laravel/homestead file:///c:/Users/username/location_of_your_download/virtualbox.box This may take some time.
Now, navigate to your vagrant homestead box directory. On Windows 10 go to: C:\Users\username\.vagrant.d\boxes\laravel-VAGRANTSLASH-homestead then create a new file and name it: metadata_url. Using your favourite text editor. VS code most likely??, add the URL: https://atlas.hashicorp.com/laravel/homestead with no newline. Save it and close the editor. Now, in the same directory, rename the directory named 0 to 8.0.1 or whatever the version of the homestead box you have downloaded is. You are now ready to spin it up with vagrant up.
A handy tweak
One handy tricky I never forget to configure whenever I switch machines is the ability to spin up my dev environment from any location on my pc. Here is how to do it. On the homestead setup page here to the section Daily Usage>Accessing Homestead Globally>Windows follow the steps there and you should be able to just open up your terminal and run: homestead up; homestead ssh; and you are straight logged in to your dev env at any time.
Conclusion
The beauty about this setup is that you can edit your code with a modern text editor like VS Code. It's more like accessing your code on an Ubuntu server with the ability to run VS Code while using the least amount of resources on your host machine. There you go. You now have the best of both worlds. Happy coding...??