2017-09-12T18:24:44Z

Using a Chromebook for Web Development

Google Chromebook

Have you seen anybody using a Chromebook yet? These are slim, lightweight laptops that run ChromeOS, an operating system made by Google that is designed around the Chrome web browser. If you want a laptop that you can use for doing your email, watching Netflix and other tasks you can easily do in a web browser, then a Chromebook is a very good choice, and also cheap, since most models are in the $150-$300 price range.

They also make great travel laptops if you are going on vacation or to a conference. The problem for me is that when I travel, I spend a fair amount of time coding (this is an addiction I do not want to get rid of!). So I decided to buy one and try to configure it in a way that is suitable for web development on the move. In this article I'm going to go over three different approaches to do that.

Chromebook Specs

Chromebooks are fairly underpowered devices. There are low-end models with ARM CPUs, and mid and high-end models with Intel or Intel-compatible CPUs. If you plan on doing coding, I would recommend you only look at the Intel based ones.

In terms of RAM, most models come with either 2GB or 4GB. I think 4GB is an absolute minimum for doing any kind of development work, so when I did my research I have ignored any models with less than 4GB of RAM. There are high-end Chromebooks with 8GB and 16GB RAM, but these are all priced above $500, so in that price range you might as well get a Windows or Linux laptop.

The low and mid-level Chromebooks offer 8GB, 16GB or 32GB SSD storage, and usually have a micro-SD slot so that you can add more. Given that you always have the option to add more storage, the amount of internal storage was not a huge concern for me.

Samsung Chromebook 3

The model that I ended up choosing is the Samsung Chromebook 3. There are several variants all with this name, which makes picking the right model tricky. I chose one that comes with a dual-core Intel Celeron CPU and 4GB of RAM, because in this price range that is the best you can get these days. In case you are curious, I paid $179 USD for mine.

Chromebooks as Cloud-Based Laptops

Right from the start you notice that Chromebooks are nothing like regular laptops. The very first thing you have to do is enter your Wi-Fi connection details, and once you do that you get a login prompt and the machine is ready for you. No need to go through long set ups where you have to answer a lot of questions, set up a user account, etc. All you need to use a Chromebook is a Google account.

Once you log in, a Chrome browser opens and that is it, you can start browsing the web. If you want to check your email, you use Gmail. Write a report or spreadsheet? Google Docs. Presentation? Google Slides. Other types of files? Google Drive. You can certainly work while you are offline and use the local storage, but in general you have to be comfortable using cloud storage, because the Chromebook is designed under the premise that you will sync everything to the cloud.

The operating system that powers the Chromebook, ChromeOS, was built as a very secure platform that is more in line with "app store" concept, in which applications can only be obtained from an approved source, in this case the Chrome App Store, and for some models that support Android apps, also the Android Play Store.

As I'm sure you can guess by now, this isn't a platform that is friendly to coding. It feels more like having a tablet with a keyboard than a machine you can develop on. If you want to install the kind of software that we developers use, like for example, vim, a Python interpreter, etc., you have to resort to tricks. There are actually three different approaches that give you access to a Linux environment in which you can write code, all with pros and cons.

The Safe Approach: Termux

This approach is fairly benign, but is limited to Chromebook models that have support for running Android apps, which are those in this list. Some models support Android apps directly, while others need to be switched to the "beta channel", which installs a newer version of ChromeOS with additional features. The Samsung Chromebook that I'm using needs to be put on the beta channel to support Android apps.

The solution is based on installing a very cool Android app called Termux. Termux implements a user-mode Linux environment that can run on any Android device. The environment runs in a sandbox and does not require a rooted device, so the system security is not compromised in any way. Termux runs in its own window, and you can still use the Chrome browser or any other apps you have installed, so the integration is really good.

Termux has a few shell options such as bash and zsh, and comes with its own package manager based on Ubuntu's apt, which you can use to install your typical applications, including ssh, git, vim, Python, Node.js, nginx, etc. The list of packages that are supported is fairly extensive, you'll probably find that all the tools that you use have already been ported.

