Sunday, June 23, 2013

A funny case of using the PC

Nowadays I boot into my Windows 7, check my mail and browse some web; then I click on VirtualBox and start Lubuntu to code web application (Python, Flask, Brunch, etc.), where I spent most of the time on. It's funny I spend most of my time in a VM.

Why I am using Windows for the past 10 years

10 years ago I was a desktop developer using VB6, Microsoft C++, and eventually .NET, so Windows is the obvious choice with more than 90% market share.

The the programming work started to shift to web through ASP, ASP.NET, Java and PHP. Though I am using Eclipse to code Java and PHP (Zend Studio), it never cross my mind to shift to Linux as I see no value added benefits.

There are a bunch of Windows only apps which I cannot live without, such as Microsoft Office, Visio, Photoshop, Visual Studio, etc.

Besides, Windows 7 is pretty fast and stable, and the BSOD is pretty much dead.

Why did I start using Linux

I did install a few Linux distros in the past 10 years, but I just couldn't find a compelling reason to use it on a daily basis.

I guess Python, Brunch and Node-related stuff trigger the reason to move to Linux. I started with Python and Brunch on Windows using Eclipse, though it work pretty well. These tools involve a lot of command line at times, and Windows command prompt does look and feel terrible (cygwin doesn't work really well with Python). There are some dependencies for certain libraries or tools (I forgotten which one) which could not be installed on Windows properly (or too messy), most tutorials are on Ubuntu environment, some tools ported late or second-class citizen on Windows (livereload, yeoman, pip, etc.), lack of convenience of apt-get to install various tools and libraries, etc. I guess a combination of these reasons encourage me to move to Linux, and I am actually glad it happened.

Some benefits of Linux includes similar environment as my production environment (less deployment issue), powerful command line means plenty of stuff could be automated through cron and shell, plenty of tutorials to setup various tools and services on Linux (espcially Lubuntu), apt-get and pip (and virtualenvs) allow easy update of various tools and environment.

Lubuntu consume very little resources (could run on 512MB RAM, but more practical with 2G RAM if used as Coding environment), have decent desktop applications for Development (Chrome, Eclipse, Sublime Text), stable and speedy. Though the File Explorer on Lubuntu is a bit sucky.

How did I end up in VirtualBox Linux

At first I was still skeptical about Linux, so I take the safest route of installing one in VirtualBox. I choose the least resource intensive Ubuntu flavor (Lubuntu), assigning it half of the memory (2G out of 4G) and half the processor (i5), and it run decently on most cases. I can't take away more memory from Windows as it would crawl the moment I try to open up some apps on it.

Why not Dual Boot?

I gave this option some thought, and found it too troublesome (and time consuming) to switch between OSes.

Besides, there are some surprising benefits of running a VM:
  • A share folder could be easily created to share files between Host (Windows 7) and Guest (Lubuntu); somehow drag and drop doesn't work on my setup for file transfer.
  • Host and Guest could share the same application/services, e.g. MySql still resides on Windows 7 where Lubuntu can easily connect to it, and I could easily test IE compatibility by connect to Lubuntu test server from my Windows 7
  • Whenever there is a need to run IE or use Microsoft Office, switching back to host (and vice versa) just take a second or two.
  • Easy Backup and Transfer: My Lubuntu VM is about 20G, where I could easily backup the entire environment into an external drive/cloud, or setup my coding environment on another notebook within minutes. Keep the VM small by storing large but non-essential files on the shared drive on the Host, and I put all my essential files (e.g. Code) on a separate virtual disk (the benefit is that I could start another VM if necessary and mount my "Code" virtual disk).
  • Snapshots

Why didn't I ditch Windows totally?

Though I would like to, but I can't at this stage due to a few reasons:

  • Legacy Development Support: I still need to support some application written in VB6 and .NET; sometimes, there is still a need to develop some Windows-based application.
  • Internet Explorer: In Malaysia (my country), IE is the only choice if I need to perform Online Stock Trading (every brokerage use the same ActiveX app developed by the same company), and the same goes with some Online Banking. Besides, I still need IE to testing purpose.
  • Microsoft Office: Though I use Google Apps most of the time, there are just some 100-pages existing documents which I need to edit, where even app like Libre Office would screw up the formatting badly.

Why not put Linux as the Host (and run Windows in VM)?

This sounds like a good idea, as most of the time I am using Linux and occasionally run Windows for special purpose. The downside of the VM is I only get half the memory and CPU most of the time. The downside of not running as VM is I loose the ease of backup the entire VM image and quick portability to another PC.

I don't feel like rocking the boat now on my old notebook (almost 3 years old), but I am constantly on a lookout for a decent notebook which support Linux. Somehow the feeling is Linux notebooks are quite limited in options, but will try to get one.

4G RAM seems a bit "uncomfortable" when running VM, so 8G RAM is quite essential; and SSD is preferred for faster disk IO. 

The Future of VM OS

I wonder about the future where the main OS of a notebook/PC is a VM OS (something like Xen), where we could choose to boot up multiple OSes and communication/sharing between these OS are still possible, and the VM OS doesn't consume too much memory and CPU.

22 comments:

Anonymous said...

I've been working that way for more than five years. I have a different VM for each project, keeps the config simple and the backup is the win. If the hardware goes down, just transfer to new hardware and carry on

Andy Hamilton said...

>A share folder could be easily created to share files between Host (Windows 7) and Guest (Lubuntu); somehow drag and drop doesn't work on my setup for file transfer.

That can be done via dual boot too! I have /host mapped to my windows 7 file system.

Jason Asselin said...

I am kind of sharing the same situation you do. I might give this a try!

Hans Lemuet said...

Same setup here, because I need to use Photoshop to open PSD when I do front-end dev.

valbaca said...

This is a very standard setup, especially in the business world.
One main difference is that most setup have the "workspace" VM (in your case Lubuntu) is usually hosted on a desktop, on a server, or even in the cloud. The "bare-metal" OS is usually a rock-solid linux distro like Debian, RedHat (or CentOS).

In the future I highly recommend upgrading to this kind of setup. You can build a very cheap and powerful headless desktop. Upgrading this desktop (throwing in a new HD or more RAM or even upgrading the motherboard and CPU) is cheap and can be done almost without limits (unlike laptops which hit some RAM limit).

Another advantage of the desktop & laptop setup is a removal of the dreaded "single point of failure." Using an SSD does practically remove your chance of hard drive failure, you're still running Windows and viruses are still around.

No matter what setup you use (and the one you are using is great btw!) BACKUP! BACKUP! BACKUP! (Don't use VirtualBox snapshots, they are NOT backups). You're absolutely right that it's great your workspace VM is only 20GB.

Anonymous said...

I'm using Mac as the host and for day-to-day comfort.

I use a variety of guest machines for a variety of jobs. Sometimes I work with Linux in a VM, but I'm finding it's a lot nicer to have a powerful Linux server under the desk and connect to it using SSH, and SSH over X for the GUI tools. The advantage with this is that I can blend tools and get the best out of both machines.

The biggest problem I find with a Windows as a host is that the licensing makes it hard to switch Windows Virtual Disks from one host to another. That's a huge problem that you just don't get with GNU/Linux.

Also, how do you live with the Windows command prompt? It doesn't do anything.....

Anonymous said...

I've been considering a similar setup for coding and separate configs, and also to have a separate VM which is only ever used for online banking (probably the host, that way key loggers can't capture anything). But my main reason for posting is to tell you about console2 (search on sourceforge) it makes the command line on windows usable :)

