Running Linux apps on your Chromebook

I’ve had my Pixelbook for a while now and have been a avid user of the excellent Termux application. It’s a great alternative for using a Linux-like environment on your Pixelbook without using either Crouton or jumping out of the stable channel to play with Crostini. I’ve played with both but found Crouton made the Pixelbook run hot (with a full UI desktop — not entirely unexpected!) and the first iteration of Chrome 70 I tried on the Dev channel was so unstable, Crostini just wasn’t worth it.
Doing it all in stable
I’d read a few reports of people running GUI apps from within Termux by installing another Linux distribution in combination with a VNC viewer so I thought I’d give it a go. I took influence from a number of sites including the excellent tmux-fedora repo (from which most of the installation steps are copied). What follows is the essential steps to get Fedora 28 install inside a chroot within Termux and then connect to an LXDE desktop.
Getting started
You need Termux for this — so you’ll need to be using a Chrome device that can work with Android apps. What follows are a number of commands that you’ll type at the prompt once you’ve opened Termux.
Installing Fedora
The thoughtful folks at Fedora already have a base Fedora 28 container for us to use. We simply download this and extract the filesystem from the single layer that it contains (if you’re interested, the docker article on storage drivers would be a good start). Once this is done, we create a simple script which uses proot to ‘enter’ the filesystem and at that point — you’re essentially running inside Fedora 28 (want to know more about chroot/proot - start here!)
Prereqs
Make sure you’ve got proot, wget and tar installed within Termux. You can do this like so:
$ pkg install -y proot tar wgetCreate a directory for your installation
You need somewhere to store the Linux installation. For the purposes of this demo — that’s going to be ~/fedora28
$ mkdir ~/fedora28
$ cd ~/fedora28Download and unpack the container image
Now we’ll download the container image and unpack the filesystem. Note that we set the name of the output file to be shorter and simpler to work with.
Download the image:
$ wget -O fedora.tar.xz https://download.fedoraproject.org/pub/fedora/linux/releases/28/Container/x86_64/images/Fedora-Container-Base-28-1.1.x86_64.tar.xzUnpack it:
# This unpacks the layer.tar file from the downloaded image
$ tar xf fedora.tar.xz --strip-components=1 --exclude json --exclude VERSION# This extracts the filesystem from the layer tarball
$ tar xpf layer.tar
Ensure you can write to the directory and remove the downloaded files:
$ chmod +w .
$ rm layer.tar fedora.tar.xzNow we need to make sure that once you’re inside the proot, you can resolve DNS names. To do this we’ll use Google’s public DNS server:
$ echo "nameserver 8.8.8.8" > etc/resolv.confNext we need a handy way to jump into Fedora. This next command is a “here doc” and will create a script to launch proot with the correct parameters:
$ cat > /data/data/com.termux/files/usr/bin/startfedora <<- EOF
#!/data/data/com.termux/files/usr/bin/bash
unset LD_PRELOAD && proot --link2symlink -0 -r ~/fedora28 -b /dev/ -b /sys/ -b /proc/ -b /storage/ -b /data/data/com.termux/files/home/storage/downloads:/downloads -b $HOME -w $HOME /bin/env -i HOME=/root TERM="$TERM" PS1='[termux@fedora \W]\$ ' LANG=$LANG PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
EOFIf you run this script (it should be in your $PATH) you should end up in a shell that looks like this (note that your ‘Downloads’ folder is mounted at /downloads):
[termux@fedora home]$Getting the right packages
All we’re going to do here is get the minimum set of packages required to get a running Linux desktop experience.
First — install any available updates:
[termux@fedora home]$ dnf updateNext, we need a VNC server — this is what you’ll connect to in order to see the GUI:
[termux@fedora home]$ dnf install tigervnc-serverNow the LXDE packages:
[termux@fedora home]$ dnf group install lxde-desktopLet’s start the VNC server. I use the default 1200x800 display setting on my Pixelbook so this is what I’m going to set the geometry to — change yours as appropriate. You’ll be asked for to enter a password which you’ll use when you connect later. Note the ‘:1’ refers the first display screen:
[termux@fedora home]$ vncserver -geometry 1200x800 :1You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
xauth: file /root/.Xauthority does not existNew 'localhost:1 (root)' desktop is localhost:1Creating default startup script /root/.vnc/xstartup Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/localhost:1.log
We also need the IP address that has been assigned to Termux (we’ll use this when we setup the VNC connection — yours will likely be different):
[termux@fedora home]$ ip r | awk '{print $NF}'
100.115.92.2Lastly, export your DISPLAY and start LXDE:
[termux@fedora home]$ export DISPLAY=:1
[termux@fedora home]$ startlxde &
[1] 6803
[termux@fedora home]$ ** Message: 16:43:06.217: main.vala:113: Session is LXDE
** Message: 16:43:06.217: main.vala:114: DE is LXDE ** Message: 16:43:06.290: main.vala:145: log directory: /root/.cache/lxsession/LXDE
** Message: 16:43:06.290: main.vala:146: log path: /root/.cache/lxsession/LXDE/run.logConnecting to your desktop
Almost there. I’m using VNC Viewer from the Play store for this so go ahead and install it.
Once you’ve opened the app, click the green ‘+’ button in the bottom right corner. In the ‘Address’ field, enter the IP address you saw above followed by ‘:1’. In my case this would be “100.115.92.2:1”. When you’re done, click ‘Create’ and then click on your newly created connection. You’ll see an ‘Authentication’ dialogue box — enter the password you used when you started the vncserver above.
Enjoy!
That’s it! If all has gone well, you should now be looking at the stock Fedora LXDE desktop! You can now go and install GIMP and LibreOffice just like you’ve always wanted…