intertwingly

It’s just data

Ubuntu 20.04 on Chromebook


Linux (Beta)

Google provides instructions on how to Set up Linux (Beta) on your Chromebook. This gets you Debian. There are instructions out there on how to replace this with Ubuntu, but I've found the instructions to either partially out of date or incomplete or both. This post is an attempt to pull together this information one place an update it.

The first great resource is How to run Ubuntu with full Chrome OS Integration. It talks you through installing Ubuntu 18.04, and mentions that from there you can upgrade to 20.04. However, at the present time, Ubuntu 18.04 no longer works with Crostini, and there is no reason why you can't install Ubuntu 20.04 directly - I've tried it, it works.

There are other problems - you need to add keys to the Crostini repository, and you may wish to change your username or server name. Also, some icons may not be right, and you can fix that too.

Below are the combined instructions with these issues addressed.

Create the Ubuntu container

Start by entering the Chrome shell (crosh) by pressing CTRL+ALT+T, then enter the default termina VM:

vmc start termina

Rename the default penguin container:

lxc stop penguin --force
lxc rename penguin debian

Create a new Ubuntu container named penguin:

lxc launch ubuntu:20.04 penguin

Enter the new container (as root):

lxc exec penguin -- bash

Import public keys

While Ubuntu 20.04 will install, various apt commands will fail due to an inability to verify GPG keys. This problem is not unique to Crostini, it is seen in other environments, like Raspberry Pis.

The fix is to import two public keys:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC

Capture group membership for default ubuntu user, then delete user

With this in place, the rest of the original instructions work just fine. They are copied here so that they can be in one place.

Create a little script which we will use later to add your username to all the default Ubuntu groups, then delete the default ubuntu user:

groups ubuntu >update-groups
sed -i 'y/ /,/; s/ubuntu,:,ubuntu,/sudo usermod -aG /; s/$/ \$USER/' update-groups
killall -u ubuntu
userdel -r ubuntu # ignore warning about mail spool
sed -i '/^ubuntu/d' /etc/sudoers.d/90-cloud-init-users

Install Crostini packages

Prepare for installing Google's Crostini specific packages. First bring Ubuntu up to date:

apt update
apt upgrade -y

Now add the Crostini package repository to apt. This repository provides the Linux integration with Chrome OS (ignore RLIMIT_CORE warning):

echo "deb https://storage.googleapis.com/cros-packages stretch main" > /etc/apt/sources.list.d/cros.list
if [ -f /dev/.cros_milestone ]; then sudo sed -i "s?packages?packages/$(cat /dev/.cros_milestone)?" /etc/apt/sources.list.d/cros.list; fi
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
apt update

A work-around is needed for a cros-ui-config package installation conflict. First, install binutils to get the ar command:

apt install -y binutils

Then create the cros-ui-config work-around package:

apt download cros-ui-config # ignore any warning messages
ar x cros-ui-config_0.12_all.deb data.tar.gz
gunzip data.tar.gz
tar f data.tar --delete ./etc/gtk-3.0/settings.ini
gzip data.tar
ar r cros-ui-config_0.12_all.deb data.tar.gz
rm -rf data.tar.gz

Now install the Crostini packages and the "work-around" package, ignoring any warning messages. This will take awhile:

apt install -y cros-guest-tools ./cros-ui-config_0.12_all.deb

Delete the "work-around" package:

rm cros-ui-config_0.12_all.deb

Install the adwaita-icon-theme-full package. Without this package, GUI Linux apps may have a very small cursor:

apt install -y adwaita-icon-theme-full

Now, shut down the container:

shutdown -h now

Reboot Chrome OS and start the Terminal application from the launcher. If it fails to start the first time, try again and it should work.

Edit the user and host names

By default, Crostini will have created you a user with a name that matches your Google id. If you want something different, you can follow the instructions to Change Default Username, reproduced here:

Exit the terminal, then launch the Chrome shell (crosh) once again by pressing CTRL+ALT+T, from there enter the default termina VM, and from there log in to the container as root:

vmc start termina
lxc exec penguin -- bash

Either set googleId and ubuntuId environment variables before copy and pasting the next few lines, or substitute the desired ids directly into the commands:

killall -9 --user $googleId
groupmod --new-name $ubuntuId $googleId
usermod --move-home --home /home/$ubuntuId --login $ubuntuId $googleId
usermod --append --groups users $ubuntuId
loginctl enable-linger $ubuntuId

While you are here, you can also change your Ubuntu hostname using hostnamectl:

hostnamectl set-hostname $hostname

The container name (which you generally don't see) will remain penguin, but the host name (which is what you see in places like bash prompts) will be changed.

Once you are complete, exit all three by pressing control-d, then entering

lxc stop penguin

Then press control-d two more times.

Finishing up

From a terminal window, run the little script we created above to add your username to all the default Ubuntu groups:

sudo mv /root/update-groups .
bash update-groups
sudo rm update-groups

Fixing desktop icons

At this point, you can install web servers, development tools, and even GUI tools like Firefox, Thunderbird, and Visual Studio Code, and have then run side by side with Chromebook applications. In most cases, things will "just work", but for some applications, you will see a default penguin icon instead of the one associated with your application. Firefox and Thunderbird don't have this problem, but Visual Studio Code does. Perhaps it is because it is a Snap Application.

The fix is to copy the desktop and pixmap files to your .local environment:

mkdir -p ~/.local/share/pixmaps
cp /snap/code/current/snap/gui/com.visualstudio.code.png ~/.local/share/pixmaps
cp /snap/code/current/snap/gui/code.desktop ~/.local/share/applications

Finally, you will need to change three lines in the code.desktop file in your ~/.local directory.

First, you will need to change Exec=code to specify the full path, namely Exec=/snap/bin/code.

Next, in the two places where Icon= is defined, you will need to replace this with the path to the icon that you copied into your .local directory. In my case, the resulting lines look as follows:

Icon=/home/rubys/.local/share/pixmaps/com.visualstudio.code.png

Once these changes are made, you should be able to launch the application using the Launcher in the lower left hand corder of the screen, by clicking on the circle, entering code into the search box and then clicking on the Visual Studio Code icon. Once launched, the application will appear in the shelf at the bottom of the screen. Right clicking on this icon will give you the option to pin the application to the shelf.

Closing thoughts

It is still a beta, and the installation instructions (above) are still a bit daunting. More importantly, things that used to work can stop working at any time, like, for example, Ubuntu 18.04.

That being said, it is a full, no-compromise Ubuntu. I've developed and tested code using this setup. I even have installed my full development environment using Puppet.

The only glitch I do see is occasionally GUI applications don't receive keystrokes. This is generally fixed by switching focus to Chromebook application and then back again. Once the application is able to process keystrokes, it remains able to do so.