Pablo Veliz B. said...

Same here, use W7 in my laptop due to compatibility issues with linux distros :(.
One advice.. use portable apps on win, so the backup could be easy too (ie: http://portableapps.com)
I also use TrueCrypt disks of 4Gb for data and code, which allows me fast backup, since is only one big file that fits on a DVD, of course, I use various TC disks.
Until I can get a good latop which can be handled by linux without hassle, my life goes by Windows as Host, Linux as Guest

Unknown said...

@Anonymous said:

"Also, how do you live with the Windows command prompt? It doesn't do anything....."

PowerShell. Makes BASH look primitive.

Anonymous said...

"Also, how do you live with the Windows command prompt? It doesn't do anything....."

Showing my age here, but I started with CP/M, and still use command prompt for more than 50% of my daily routines, switching to GUI/mouse only when needed.

There are some things that can only be done in GUI, or done better, but many things that everyone does via point & click can be done better, faster, and with more control fomr the prompt.

David Lojudice Sobrinho said...

doing the same, but switched from a full Vbox VM to a light/headless vagrant VM. You can use your IDE in windows, which in my case is Sublime and cygwin.

Brien Malone said...

Thanks for this tip. I don't get the "windows command prompt doesn't do anything" comments. I've used DOS since 2.11 was new and can make it do backflips. Still, I'm always on the lookout for enhanced functionality.

Ed Korsberg said...

I completely agree with everything you said since this is exactly how I work too. I typically have about 4 VM images active, each with a different purpose and each with the minimal set of data/applications for the task at hand.

Anonymous said...

I have been using virtual machines for development since 2003, when doing server controls development. An IT manager wouldn't let us install server OS on a workstation because policy required all "Servers" to be behind locked doors. I put it on a virtual machine with a virtual domain controller, and had to prove to Infosec that it would not connect to the production domain. A major waste of time, but liked the result.

Desmond Lua said...

Thanks for the feedback, and I guess a lot of us are on the same boat. I was hoping to get some idea on how to make this setup better.

Quite a few mentioned Vagrant, but I guess it's not really useful for me at the moment unless I plan to setup multiple VMs with same environment.

Some mentioned headless VM, where there isn't much benefit for my scenario where I actually want to code within the Linux environment (Guest), not just for production. I assume it's pointless to setup a headless VM and RDP in on the same machine vs loading a full VM, correct me if I am wrong.

A headless VM on another machine under the desk isn't feasible for me as I move around a lot.

I am wondering which OS is a better host, hopefully consume less CPU and Memory. Linux driver might be a problem for most notebook though.

About Windows command prompt, the font, copy-paste just felt "awkward", and lack of common Linux command. I try the Console, Git bash and Cygwin, each has its drawbacks under certain scenarios (can't recall what are the limitation).

Anonymous said...

I've been doing this for a while myself. Running Ubuntu, Mac, and Windows Server all in VMs on my Windows 8 host. I'll create a master template for each OS, complete with all my dev tools and other essential apps, then when I need to start a new project I just make a copy of the master and presto, instant dev environment!

Anonymous said...
This comment has been removed by a blog administrator.
DakoChan said...

Similar with you, I also use VM in office and home. But, mostly I use VMWare instead of VirtualBox. I feel VMWare is more stable than VirtualBox.

In office I use Windows 7 as my host, and using Windows XP as the guest. At home I use Ubuntu as the host. Both my notebook in office and at home have similar specifications. Both were using i5 processor and 4 GB memory.

A few months ago I have annoyed with my notebook in office, because the vm was very slow and sometimes it wasn't responding well, even though I only ran one vm with 1 GB allocated memory. I tested to run the same vm on my linux machine. I could run 2 VMs at once! (The third vm was crashed). Pretty impressive. I almost install Ubuntu OS on my notebook in office. Luckily my IT increased my memory to 8 GB. Now I can run 3 VMs at once.

In short I think memory usage in Linux is more decent.

Anonymous said...

I use virtualized environments daily. I had an old PowerEdge server lying around, with a 2-cores 2-threads Xeon with huge cache, 16GB of RAM and some old SAS 40GB drives. I replaced the drives with 120GB SSD's, installed VMWare ESXi (which is a free virtualization OS with all the trimmings, highly recommended as host for headless), and loaded some VMs on those, each with RDP/xrdp installed. I can run 6 VMs concurrently on this and it never even shudders. Install your favorite daily OS on the laptop, and just RDP into Solaris, Linux, Windows, drag and drop files in between any of them. It is so efficient because in fact most of the time I am only working on one or two VMs at a time, and because of the awesome VMWare processor scheduling and memory overcommit, only two VMs have to share the totality of the server's resources. As noted you also get super easy replication to anywhere, snapshots, shared swap space, and scalpel-precise control over the resources of each VM.

ol said...

Anonymous said...
I've been doing this for a while myself. Running Ubuntu, Mac, and Windows Server all in VMs on my Windows 8 host

What kind of MAC OS are you running onVM ?

Anonymous said...

Same situation here, though I like open nature of Linux can't shift completely to it still Windows is my OS of choice.

Anonymous said...

Doing this on OSX Mountain Lion is really really awesome. If you have a magic trackpad you can 3-finger swipe back and forth between all the full screen virtual machines as well as RDP and VNC sessions. Because windows and linux do not understand 3-finger swipe gestures it always works. No strange mapping key issues.