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
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 http://goo.gl/nXWSGf.
Thanks to azumafuji for the following comment on r/Crostini:
ReplyDeleteAfter 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.
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!
ReplyDeletehttps://imgur.com/a/cTu4w6Q
Nevermind, I used my normal username when setting this up, instead of my test one. Sorry!
ReplyDeleteI noticed that /usr/bin/run_container.sh adds the user to the "users" group. You might want to add the instruction:
ReplyDeleteusermod -aG users username
Done and thanks.
DeleteI'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?
ReplyDeleteAnd thanks for this great post BTW!
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.
ReplyDeleteI'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).
DeleteI 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?
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.
DeleteHaving 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?
DeleteDoes this help: https://www.reddit.com/r/Crostini/comments/9g1ovl/scale_and_dpi_in_sommelierrc/
Deleteor this:
https://chromium.googlesource.com/chromiumos/docs/+/master/containers_and_vms.md#Why-are-windows-sometimes-tiny_fuzzy
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.
DeleteI found a fix for this. There are cursors that are missing by default in Ubuntu. To fix it, do:
Delete$ sudo apt install adwaita-icon-theme-full
fyi... https://bugs.chromium.org/p/chromium/issues/detail?id=883616
ReplyDeleteFixed! I've added the line:
Deleteif [ -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.
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
DeleteI'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.
DeleteNote 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.
Cool thanks. Did you see my fix above for small cursors?
DeleteYes. Is it because you are not installing the full 'ubuntu-desktop^' package that you get this issue?
DeletePossibly.
Deleteadwaita-icon-theme-full is actually installed in Google's Debian distro, although you can't see it with apt under Debian.
Hi, thanks for the guide! Now if I want to make some space and delete what I created, what should I do?
ReplyDeleteSorry, found the command already. Lazy me!
DeleteThis is a little out of date now, cros-unattended-upgrades has been replaced by cros-garcon
ReplyDeleteIs breakage expected when Google updates Crostini?
ReplyDeleteTo 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.
ReplyDeleteWould 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.
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
DeleteThat doesn't seem to get installed even under Debian, correct?
DeleteNot according to https://chromium.googlesource.com/chromiumos/containers/cros-container-guest-tools/+/master
DeleteI don't see that package listed though:
Delete$ apt list|grep adapta
cros-adapta/stable,now 0.2 all [installed,automatic]
So how does it get installed?
I don't think it does get installed. I think it can be ignored for the time being.
DeleteI'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?
ReplyDeleteTry rebooting your device. Sometimes the VM seems to hang.
DeleteChrome 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/
ReplyDeleteI looked into this when it first appeared and I agree that users don't need to install or run them.
DeleteFYI... haven't tried to update to CrOS 73 yet, but saw this:
ReplyDeletehttps://www.reddit.com/r/Crostini/comments/aqce3b/trouble_starting_arch_container_in_version/egf909n/
I updated to CrOS 73 and went fine.
DeleteSince the Crostini packages change over time, this can be used to install all packages that start with `cros-` instead of using a hardcoded list:
ReplyDeleteapt 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.