Termux

This seems like a perfect solution, right? Well, I have tried this approach and unfortunately it sounds better on paper than in reality. Because you are in a heavily guarded sandbox, the sharing between the Linux environment and the rest of the system is very limited, and this gets in the way. Examples:

  • The files that you write inside the Linux file system are not visible from the outside. The only exceptions are a few system directories that Termux exposes to the Linux environment as mounts. For example, the Chromebook's Downloads directory is accessible from inside the sandbox, so it is an ideal place to store your projects, since that makes them visible from the outside and opens the door to using a Chrome based text editor or IDE. This mostly works, but because the device is not rooted, symlinks are not allowed on any of these system mounts. Since Python virtual environments create symlinks, you are forced to create your projects in the shared folders and your virtualenvs in internal folders, which is not how I'm used to organize my projects.
  • Only command-line apps are supported, no GUI apps.
  • No access to the Chromebook's hardware, such as the camera or the microphone.
  • This is more an annoyance than anything else, but if you start a web server listening on localhost, the Chrome web browser will not be able to connect to it, because the Linux environment runs on a separate network so its localhost is not the same as the Chromebook's. The only way to access a web server from outside the sandbox is by having the server listen on the public network interface (i.e. 0.0.0.0) and then use the IP address Termux assigned to the Linux environment in the Chrome address bar, which you can obtain by running the ip addr list command.

After I tried this approach and found no comfortable way to set things up, I looked at how other people implemented a solution based on Termux, and all have weird ways in which they attempt to bypass the strict security measures of the host operating system. Now don't get me wrong, I think you can create a decent environment, but it is not going to be a "familiar" environment, you will have to carefully design your workflow so that it does not collide with the restrictions imposed by ChromeOS.

But as a big plus for this approach, this is the only option that I know that can be implemented without root access, which is amazing considering how much you can get done while keeping the system secured.

Developer Mode

If you are willing to sacrifice some of the tight security measures that ChromeOS implements, then you have more (and in my opinion better) options. If you are concerned about making your system less secure, consider that we are talking about making your system's security be on par with a regular laptop. If you bought a Chromebook because of its highly regarded security aspects though, I would recommend that you stick to the Termux solution I described in the previous section.

Chromebooks have a developer mode, intended for ChromeOS developers to have more freedom to access the system, obviously at the cost of reduced security. Developer mode disables internal verifications to detect infiltrated code every time the system boots. It also gives you shell access to the chronos user, which is the default user in the system, a user that is configured with password-less sudo access by default.

Not checking the OS for infiltrated code is something I can live with. A system with password-less sudo I cannot. Let's first see how to switch the Chromebook into developer mode, then we'll address the sudo problem. Note that switching to developer mode requires a full reset of your system, so any files you have in local storage will be lost.

  • Turn the Chromebook on while holding the Esc and Refresh keys down.
  • A screen that reads "Chrome OS is missing or damaged" will appear. It looks scary, but it is expected. Press Ctrl-D to continue with the process.
  • The next screen will say "To turn verification off, press Enter". When you press Enter, the system will do a full reset. This will take about 15-20 minutes.
  • After the system resets, you will see a "System verification is OFF, press Space to re-enable". DO NOT press space! Press Ctrl-D to continue with the boot process.

Google Chromebook

After the above steps, ChromeOS will run as usual, but developer mode will be activated. Note that each time you boot, you will see the "System verification is OFF" screen, and you will have to accept it by pressing Ctrl-D. If you press Space by accident, developer mode will be deactivated and the system restored to factory settings. Anything in local storage will disappear.

You will not notice any difference in how ChromeOS operates in development mode. The hidden power is in the shell access, which is available by pressing Ctrl-Alt-T to open a crosh tab (Chrome Shell), and then typing shell at the crosh command prompt.

Google Chromebook

