Linux on a Macbook Air

What do you do with an old late-2010 Core2Duo 1.8GHz Macbook with 2GB RAM, that is no longer able to run the current Mac OS quickly enough? Apple’s recommendation would be to throw it away and buy a new one because it’s about time after 6 years and the hardware probably wore out significantly by now. The second part of the recommendation I have no problem with – since the machine is indeed too slow for running a modern OS with all the applications that I need, I bought a 15” retinabook as a replacement. However, the part where I just throw the old machine away, although all the hardware still functions, it has a very good keyboard, monitor and a touchpad, the battery is above 80% – I don’t think so. So, I tried several things, just to see what can be done.

The first thing I did was boot it from a USB drive containing Ubuntu Trusty Mate LTS 64-bit, to see if it’s actually possible and if all the hardware is correctly recognized. To my surprise, it all worked, completely out-of-the-box and without any sort of additional tweaking, except for one very specific thing, which is the Croatian keyboard layout on a Mac, which is different from the standard Croatian Latin II layout used by Windows and Linux. I tried selecting a combination of a Mac keyboard and Croatian layout in the OS, but it didn’t work. I ended up editing the /usr/share/X11/xkb/symbols/hr file to modify the basic layout:

xkb_symbols "basic" {

    name[Group1]="Croatian";

    include "rs(latin)"

    // Redefine these keys to match XFree86 Croatian layout
    key <AE01> { [         1,     exclam,   asciitilde,   dead_tilde ] };
    key <AE02> { [         2,   quotedbl,           at] };
    key <AE03> { [         3, numbersign,  asciicircum, dead_circumflex ] };
    key <AE05> { [         5,    percent,       degree, dead_abovering ] };
    key <AE07> { [         7,      apostrophe,        grave,   dead_grave ] };
    key <AE11> { [         slash,    question       ]       };
    key <AB10> { [     minus, underscore, dead_belowdot, dead_abovedot ] };
    key <AD06>  { [         y,          Y,    leftarrow,          yen ] };
    key <AB01>  { [         z,          Z, guillemotleft,        less ] };
    key <AD01>  { [         q,          Q,    backslash,  Greek_OMEGA ] };
    key <AD02>  { [         w,          W,          bar,      Lstroke ] };

}; 

Essentially, what I did was reposition z and y, put apostrophe above 7, and question mark/slash to the right of 0. However, the extended right-alt functionality now works as if on a Windows keyboard, so it’s slightly confusing to have the layouts mixed. (ps.: I had to repost the code because WordPress was acting smart and modified the “tags” so I converted it into html entities).

Other than having to tweak the keyboard layout, I had to use the Nouveau driver for the Nvidia GPU, because any kind of proprietary Nvidia driver, either new or legacy, freezes the screen during boot, when xorg initializes. That’s a bummer because the proprietary driver is much faster, but since the only thing I’m about to use the GPU for is playing YouTube videos on full screen, and that works fine, I’m not worried much. Everything else seems to work fine – the wireless network, the touchpad, the sound, regulating screen brightness and sound volume with the standard Mac keys, everything.

Having ascertained that Linux works, I formatted the SSD from gparted, installed Linux, tested if everything boots properly, and copied my edit of the keyboard layout to the cloud for further use. Then, I decided to test other things, wiped the SSD again, and tried to run the Apple online recovery, which supposedly installs OS X Lion over the Internet. Now that was a disaster – the service appears to work, but after you really start doing it, the Apple server reports that the service isn’t “currently” available. After checking online for other users’ experiences, it turned out that it’s “currently” unavailable since early 2015 if not longer, so basically their service is fubared due to zero fucks given to maintenance of older systems.

OK, I found the USB drive containing the OS X Snow Leopard that I got with the laptop, and, surprisingly, it worked great – I installed the Snow Leopard on the laptop but I couldn’t do anything with it because most modern software refuses to install on a version that old, Apple’s own services such as the iCloud and the Apple Store don’t support it, so I just used it to test a few things and I found out that it’s as fast as I remember it when I just bought the laptop – there’s no lag or delays introduced by the newer versions, everything works great, except that the current Linux is a much more secure and up-to-date system than Snow Leopard, so I did the next experiment; I took the Time Machine drive with the current backup of the 15” retinabook running Sierra, and booted from that. It gave me two options – install clean Sierra, or do a full system recovery from the backup. I did the clean install first, and it surprised me how fast the machine was, much faster than my slow El Capitan installation that I was running before finally giving up on the machine, because I had no time for this shit. Then I decided to take a look at what the full recovery would look like. It worked, but it was as slow or slower than the full installation on El Capitan. I tried playing with it but gave up quickly – after getting used to my new machines, it’s like watching paint dry.

I decided to try Linux again, but with a slight modification – instead of running the perfectly reliable and capable, but visually slightly older-looking Mate (which is basically a green-themed fork of Gnome 2), I decided to try the Ubuntu Trusty Gnome LTS 64-bit version, which runs the more modern and sleek-looking, but potentially more buggy and sometimes less functional Gnome 3. Why did I do that, well, because the search function in Gnome 3 is great, and resembles both Spotlight and Windows 10 search function that I got used to in the modern systems, and visually the Adwaita theme looks very sleek and modern on a Macbook, very much in tune with its minimalist design. So, I loaded it up, copied back my modifications of the keyboard layout (which are actually more difficult to activate here than in Gnome 2, requiring some dpkg-reconfiguring from shell). I made a mistake trying to test if the Nvidia drivers work here – they don’t, and I had to fix things the hard way, by booting into root shell with networking (not so much for the networking, but because in the normal root shell mode the drive is mounted in the read-only mode), did apt-get remove nvidia*, rebooted and it worked. Then I installed the most recent kernel version, just to test that, and yes, the 4.2.0-42-generic kernel works just fine. The rest of the installation was just standard stuff, loading up my standard tools, PGP key and the RSA certificates, chat clients and Dropbox, so that I can sync my keepass2 database containing all my account passwords in encrypted form, as well as the articles for the blog.

