Run Linux programs on ChromeBook with Crostini
I bought a Samsung ChromeBook Pro about two years ago as my coding laptop.
To set up the development environment, I tried Termux, Crouton, and
Chromebrew (aka crew
), and finally settled on crew.
You can find more details in the following posts.
Overall I am very satisfied with ChromeOS and this Samsung device. One missing piece, however, is Docker. (I heard it’s possible to run Docker inside Crouton with compromised performance, but I never tried.) The good news is that Google started a project called Crostini a few years ago to enable Linux container inside ChromeOS. It can do what Termux, Crouton, and Crew can do. In addition,
- There is no need to switch to developer mode.
- We get easy installation and fast execution of Docker.
The bad news is that not all Chromebooks are supported. For example, my Samsung ChromeBook Pro is not. However, (to my annoyance), the cheaper variants of this device, i.e., Samsung Chromebook Plus and Samsung Chromebook Plus V2, are both supported.
In late August, I got a deal for HP Chromebook x360 (14-da0021nr), which has Crostini support. Compared to the Samsung device, its pros and cons are
- pros
- Good price: I paid $349, whereas the Samsung Chromebook Pro costed me $520 in 2017.
- Intel 8th gen i3 processor + 8G memory + 64 GB storage
- The 14 inch display is wide enough for 160 columns.
- The keyboard is pleasant to type on and has backlit.
- The speaker is slightly louder, but still not as loud as I want.
- Besides two USB-C ports, there is also a USB-A port.
- cons
- It’s quite heavy: 3.7 pounds.
- The hinge of the screen is loose. As I move the laptop, the screen dangles.
If you are interested in buying a Chromebook to run Crostini, check out the following links
- List of Crostini enabled devices
- Auto Update policy for all Chromebooks: Google provides support for each Chromebook for a limited years. After that time span, the device won’t be able to get ChromeOS upgrade.
- Chrome Unboxed: This is a Youtube channel with Chromebook reviews.
In the rest of the post, I will go over the setup for the development environment. The main pieces are
- Vim 8.1
- Python 3.7
- Go 1.12
- Docker 19.03.1
- VS Code
my setup procedure
To enable Crostini, go to Settings, search for Linux (Beta)
and enable it.
Alternatively, it can be accessed with this address chrome://settings/?search=linux
.
After that, you will be able to access Terminal
as an app.
By default, the Linux distribution is Debian 9 stretch,
which you can check with
cat /etc/issue
To make the installation easier (i.e., avoid compilation),
I add the following line in /etc/apt/sources.list
deb http://ftp.de.debian.org/debian testing main
Then run
echo 'APT::Default-Release "stable";' | sudo tee -a /etc/apt/apt.conf.d/00local
sudo apt-get update
sudo apt-get -t testing install python3
sudo apt-get -t testing install python3-pip
sudo apt-get -t testing install vim
sudo apt-get -t testing install texlive
sudo apt-get -t testing install golang
sudo apt-get -t testing install golang-go.tools
It installs Python 3.7, Vim 8.1, Go 1.12, and Latex.
I want Vim 8.1 because it supports embedded terminal (try vert ter
command).
The last line is to make godoc --http :8888
to work. This command has been removed from the normal
distribution package. Also go get golang.org/x/tools/cmd/godoc
probably
won’t work. See this issue for details.
Docker
To install Docker, I basically followed the official installation guild for Debian.
To avoid using root (i.e., docker ...
instead of sudo docker ...
), run
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
Some Docker resources are listed here too
VS Code
Installing VS Code is simple. After downloading the installable for Debian,
move it from Downloads
to Linux files
(Alternatively, you can run wget
or curl
inside the Terminal
). Then run
sudo dpkg -i code_1.37.1-1565886362_amd64.deb
It will show up as an app.
Github blog
I also installed jekyll
to run my blog. However, the default port doesn’t work.
I thus use port 8000 as it’s automatically exposed.
jekyll serve --draft -P 8000
Below is a list of the exposed ports
// TCP ports to statically forward to the container over SSH.
const uint16_t kStaticForwardPorts[] = {
3000, // Rails
4200, // Angular
5000, // Flask
8000, // Django
8008, // HTTP alternative port
8080, // HTTP alternative port
8085, // Cloud SDK
8888, // ipython/jupyter
9005, // Firebase login
};
You can find more details in this post
Tips
- Open a new terminal window:
- While the focus is on the terminal window, press ctrl + shift + n
- Right click (or alt + left click) the ‘terminal’ logo in the status bar, and choose ‘New Window’ (It doesn’t work every time though)
- Access ChromeOS folders from Crostini terminal:
Right click the folder and choose
share with Linux
. It then shows up in/mnt/chromeos/
. - Stay on the stable channel. I am usually on the dev channel, and often times the bluetooth, ear phone break. Sometimes the Chrome browser crashes every few minutes.
- Do not use USB-A / USB-C converter. I think it destroyed the ports of my Samsung Chromebook Pro.
Wish list
- Multiple tab for Linux terminal
- Embed the Linux app, e.g., VS Code, inside Chrome tab