As I mentioned earlier, this gives you full sudo access without password. The very first thing you need to do is recover some of the lost security by setting a password:

$ sudo chromeos-setdevpasswd
Password: <type-your-password>
Verifying - Password: <type-password-again>

At this point you have a system that is about as secure as a laptop or desktop computer, so we can stop worrying about security and see what cool things this developer shell can do. The next sections describe two different approaches to get a real Linux distribution installed on your Chromebook.

Dual-boot a Linux distribution

With the help of the chrx project, you can dual-boot your Chromebook between ChromeOS and a Linux distribution. This option leaves you with a full Linux installation that is running on a x86-64 CPU, so you can think of it as being equal to running Linux on a low-end laptop.

The installation process is pretty much automated. You need to open the developer shell as indicated above, and then download and run the chrx installer script:

$ curl -Os https://chrx.org/go && sh go

The script will ask you a few questions and then run for a while. When running without arguments as above, chrx will install GalliumOS, a small and beautiful Linux distribution based on Xubuntu, specially optimized to run on Chromebooks. If you prefer a different distribution, add -d DISTRIBUTION to the go command. Valid options are galliumos, ubuntu, lubuntu, xubuntu, kubuntu, edubuntu and fedora,

There isn't really much to say about this option, as anything that runs on a regular Linux machine will likely run in the Chromebook as well, including GUI applications, containers, virtualization, access to camera and microphone, and anything else you can think of.

Google Chromebook

Run Linux inside ChromeOS

The only reason you may not want to go with the solution presented in the previous section is that you have to choose wether you want to boot ChromeOS or Linux, you cannot have both at the same time. And if you like the sleekness and simplicity of ChromeOS, it may be tough to get used to a less polished and harder to use Linux desktop.

If that is your situation, you may like the Termux solution more, because it nicely integrates into ChromeOS by creating a Linux terminal in a window. If you like the convenience of the Termux solution, but do not like the many limitations of running Linux in that environment, then you should definitely check out crouton.

Crouton is another installer script that runs on the developer shell like chrx, but it does something completely different. Instead of installing a fully independent OS, it creates a Linux chroot within ChromeOS. A chroot is like a poor man's Docker container, it is a much older technology that allows you to run processes in the context of a different file system root directory, hence the name "(ch)ange root". If you install a base Linux system in a subdirectory on your disk, chroot allows you to launch processes that see that subdirectory with all its contents as their whole file system.

The great benefit is that you can run one or more chroots in your system and the processes that live in each one are isolated from the others and from the processes in the host system. The downside is that the chroots do not run their own kernel, the kernel is always the one from the host system, in this case ChromeOS, so if your needs require working with specific kernels, or adding custom kernel modules, then this is not for you.

Like chrx, installation is fairly easy. First you download the crouton script from its GitHub repository, and then run it from a developer shell. For example, you can install Ubuntu 16.04 with the xfce and xiwi window managers with the command:

$ sudo sh ~/Downloads/crouton -t xfce,xiwi

The command line arguments allow you to specify what do you want to put in the chroot, with a few Debian, Kali and Ubuntu releases as choices (Ubuntu 16.04 is the default and most tested distribution). In addition to picking the OS, you can select what window manager you want to use, and these include the usual suspects: gnome, kde, unity, xfce, etc., and a special one called "xiwi" (X in a Window), that makes it possible to launch GUI applications in a ChromeOS window, or also in a browser tab. Other options allow you to encrypt the chroot for added security or restore a chroot from a previously made backup.

When you have a chroot created, you have a a few options. If all you want is command-line access, then right from a developer shell you can open a shell in the chroot with the sudo enter-chroot command. You can also start a full-screen session using the window manager of your choice with sudo start<window-manager>, so for example, this would be sudo startxfce4, sudo startunity, etc. depending on what window manager you installed. This will create a second full-screen window that is managed by the chroot, and you can switch back and forth between ChromeOS and the chroot with Ctrl-Alt-⇨ and Ctrl-Alt-⇦.

