Saturday, 4 August 2018

Introduction to Crostini - Part 3: Using Ubuntu by default

When starting the default Crostini container Debian 9 (stretch) is run. Whilst you can add containers of other distros it is also possible to change to default container to Ubuntu or even potentially other distros. This is because all the Crostini/Chrome integration packages are publicly available as '.deb' packages.

The process for creating an Ubuntu default container is quite detailed but essentially consists of creating an Ubuntu container, preparing and then adding the Crostini packages, setting the hostname and user account, optionally installing additional packages. Then if the Ubuntu container has been built on a different Linux machine export the container as a compressed tarball, copy to the Chrome device and import the tarball as an image. Finally move the current default container sideways and replace it with the new Ubuntu container. The Crostini packages need a preparatory step as although they install without issue on Debian, with Ubuntu there is an installation issue with the 'cros-ui-config' package that needs resolving first. The following commands detail the actual steps required.

Start by entering the Chrome shell by pressing CTRL+ALT+T then enter the VM:

vsh termina

and clone a new Ubuntu container (e.g. eskimo):

lxc image copy ubuntu:18.04 local: --alias bionic
lxc launch bionic eskimo

Next enter the new container and prepare for installing the Crostini packages:

lxc exec eskimo -- bash

apt update
apt upgrade
echo "deb 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 --recv-keys 1397BC53640DB551
apt update
apt install binutils
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

If the container is being prepared externally on a Linux machine I've found it is necessary set up some additional dependencies first:

mkdir -p /opt/google/cros-containers/bin/sommelier
mkdir -p /opt/google/cros-containers/lib/
apt install libgl1-mesa-dri
cp /usr/lib/x86_64-linux-gnu/dri/ /opt/google/cros-containers/lib/

Now install the Crostini packages:

apt install cros-adapta cros-apt-config cros-garcon cros-guest-tools cros-sftp cros-sommelier cros-sommelier-config cros-sudo-config cros-systemd-overrides ./cros-ui-config_0.12_all.deb cros-unattended-upgrades cros-wayland # ignore any warning messages
rm -rf cros-ui-config_0.12_all.deb
sed -i 's/Ambiance/CrosAdapta/' /etc/gtk-3.0/settings.ini
sed -i 's/ubuntu-mono-dark/CrosAdapta/' /etc/gtk-3.0/settings.ini
sed -i 's/gtk-sound-theme-name = ubuntu/gtk-font-name = Roboto 11/' /etc/gtk-3.0/settings.ini
sed -i '5d' /etc/gtk-3.0/settings.ini
sed -i -n '2{h;n;G};p' /etc/gtk-3.0/settings.ini

Set the hostname:

sed -i '1cpenguin' /etc/hostname

and set the user account ('linuxiumcomau' in this example):

killall -u ubuntu
groupmod -n linuxiumcomau ubuntu
usermod -md /home/linuxiumcomau -l linuxiumcomau ubuntu
usermod -aG users linuxiumcomau
loginctl enable-linger linuxiumcomau
sed -i 's/ubuntu/linuxiumcomau/' /etc/sudoers.d/90-cloud-init-users

Optionally install additional packages (e.g. a full desktop and a VNC server together with access):

apt install ubuntu-desktop^ lxde lxde-common tightvncserver

Finally shutdown the new container:

shutdown -h now

If the container is being built on on a different machine:

lxc publish eskimo --alias eskimo
lxc image export eskimo eskimo

then copy the file 'eskimo.tar.gz' by USB to the Chrome device into the default penguin container using the 'Files' app and then pull the file from the container to the VM:

lxc file pull penguin/home/linuxiumcomau/eskimo.tar.gz $LXD_CONF

Now on the Chrome device:

lxc stop --force penguin
lxc rename penguin google

and finally either:

lxc rename eskimo penguin

or for the remotely prepared container:

lxc image import $LXD_CONF/eskimo.tar.gz --alias eskimo
lxc init eskimo penguin

Now reboot and try running the terminal to start the 'penguin' container.

If Linux fails to start check container status with 'lxc list'. If it is stopped then start the container with 'lxc start penguin'. Then login as 'linuxiumcomau' with the command 'lxc exec penguin -- /bin/login -f linuxiumcomau' and this should startthe terminal. Thereafter is should function as normal.

The Crostini packages enable Chrome OS to become the desktop environment for the Linux container:

Currently the icons for Linux apps are jumbled in with the Chrome applications however this will change in the next release (see below). Also the Crostini integration relies on Chrome APIs (most likely OAuth 2.0 client IDs) which means that the integration on Chromium OS will fail if they are not included (e.g. the build I provide in Part 2 or the current CloudReady image from Neverware).

So for testing I recompiled the latest Chromium OS source together with my personal API keys and imported the 'eskimo' image previously created. After installing the new Chromium OS image this is what my applicaitions menu looked like:

and after importing and replacing the default container with Ubuntu an additional icon appeared:

As the Chrome menu is now the UI (or desktop) to the Linux container it has changed moving forward to now grouping all the Linux apps in a Linux folder:

and application icons are displayed when Linux apps are run:

One point to note is that if the Linux container is accessed remotely using VNC for example then remotely run applications get displayed locally on the Chrome device:

because this is a feature of using the Crostini/Chrome integration.

Please donate if you find this guide useful using the following link


  1. Thanks to azumafuji for the following comment on r/Crostini:

    After you set the user account with your username run the following command:

    # loginctl enable-linger USERNAME

    Where USERNAME is your username you set in the previous step. Behind the scenes this start garcon and sommelier as your user when the container boots so they are already running. You won't need to login via crosh and lxc and you should just be able to launch apps as you did with the Debian container.

  2. I followed your instructions for setting up Ubuntu. Launcher icons and browser redirects work. But Files integration gets this error - any idea how to fix it? Thanks!

  3. Nevermind, I used my normal username when setting this up, instead of my test one. Sorry!

  4. I noticed that /usr/bin/ adds the user to the "users" group. You might want to add the instruction:

    usermod -aG users username

  5. I've noticed an issue where the mouse pointer and the cursor in VS Code are very small. This doesn't happen in the default Debian container. Any ideas?

    And thanks for this great post BTW!

  6. The small cursor issue is seen in Firefox too... any ideas how to fix it? I tested Debian and there was a regular-sized cursor.

    1. I've had a look and I can't see any difference between the official Google Crostini container and one built based on Debian stretch and the concepts in the post above (i.e. the Crostini packages all install without any modification required).

      I also don't experience a small cursor either in the self-built Debian container, the official Crostini Debian container or the above built Ubuntu container (with desktop packages added) so maybe VS Code alters a default somewhere?

    2. VS Code's cursor is normal-sized in the official container. My Ubuntu container is relatively new (built since 69 went to beta on the Pixelbook about a week ago). I have a backup of an Ubuntu container I created some time ago, I'll try that and report back.

    3. Having the same issue with graphical (X) apps in both my Ubuntu containers (but not in Debian). My Pixelbook has a fairly high-res screen, could that be the cause?

    4. Does this help:
      or this:

    5. I've tried those things, and they affect text sharpness and resolution, but not the mouse pointer size. It's odd, when the pointer is in the graphical program (Firefox, code, Chrome, etc) it is tiny, as soon as the pointer moves to the title bar or otherwise outside the program window, it reverts to a normal ChromeOS pointer.

    6. I found a fix for this. There are cursors that are missing by default in Ubuntu. To fix it, do:

      $ sudo apt install adwaita-icon-theme-full

  7. fyi...

    1. Fixed! I've added the line:

      if [ -f /dev/.cros_milestone ]; then sudo sed -i "s?packages?packages/$(cat /dev/.cros_milestone)?" /etc/apt/sources.list.d/cros.list; fi

      before the key import to ensure the matching cros binaries are selected.

      If you have a previously build container and are now on a later version of Chrome OS (i.e. 70 or later) you can update simply by running the line as a command and then running 'sudo apt update' followed if required by 'sudo apt upgrade'.

      However judging from the thread this may break again in the future if 'cros.list' is indeed removed.

    2. We need a way to update it to the latest package, removing the previous one, eg 70 -> 71, that way it can be added to the .profile

    3. I've looked at this and at this stage it may be better to manually update from 70 -> 71 etc. as things are rather fluid with development. I'll keep and eye on it in the interim.

      Note with release 71 there is a new 'cros' binary that gets installed: cros-notificationsd. I'll update the instructions when release 71 hits the dev channel.

    4. Cool thanks. Did you see my fix above for small cursors?

    5. Yes. Is it because you are not installing the full 'ubuntu-desktop^' package that you get this issue?

    6. Possibly.

      adwaita-icon-theme-full is actually installed in Google's Debian distro, although you can't see it with apt under Debian.