At the last AberdeenPHP meetup we did a very brief overview of web development on a Chromebook. We probably covered it a bit too briefly, so it seems useful to jot some more in depth notes on the subject.
As a couple of old SSOFB laptops have expired, we were looking for a new web development laptop or two. Laptops are a very personal choice, as users have quite different preferences.
Our requirements were, in rough order of priority...
- Ubuntu or Xubuntu LTS, 16.04 (Xenial Xerus) at the moment.
- 4GB or more of RAM, enough to run VMs and the heavyest web dev toolset.
- 2 or more cores.
- 7 hours or more battery life, for most return train journeys in Scotland.
- 14" screen, preferably full HD.
- Good keyboard.
- Good trackpad.
- Gigabit ethernet.
- Reasonable cost.
The current laptop landscape seems to be quite polarised between higher end Ultrabooks and low end Chrome and Windows machines. We don't use laptops as our main PCs, so an £800, or more, Ultrabook, doesn't seem good value. On the other hand, the low-end machines don't meet enough of our requirements. The closest we could find to a happy medium were the higher end Chromebooks, so we settled on the HP Chromebook G4, which for £300 meets all of the requirements with the exception of it not having an Ethernet port. Other laptops we considered were Dell Latitude 3450, HP 14-ak004na, Lenovo Yoga 500 and Asus C300MA.
The first step, usually, with any new development system, is putting Linux on it. Some systems are sold pre-loaded with Linux now, but not many. A distinct difference with a Chromebook though is that it already come with linux installed, even if this is perhaps not of a very practical flavor. ChromeOS is quite limited, but it does mean all of the system's hardware will be well supported. To get a more fully featured linux on a Chromebook there are two main options, a parallel install using Crouton, or a full direct install. Using Crouton is the most well worn path, so we decided to try this, at least initially. Installing Linux directly on the system means installing new bios, which is technically much more complex, however we may try this if Crouton, in the longer term, feels sub-optimal.
What is Crouton...
That is best explained on the project's homepage. It says "crouton is a set of scripts that bundle up into an easy-to-use, Chromium OS-centric chroot generator". It further explains chroot as "Like virtualisation, chroots provide the guest OS with their own, segregated file system to run in, allowing applications to run in a different binary environment from the host OS. Unlike virtualization, you are not booting a second OS; instead, the guest OS is running using the Chromium OS system. The benefit to this is that there is zero speed penalty since everything is run natively, and you aren't wasting RAM to boot two OSes at the same time. The downside is that you must be running the correct chroot for your hardware, the software must be compatible with Chromium OS's kernel, and machine resources are inextricably tied between the host Chromium OS and the guest OS. What this means is that while the chroot cannot directly access files outside of its view, it can access all of your hardware devices, including the entire contents of memory. A root exploit in your guest OS will essentially have unfettered access to the rest of Chromium OS."
1) Put Chromebook into developer mode. To do this, power off the Chromebook, then switch it on, holding down the Power + Refresh + Esc, read the warnings and then press Ctrl + d.
2) Download Crouton
3) Press Ctrl + Alt + T
4) Install your Crouton OS using...
sudo sh ~/Downloads/crouton -t xfce,xenial
...this may take a wee while, answering prompts as required. We chose Xenial as it is the latest Ububtu LTS version, and it includes PHP7. It was not listed as fully supported version but it works great for us.
5) After it's installed you can start your Crouton guest system using...
...you can cycle between Ubuntu Xenial and ChromeOS by pressing Ctrl + Alt + Shift + Back or Ctrl + Alt + Shift + Forward. Back and Forward keys being the ChromeOS arrow keys above the number one and two keys, rather than the cursor keys.
6) The next step is really just to install your normal packages on Ubuntu Xenial. This is just done as normal with sudo apt-get install etc. We installed lamp-server^, apache2-utils, php-mcrypt, libapache2-mod-auth-mysql, php-mbstring, php7.0-mbstring, php-gettext, php-curl, nodejs, npm, phantonjs, a2enmod, filezilla, phpmyadmin, git, subversion-client, firefox, filezilla and kate.
7) We chose to put the apache root on a micro SD card. This is just a tweak to your apache conf file. Although the HP Chromebook G4 has 32GB of built in storage, we added a 64GB micro SD card. We are putting files in the Download folder, which is shared between both OSes, and the code on the micro SD card, which is mounted in both.
8) We also installed some tools in ChromeOS, these being Chrome extentions, initially Postman and the Caret editor.
At this point, you're away and running with your Chromebook web development system.
After a reboot you'll need to start crouton again. To do this, take the following steps:
1) Open Chrome
2) Hit Control + Alt + T
3) Type "shell"
4) Type "sudo startxfce4"
After a few weeks using this set-up some notes on positives of hardware and software.
- ChromeOS is ok for many quick tasks.
- Code and files were seamlessly accessible via both environments.
- All the hardware just works.
- Battery life is great, at about 9 hours.
- The screen is great, the pixel density of 157.35 PPI makes it really crisp and sharp.
- There is no fan or spinning disk, so the system is totally silent.
- When you're in Linux, doing web development, it feels just the same as a normal linux web development.
- The Caret editor in ChromeOS is fine for many quick fixes and tweaks, when you don't need a full dev environment.
- Build quality is good, the hardware seems well designed an put together.
- The keyboard feels good, positive and clicky enough.
- The trackpad is large and works well.
- Being able to back-up the whole chroot using "sudo edit-chroot -b xenial" works really nicely.
- The ChromeOS developer mode adds maybe 20 or 30 seconds to boot-up, however we rarely rebooted the system, instead just opening and closing the lid to wake and sleep it system.
- There is no backspace key.
- It took a bit of tinkering to get the keyboard mapping in Linux matching the hardware.
- Not having an ethernet port slows down the transfer of large files across the LAN onto the system. We'll probably try a USB3 GigE adapter in the near future.
- Sometimes large revision control checkouts, to the micro SD card, caused filesystem errors. This was perhaps with git checkouts that contained 10,000 small files. It only happens one in twenty times perhaps, and is fixed by a reboot, but it is worth mentioning.
- In ChromeOS it is not so easy to do a mouse right-click, which seems odd, and can be inconvenient. Right click is achieved by holding Ctrl + Alt + Mouse click. In Linux it all works as normal.
- Chromebooks have a large Search button above the left Shift key, which we found to be of no practical use, generally. We occasionally clicked this inadvertently, which in ChromeOS, brings up the Google search dialogue.
- The keyboard has no back-light, which is probably an unfair criticism, as I'm note seen a laptop under £600 that does.
Links and further reading
- The Crouton project - https://github.com/dnschneid/crouton
- Xubuntu LTS, 16.04 (Xenial Xerus) - http://releases.ubuntu.com/16.04/
- A handy how-to on experts exchange - http://www.expertreviews.co.uk/software/operating-systems/1403773/how-to-install-linux-on-a-chromebook-using-crouton
- The HP Chromebook G4 on HP's website - http://www8.hp.com/uk/en/products/laptops/product-detail.html?oid=8326221
- Aberdeen PHP User Group - http://aberdeenphp.co.uk/