The most interesting option, however, is the xiwi window manager that I mentioned above. This is a custom manager that uses a memory buffer as display. You install the Crouton integration extension in the Chrome browser, and then for each window that you start in the chroot, the extension opens a new window or tab within the ChromeOS desktop, and displays the xiwi RAM-based display on it. The refresh rate prevents this solution from being usable to play games or any kind of application that requires low latency display updates, but for code editing it is perfect. For example, running sudo startxiwi -T code starts Visual Studio Code in a Chrome tab. Below you can see a screenshot of this IDE open on a Python project.

Google Chromebook

I have been able to work with git, vscode, vim, zsh, tmux, Python, Flask, opencv without a problem. And unlike the weird networking in Termux, the localhost in a chroot maps to the localhost in the host operating system, so for example, you can run a Flask server in a chroot session and open it in Chrome at localhost:5000, exactly like I would on my Mac or Windows computers.

As far as downsides, I haven't really found anything that is a deal killer yet. I found that Docker does not install in the chroot, but rkt does, so that's a good compromise solution to run containers (you can only use host networking though). Obviously you will not be able to run VirtualBox or anything like it. The key mappings take some time to get used to, I need to investigate how they can be improved.

Conclusion

So there you have it, three ways to run Linux on a Chromebook. After playing with all three, I decided I'm going to go with Crouton for the time being. This is the most polished approach of all that I have described, because I can run ChromeOS in all its beauty and have the choice to start terminals or graphical apps as standalone windows or tabs, with ChromeOS and Linux apps happily coexisting in the same desktop, and even in the same browser window.

But with a Chromebook nothing is permanent, since it is super easy to reset it back to a pristine state and start over with a different approach Do you use a Chromebook? Let me know in the comments if you have a great coding workflow.

