I’ve always wondered if I could turn a Chromebook into a full-time development machine, so I recently started tinkering with Crouton to get a Linux CLI running.
Crouton creates a chroot environment and installs a distribution such as Debian or Ubuntu. It even let’s you run a full X server and get a GUI like Xfce — but my initial impression of this was that it’s a little buggy, and personally I don’t really mind the Chrome OS GUI, I just want a Linux shell.
Finally, rather than back up my Chromebook using traditional file syncing methods, I wanted to use configuration management and Git to keep all of my configuration and code copied across multiple machine; this has the advantage that if I accidentally reset my machine (switching Chromebook out of Developer Mode will wipe it), I can quickly bring it back to a good state. Also it allows me to run multiple Chromebooks or Linux VMs (e.g. on my Mac or in the “cloud”), and keep everything relatively consistent.
Step 1: Switch your Chromebook to “Developer Mode”
Full instructions here. I initially found the timing of this tricky, but basically it was two sets of keyboard shortcuts, the second which had to be timed very specifically. “Esc+F3(refresh)+Power” gets you into Recovery Mode, and while the screen was still blank, “Ctrl+D” brings up the Developer Mode screen (it prompts for confirmation before entering developer mode).
Every time the machine boots, you also need to use “Ctrl+D” to continue with Developer Mode (pressing space bar will restore your Chromebook out of Developer).
Note: switching in or out of Developer Mode erases all of your data.
Step 2: Install Ubuntu “Xenial” 16.04 (LTS)
Download the crouton script to your Downloads folder, from the link in the description here: https://github.com/dnschneid/crouton
Then open up a Chrome OS shell using “Ctrl+Alt+T” and typing “shell” then pressing enter.
To run the crouton script and install a Ubuntu Xenial with basic CLI tools:
sudo sh ¬/Downloads/crouton -e -r xenial -t cli-extra
Note that the -e
option will encrypt your chroot. You definitely should do this, and ideally you should store your decryption key off your device and on something like a USB drive — see instructions here.
Specify a username, enter your password twice, and after the install completes, you can access the CLI by entering the Chrome OS shell (if you’re not already there), and typing:
sudo enter-chroot
You’ll be prompted for the password used to encrypt your chroot, and once entered, you should find yourself with a Linux shell.
Step 3: Install SaltStack
SaltStack, otherwise known as Salt, is a configuration management tool like Chef, Puppet and Ansible. It is well known for scaling to manage thousands of machines using its event bus model, however it performs equally as well when run locally on a single machine. This is known as running Salt “masterless”, and there’s a general guide to this here. It’s as easy as changing a few line of the “minion” configuration, writing a few state files, and running the salt-call CLI tool.
First, let’s install a text editor (VIM) and Salt:
sudo apt-get update
sudo apt-get install vim salt-minion
Now, assuming the username you used for step two was “tux”, your home directory will be /home/tux
, so you’ll want to create a new directory to store your salt configuration e.g.mkdir ~/salt
, and update the Salt minion configuration /etc/salt/minion
to use local mode and look for your state files in this directory:
file_client: local
file_roots:
base:
- /home/tux/salt
Now, to demonstrate using salt, we’ll create a main state file and one to define installation of some “dev tools”:
vim ~/salt/top.sls
to edit the main state file — adding this:
base:
'*':
- devtools
and vim ~/salt/devtools.sls
to define some dev tools — with this:
git:
pkg:
- installed
golang:
pkg:
- installed
Now, to actually get Git and Go installed, we need to run the salt states:
sudo salt-call state.apply
You’ll see a bunch of text fly by, ending with a summary which hopefully says Succeeded: 2, and Failed: 0. The most interesting part will be something like this:
----------
ID: golang
Function: pkg.installed
Result: True
Comment: The following packages were installed/updated: golang
Started: 19:28:30.581690
Duration: 7797.161 ms
Changes:
----------
golang:
----------
new:
2:1.6-1ubuntu4
old:
This shows that golang:1.6–1ubuntu4 was installed. Now you’re ready to start developing some Go! Don’t forget to add your Salt configuration to a Git repository and push it somewhere like GitHub or BitBucket — that way if you accidentally wipe your Chromebook by pressing space bar next time you restart it (instead of Ctrl+D to enter Developer Mode), you’ll be able to repeat this process and get things back to a working state.
Next steps for me is to build-out my Salt states to get a nice development environment going, and look into running rkt containers locally (since Docker doesn’t play too well with the Chrome OS kernel, and rkt looks cool).