So, what did I gain, and what did I lose? I lost the ability to run Lightroom, but this machine is too weak for that, and I removed it from the position of a photo editing laptop in any case. The second thing that doesn’t work is msecure, where I have all my current passwords stored in the original form; the keepass file is a secondary copy, so that’s not great. However, Thunderbird mail works, Skype works, Rocketchat works, Web works and LibreOffice works. The ssh/rsync connection to my servers works, all the secure stuff works, UNIX shell functionality works. Essentially, I can use it for writing, for answering mail, for chat, web and doing stuff on my server via ssh. The battery life seems to be diminished from what I would expect, but it’s actually better than it was on El Capitan and Sierra, which seemed to constantly run some CPU-demanding processes in the background, such as RAM compression, which of course drained the battery very quickly and made the machine emulate a female porn star, being very hot and making loud noises. 🙂

I gained speed. It’s as fast as it was running Snow Leopard when I initially bought it, which is great. Also, I have the ability to run all the current Linux software, and I don’t have to maintain the slow macports source-compiling layer in order to have all the Linux tools available on a Mac. I do realize, however, that I’m approaching this from a somewhat uncommon perspective of someone who uses a Mac as a Linux machine that just happens to run Adobe Lightroom and other commercial software; I never did get a Mac to get the “simple” experience that most users crave. To me, if a machine can’t rsync backups from my server, and if I can’t go into shell and write a 10-line script that will chew out some data, it’s not fit for serious use. I run a Linux virtual machine on my Windows desktop where I actually do all the programming and server maintenance, so having Linux on a laptop that’s supposed to be all about “simplicity of use” is not contradictory in any way – to me, simplicity of use is the ability to mount my server’s directories from Nautilus via ssh, and do a simple copy and paste of files. This works better on Linux than anywhere else. Also, the Geeqie image viewer on Linux is so much better than anything on a Mac, it’s not even funny. These tools can actually make you very productive, if you know how to use them, so for some things I do, Linux is actually an upgrade. However, I can’t run some very important commercial software that I use, so I can’t use Linux on my primary setup. That’s just unfortunate, but it is what it is. Linux is primarily used by people who want free stuff, and are unwilling to pay for software, so nobody serious bothers to write commercial software for it. Yeah, theoretically it’s supposed to be free as freedom, not free as free beer, but in reality, Linux is designed by communists who have serious problems with the concept of money, either because they don’t understand it, because they reject it for ideological reasons, or both. In some cases, however, Linux is an excellent way to save still functional machines from the planned obsolescence death they were sentenced to by the manufacturers. Also, it’s an excellent way of being sure that you don’t have all kinds of nefarious spyware installed by the OS manufacturer, if that’s what you care about; however, since I guess that most of the worst kinds of government spying is done by exploits in the basic SSL routines and certificate authorities, that might not help much.

Also, the thing about Linux is that it tries to write drivers for the generic components used in the hardware, instead for the actual hardware implementation. This means you get a driver for the Broadcom network chip, instead for the, I don’t know, D-Link network card. The great aspect of this is that it cuts through lots of bullshit and gets straight to the point, reducing the number of hardware drivers significantly, and increasing the probability that what you have will just work. The problem is, there isn’t much done to assure that every single implementation of the generic components will actually work, and work optimally. In reality, what this means is that if your hardware happens to be close to the generic implementation, it will just work, as it happened to just work on my late-2010 Macbook Air, for the most part. However, if something isn’t really made to generic spec, as it happens to be the case with my discrete graphics, trying to use the generic drivers will plunge you headfirst from the tall cliff of optimism into the cold sea of fail.

So, do I recommend this? Well, if you’re a hacker and you know what you’re getting yourself into, hell yeah. I did it for shits and giggles, just to see if it can be done. Would I do it on a “productivity” machine, basically my main laptop/desktop that I have to depend on to do real work reliably and produce instant results when I need something? That’s more tricky, and it depends on what you do. I used to have Linux on both my desktop and laptop for about 5 years, from Ubuntu Gutsy to Ubuntu Lucid. Obviously, I managed to get things done, and sometimes I was more productive than on anything else. At other times, I did nothing but fix shit that broke when I updated something. If anything, Linux forces you to keep your skills sharp, by occasionally waking you from sleep with surprise butt sex. On other occasions, you get to laugh watching Windows and Mac users struggle with something that you do with trivial ease. At one point I got tired of the constant whiplash experience from alternating between Dr. Jekyll and Mr. Hyde and quarantined Linux into its safe virtualized sandbox where it does what it’s good at, without trying to run my hardware with generic open source drivers, or forcing me to find free shitty substitutes for paying $200 for some professionally made piece of software that I need. Essentially, running Linux is like owning a BMW or an Alpha Romeo – it runs great when it runs, but for the most part it’s not great as a daily driver, and it’s fun if you’re a mechanic who enjoys fixing shit on your car to keep your skills sharp. I actually find it quite useful, since I maintain my Linux servers myself and this forces me to stay in touch with the Linux skill-set. It’s not just an exercise in pointless masochism. 🙂