Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Last active March 16, 2023 05:22
Show Gist options
  • Save rstacruz/aeb2273d19e5f5ffbe27a973cb82717f to your computer and use it in GitHub Desktop.
Save rstacruz/aeb2273d19e5f5ffbe27a973cb82717f to your computer and use it in GitHub Desktop.
Arch Linux ARM on Crostini

Arch Linux ARM on Crostini

Screenshot

I got Arch Linux ARM installed on a Lenovo Chromebook Duet! I mostly used the instructions from the Arch Wiki as reference.

0. Before we begin

  • Enable Linux development environment in Chrome OS's settings
  • Get it running

This comes with Debian by default, but this guide will install Arch Linux alongside that.

Screenshot

1. Installing the image

(ctrl-alt-t)
# ^ Opens the crosh shell
#
# › crosh>

vmc start termina
vsh termina
# ^ Enters the Linux VM ("termina"). From this VM, we
#   will create an LXC container from the Arch Linux image.
#
# › (termina) chronos@localhost ~ $

lxc remote add images-uk https://uk.images.linuxcontainers.org --protocol simplestreams --auth-type tls
lxc remote list
# ^ Optional: adds a UK mirror if that's closer to you.
#   This can be skipped; use `images:` rather than `images-uk:`
#   in the next step.
#
# > |      NAME       |                    URL                |   PROTOCOL    |  AUTH TYPE  | PUBLIC | STATIC |
#   | images          | https://images.linuxcontainers.org    | simplestreams | none        | YES    | NO     |
#   | images-uk       | https://uk.images.linuxcontainers.org | simplestreams | none        | YES    | NO     |

lxc launch images-uk:archlinux/current arch
# ^ Creates the LXC container with Arch Linux.
#   This will take a LONG time.
#
# › Creating arch
#   Starting arch

lxc list
# ^ It should now be started and in this list after that.
#
# > |      NAME      |  STATE  | IPV4 | IPV6 |    TYPE    | SNAPSHOTS |
#   | arch           | RUNNING |      |      | PERSISTENT | 0         |
#   | penguin        | STOPPED |      |      | PERSISTENT | 0         |

lxc exec arch bash
# ^ Enter the container.
#   If you see the prompt below, you're now in Arch!
#
# > [root@arch ~]#

2. Set up the user

There's already a default user (alarm). I renamed that to my own preferred name.

grep 1000:1000 /etc/passwd
# ^ Shows the default user. It's usually `alarm` for
#   the ARM build, but I haven't tried it elsewhere.
#
# > alarm

groupmod -n rsc alarm
usermod -d /home/rsc -l rsc -m -c rsc alarm
# ^ Rename that user. I name mine `rsc`. This should
#   be the same username that was used to set up the
#   default Debian environment.

passwd rsc
# ^ Change passwd

visudo
# ^ Uncomment the line that says:
#   %wheel ALL=(ALL) NOPASSWD ALL

usermod -aG wheel rsc
# ^ Gives sudo rights to user

3. Setting up networking

Networking doesn't work by default (try pinging out), and this was what I did to turn it on.

# ^ We should still be in the root shell inside Arch
#   [root@arch ~]#

ip -4 a show dev eth0
# ^ See if there's a network connection.
#   non-empty output = good (skip)
#   empty output     = proceed below

dhcpcd eth0
ping 8.8.8.8
# ^ Connects to the internet. It if works, ping should
#   start giving some results.
#
# > dhcpcd-9.4.0 starting
#   ...
#   forked in background, child pid 122
#
# > 64 bytes from 8.8.8.8: icmp_seq=1 ttl=53 time=27.6ms
#   ...

pacman -Syu dhclient
systemctl enable --now dhclient@eth0
# ^ use dhclient to auto-connect eth0 on startup

4. Log in as user

Now that there's a user (rsc), I logged on directly with it and did the first system update (pacman -Syu).

exit
# ^ Go back to termina if you're still inside Arch
# > (termina) chronos@localhost ~ $

lxc exec arch su - rsc
# ^ Log in as the user
#
# > [rsc@arch ~]$

sudo nano /etc/pacman.d/mirrorlist
# ^ Optional: Use a closer mirror. Eg, change
#   mirror.archlinuxarm.org => au.mirror.archlinuxarm.org
#
#   A full list of mirrors are in this page:
#   https://archlinuxarm.org/about/mirrors

sudo nano /etc/pacman.conf
# ^ Optional: Update pacman config. I prefer to:
#   - uncomment #Color
#   - uncomment #VerbosePkgLists
#   - uncomment #ParallelDownloads = 5

sudo pacman -Syu base-devel git curl make neovim wl-clipboard fish
# ^ Installs some packages

5. Install yay

# This step requires `base-devel`, which was installed
# in a previous step. If there are errors about
# fakeroot, try: sudo pacman -Syu base-devel

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

6. Install cros-container-guest-tools

cros-container-guest-tools allows X apps to work. It can be installed using yay.

yay -S cros-container-guest-tools-git

cp -r /etc/skel/.config/pulse ~/.config/pulse
# ^ As directed by the post-install message. This will
#   enable audio to wor.

yay -S xorg-xwayland
yay -S mousepad
# ^ Install a basic text editor so we can test it out

exit
# ^ Go back to termina
#   (termina) chronos@localhost ~ $

lxc console arch
# ^ Log in via tty. This has no colours, but it
#   will be necessary to start/enable user services.
#
# > To detach from the console, press: <ctrl>+a q
#   arch login: rsc
#   password:
#   [rsc@arch ~]$

systemctl enable --now --user sommelier{,-x}@{0,1}.service
# ^ Starts and enables X11 and Wayland bridges
#
# > Created symlink /home/rsc/.config/systemd/user/default.target.wants/[email protected] -> /usr/lib/systemd/user/[email protected].
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/[email protected] -> /usr/lib/systemd/user/[email protected].
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/[email protected] -> /usr/lib/systemd/user/[email protected].
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/[email protected] -> /usr/lib/systemd/user/[email protected].

mousepad
# ^ If it worked, this will open up a mousepad window

Screenshot of Mousepad

7. Make it the default

The default image is Debian (penguin), but we can move that away and make Arch the default. To do this, we'll rename the LXC image to penguin.

# ^ Start in termina
#   (termina) chronos@localhost ~ $

lxc list
lxc stop arch
lxc stop penguin
# ^ Stop all LXC containers that are `RUNNING`

lxc rename penguin google
lxc rename arch penguin
# ^ Swap out the names

exit
# ^ Go back to crosh
# > crosh>

vmc list
vmc stop termina
vmc stop dev
# ^ Stop all VMs

# ... after this, run the Terminal and it should boot
# up with your user
@jtaylor-ion
Copy link

jtaylor-ion commented Jul 20, 2022

I get stuck on the last part, "after this, run the Terminal and it should boot". It just keeps spinning and eventually says "error starting penguin container: 58 - launching vmshell failed".
Also, on one of the steps, I think it was "yay -S cros-container-guest-tools-git" it asks a few questions that I don't know the answer to, so I had to guess. Is that normal or did I do something wrong? It seemed to work okay. Mousepad came up fine. This guide is awesome. Thanks for creating it.

@cdd100
Copy link

cdd100 commented Oct 28, 2022

Everything worked fine until I restarted my chromebook. It now fails with operation vm_start failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment