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 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
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/swrast_dri.so /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
apt install cros-guest-tools ./cros-ui-config_0.12_all.deb # 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

For full cursor support install the 'adwaita-icon-theme-full' package:

apt install adwaita-icon-theme-full

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 http://goo.gl/nXWSGf.







61 comments:

Linuxium said...

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.

Unknown said...

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!

https://imgur.com/a/cTu4w6Q

Unknown said...

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

WPWoodJr said...

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

usermod -aG users username

Linuxium said...

Done and thanks.

WPWoodJr said...

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!

WPWoodJr said...

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.

Linuxium said...

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?

WPWoodJr said...

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.

WPWoodJr said...

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?

Linuxium said...

Does this help: https://www.reddit.com/r/Crostini/comments/9g1ovl/scale_and_dpi_in_sommelierrc/
or this:
https://chromium.googlesource.com/chromiumos/docs/+/master/containers_and_vms.md#Why-are-windows-sometimes-tiny_fuzzy

WPWoodJr said...

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.

WPWoodJr said...

fyi... https://bugs.chromium.org/p/chromium/issues/detail?id=883616

Linuxium said...

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.

WPWoodJr said...

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

WPWoodJr said...

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

Linuxium said...

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.

WPWoodJr said...

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

Linuxium said...

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

WPWoodJr said...

Possibly.

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

victor said...

Hi, thanks for the guide! Now if I want to make some space and delete what I created, what should I do?

victor said...

Sorry, found the command already. Lazy me!

Unknown said...

This is a little out of date now, cros-unattended-upgrades has been replaced by cros-garcon

Unknown said...

Is breakage expected when Google updates Crostini?

Unknown said...

To answer my own question, I reviewed the list of packages that Google installs in the Debian container: ` dpkg -l 'cros-*'` Then for each package, I used `dpkg -L packageName` to review the list of files in each package.

Would I found is that Google installs surprising little in the containers to accomplish the integration. If this trend continues, it seems likely Ubuntu-compatibility will continue to hold.

Linuxium said...

There is also another package that is new: adapta-gtk-theme_3.93.0.174-cros1_all.deb if you look at https://storage.googleapis.com/cros-packages

Alex said...

I've gone through the guide and I have the folder of linux apps but none of them actually load they just act like they are loading perpetually. Where did i go wrong?

Unknown said...

Chrome 72 also adds a package named "cros-tast-tests". It seems to contain just tests that I'm not sure that end-users need to install or run: https://chromium.googlesource.com/chromiumos/platform/tast-tests/

Linuxium said...

Try rebooting your device. Sometimes the VM seems to hang.

Linuxium said...

I looked into this when it first appeared and I agree that users don't need to install or run them.

WPWoodJr said...

That doesn't seem to get installed even under Debian, correct?

Linuxium said...

Not according to https://chromium.googlesource.com/chromiumos/containers/cros-container-guest-tools/+/master

WPWoodJr said...

I don't see that package listed though:

$ apt list|grep adapta
cros-adapta/stable,now 0.2 all [installed,automatic]

So how does it get installed?

Linuxium said...

I don't think it does get installed. I think it can be ignored for the time being.

WPWoodJr said...

FYI... haven't tried to update to CrOS 73 yet, but saw this:
https://www.reddit.com/r/Crostini/comments/aqce3b/trouble_starting_arch_container_in_version/egf909n/

Linuxium said...

I updated to CrOS 73 and went fine.

Mark Stosberg said...

Since the Crostini packages change over time, this can be used to install all packages that start with `cros-` instead of using a hardcoded list:

apt install $(apt-cache search --names-only 'cros-' | cut -d ' ' -f 1 | grep -v cros-ui-config)

You still need to `apt install` your repackaged cros-ui-config package.

linuxium.com.au said...

The package 'cros-guest-tools' is a metapackage so really all that is now needed is:

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

Linuxium said...

I've updated the post above accordingly.

WPWoodJr said...

Would you add installation of adwaita-icon-theme-full to your instructions please?

Unknown said...

Another awesome guide, thanx. ��
I love getting a full desktop thru vnc but I can't seem to get any other desktops working besides LXDE. I've tried editing ~/.vnc/xstartup with gnome-session, unity, etc. to no avail.
I hope I'm just missing something simple.

Linuxium said...

Done!

Linuxium said...

I've also never got Gnome or Unity to work and always use LXDE.

WPWoodJr said...

Why did you take this stuff out?

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

Linuxium said...

It had become outdated to the point of being wrong and I found that everything worked without the modification. So rather than update to the correct sed commands I deleted it.

WPWoodJr said...

Would it work to simply copy the GTK3 version over the Google version, rather than use sed?

Linuxium said...

By not using 'sed' you end up using the Ubuntu version rather than the Google version which seems to work fine.

Robert L. Harris said...

This is the closest I've gotten to getting Ubuntu running straight up. I can do the exec and log into the ubuntu container but if I try to click the "Terminal" icon, first time ( when the container is stopped ) the status arrow swirls, then quits. After that, it never seems to do anything but I can exec bash in Termina and connect though.

What am I missing?

cowmix said...

I'm not able to paste from ChromeOS into Tilix or Gnome Terminal. This worked from Debian.

Anyone have any ideas on this?

Linuxium said...

Does a reboot of ChomeOS fix it?

Fish said...

Same problem with terminator :(

bwraith said...

I have vnc and lxde working, but some apps I launch from the vncviewer from the lxde menu seem to display on the vncviewer, others on chrome os. Is there a way to control where the applications are displayed?

Linuxium said...

Not that I'm aware of. It seems to be controlled by Garcon/Sommelier directly and is not user-configurable (at least at this stage).

Rather than using VNC & LXDE I suggest using LX Panel directly - see https://linuxiumcomau.blogspot.com/2020/02/using-lxpanel-as-ui-for-crostini.html

Test said...

well now i can't start linux container

Linuxium said...

It may be better to use Ubunu 20.04 now and use relevant version numbers rather than those stated above because Corstini has evolved and new software has been released.

Nicolas Crowell said...

Hello Linuxium, how did you learn the procedures involving cros-ui-config etc.? I'm poking around the cros-guest-tools repo and there's not much in the way of detailed documentation. But surely some of these steps look a little different 2 years later.

Linuxium said...

There wasn't any specific documentation I refered to other than essentially reverse engineering what was installed when creating a Debian container. I haven't looked at this for some time so things could have changed including almost certainly the versions.

Erik said...

So far so good....., until I get stuck here: 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

How do I do this?

Linuxium said...

Did you create the 'eskimo' container in Crostini or on a separate Linux machine? If you created it under Crostini you can ignore this step otherwise you need to physically copy the file from the Linux machine using a USB to the Chrome machine running Crostini. Once you have it on the Chrome machine you use the 'Files' application to share the file with your 'Linux files'. Then run the 'lxc file pull penguin/home/linuxiumcomau/eskimo.tar.gz $LXD_CONF' command (the picture shows this more visually).

Unknown said...

Hi mate,
Is there any way to make this happen as well on FydeOS?
Do you have any Discord of which we could discuss this further?
Here is where I am 'focused': https://forum.radxa.com/t/guide-openfyde-rock-5b-the-best-options/15338
If you could give any instructions that would be fun.
Thank you ;)

Linuxium said...

@Unknown: I've not played with Crostini for a long time since WSL2 is my current toy. I also thought FydeOS has been usurped by Neverware -> Chrome OS Flex?

Post a Comment