21 comments

  • #1 Darko said 2017-09-24T07:51:03Z

    I apologize in advance for a "little longer" response, but not very often you can find someone that appreciate Chromebook. I have Crouton on my Chromebook for at least 4 years now, probably even longer. I started it as experiment after I've read that I can have Linux on my Chromebook, so I have researched it and decided for Crouton. That was one of the best hardware/software decisions I have ever made. First time I ever tried it was on Chromebook with ARM processor, and it was OK, but at a time, I had some issues with certain libraries/packages on linux on ARM. So, i sold it and bought Intel Celeron based one that was perfect. I could even upgrade RAM on it , and I did - to 10 GB of RAM, as i can remember. Very good one, except that I realized quickly that I couldn't upgrade 16 GB SSD on it. I did further research and found one that I now call a Little Giant. It is Acer C720 - 2800 model. It has 4 GB of RAM (couldn't upgrade it to more than that, but 4 GB is A LOT for Linux). And upgradable SSD (comes with 16 GB). It even has 128 MB of dedicated video memory!!! So, i bought 128 GB SSD and it was AMAZING machine after that. So much power in it. Boots Linux in seconds. Alt-TAB switching between ChromeOS and Linux. XFCE desktop is very efficient and XIWI gives you ability to run full Linux in browser tab. 8+ hours of battery juice and very silent. The only moving part on this Chromebook is CPU FAN. And i can't hear it at all. You can have multiple Crouton Linux installations, and since now I have 128 GB SSD, i created several of them, and tailored them for specific needs and named them as "developer", "artist", "whitehacker". Needles to say, developer is for development, artist has some multimedia/drawing tools and whitehacker was for learning security. I am java developer by day and many other software/hardware interests the rest of the day. Linux on this hardware is fast! I run several Java SDK versions on it. Tools like Eclipse, Intellij, PyCharm! They are all java based and you would expect them not to be fast on this hardware, but they run OK. For any non-java, I used Atom for long time, now, I use Visual Studio Code. And I am very happy with it. I have three of these C720-2800 that I upgraded to 128 GB ssd. Since they discontinued Acer C720, and I did not need any better hardware for development, i got 2 more from eBay, they were cheap because they have broken display. Display is easy to replace and is about 30$ on Amazon or eBay. My primary Chromebook is ChromeOS + Crouton, and this one is all the time with me. Second one is Ubutnu desktop, not Crouton - standalone ubuntu desktop installation. I have it because i use linux containers (LXC/LXD) for developing and Docker as well. These runs smooth. Couldn't have Docker running in Crouton and I did not even try LXC/LXD. Third one is, "just in case one", if any of previous two die. And they did not. For years now. I don't use Chromebook/Linux in only 2 cases, because 2 software that I use are not available on Linux: - Animestudio Pro, by Smith Micro and - Mixcraft Pro Studio by acoustica.com For those, I use Windows laptop.

  • #2 Miguel Grinberg said 2017-09-25T05:33:08Z

    @Darko: Yeah, I like my Chromebook set up more and more. I use it every time I'm out and so far I had no problems. I was also unable to run Docker under Crouton, but note that rkt installs just fine. The only caveat is that you have to use host networking, but if you can tolerate that, you can run containers on Crouton!

  • #3 KO said 2017-09-26T04:09:13Z

    How do you deal with accidentally pressing spacebar on boot and nuking your crouton setup? Is there a way to hide/skip that msg altogether?

  • #4 Mudpuppy said 2017-09-26T19:24:52Z

    Picked up a Asus 302C chromebook. Switched from Atom to Visual Code studio and running Crouton in the window. Love the setup. I use the terminal plugin in VSC, so I have a shell in the root. Good to go. Have all the git tools and go installed there. Works really well. I figure if I wanted to use docker, I'll just use it on my GCE vm. I like the environment. The only negative is having to be in developer mode and that scary boot screen. Beyond that Crouton works great. TY for the article. Saved me 10x the price on a Macbook. :) - Dennis

  • #5 Miguel Grinberg said 2017-09-26T23:25:20Z

    @KO: You just need to be careful, but if you happen to hit the space bar and wipe everything out, you can start over. I make sure I never leave stuff on any machine that is not saved to github or other cloud service, so losing my chromebook (or actually any of my machines) would just means a little bit of time setting everything up again, but there is really no way I can lose data.

  • #6 Miguel Grinberg said 2017-09-27T00:01:44Z

    Hey Dennis! Glad to know that worked out for you too. I love my CB, works great for pretty much anything I need to do while I'm out. I have even been able to run Docker containers using rkt, which installs cleanly inside a Crouton chroot. The trick is to run your containers in host networking mode, the other more complex modes do not work.

  • #7 Al Krinker said 2017-09-27T13:13:50Z

    Hi Miguel, glad to see the post! I was pretty excited about your work when you were discussing it on Twitter. Question: Did you have a chance to do some benchmarks between dual boot (GalliumOS) and running Crouton insode ChromeOS? I would expect that the dual boot wold be much faster, but I keep reading about people mostly leaning towards Crouton so.... maybe not that much of a difference?

  • #8 Tom said 2017-09-27T21:19:53Z

    I ran across this article and thought it timely as I just published an instruction set for setting up a (primarily web) development environment with a Chromebook last week! Here's the write up: https://github.com/Usarneme/scripts/blob/master/Crouton/CroutonSetupInstructions.md Have you looked into installing your own SSD upgrade? The cloud storage is nice but it's also nice to not worry about hard drive space when building applications that require a lot of resources. I managed to put a 128gb flash drive in my HP Chromebook without too much trouble. If you're interested I can rummage my bookmarks and find you the build link...

  • #9 Miguel Grinberg said 2017-09-28T06:37:36Z

    @Al: I did not do any benchmarks. All I was interested is in having a good experience for coding, and Crouton does it nicely while allowing me to stay in ChromeOS (which I prefer versus a desktop Linux distribution).

  • #10 Miguel Grinberg said 2017-09-28T06:43:49Z

    @Tom: nice guide! I have not upgraded the SSD. I'm not sure I'll ever need more than the 32GB it came with. I'm only using it as a travel laptop, and mostly for coding. At least for the type of projects I work on I do not have any big storage needs.

  • #11 Wey Gu said 2017-10-03T09:35:03Z

    I used Chromebook as my device coding in sofa for the reason I mostly docked my Macbook Pro on my desk connected with many cables. My option was the most lightweight directly use the chromeOS's Shell as my disk space is limited(32Gb) and ChromeOS is a Gentoo anyway. With oh-my-zsh/vim-spf13 installed, powerline font hacked, it fully enabled my intend to code on sofa~~ I used a "homebrew/apt" like package manager called "crew/chromebrew" Maybe you could check it out :-D.

  • #12 Miguel Grinberg said 2017-10-03T16:34:56Z

    @Wey: I had not seen ChromeBrew, interesting project. So I guess there is one more option. Thanks!

  • #13 Robert said 2017-10-04T03:38:20Z

    Hi Miguel I have the same CB as you (XE500C13-K04US) and intend to put Linux on it. Did you have to Update the RW_LEGACY firmware when installing GalliumOS? Do you have any other advice/tips etc. before I begin? Thank you, Robert

  • #14 Miguel Grinberg said 2017-10-04T05:30:46Z

    @Robert: I haven't really used GalliumOS that much, I ended up using Crouton. When I installed it I followed the docs, which said the firmware upgrade was necessary.

  • #15 Robert said 2017-10-05T01:34:39Z

    @Miguel: Shortly after posting I went ahead with Chrx install method, including firmware upgrade. Unfortunately due to flaky wifi connection it never managed to get over 19-60% before failing. So for the time being I've restore everything back to original. Will probably try again with a USB/ethernet adaptor or new router?? The main reason for needing to install Linux is to run Musescore, so the Crouton is not best option for me. Thanks for great and informative article :-) Robert

  • #16 Miguel Grinberg said 2017-10-05T04:40:33Z

    @Robert: What is the reason musescore does not work under Crouton? I have used fairly complex GUI apps such as Visual Studio Code and they run in a Chrome window or tab just fine.

  • #17 Robert said 2017-10-05T11:57:28Z

    @Miguel: Musescore could possibly work with Crouton. But because I found the Android app "Practice Player Live Midi" was virtually unusable due to the frequent erratic pauses while playing music scores - it makes me doubt ChromeOS can effectively share enough resources for a more complex app like Musescore. I'll do some more experimenting on the weekend and see if I can find a way to stretch the Chromebook to support my little project.

  • #18 Robert said 2017-10-05T23:11:42Z

    Wow. I was completely wrong about dual booting being my only option. Although I haven't had a chance to extensively test it - Musescore is running very nicely under Crouton, including the startxiwi method. Very Happy! Cheers, Robert

  • #19 Miguel Grinberg said 2017-10-05T23:25:08Z

    @Robert: Yeah, exactly. Wow is a good way to describe working in Crouton. A lot of things that you assume are not possible work really well!

  • #20 Tom from Omneon said 2017-10-14T20:31:05Z

    Crouton works great. I used it for over a year on a Toshiba CB35 while taking some big data Coursera classes (had to load a few apps like R, etc.). The downside is that at some point, I could no longer access the Crouton "login," i.e., I'd get error messages as the Crouton and/or OS was loading. I never solved it, though Google searches alluded to Google Chrome changing some stuff under the hood. I know this is vague, but just keep an eye on it. Anyway, when it worked, it was pretty awesome -- a very portable development machine. I might install it on my newish Asus C301S.

  • #21 Miguel Grinberg said 2017-10-15T02:56:19Z

    @Tom: Hey, great to hear from you! Hope you are doing well. So far I had no problem, but I created a backup of my clean chroot before I started installing stuff. I really like the "disposable" mentality in ChromeOS, if a chroot starts giving me problems I just throw it away and start another one.

Leave a Comment