Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save baldrailers/09ba52a17219ca1e8fbf233dc8a4b375 to your computer and use it in GitHub Desktop.
Save baldrailers/09ba52a17219ca1e8fbf233dc8a4b375 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/sommelier@0.service -> /usr/lib/systemd/user/sommelier@.service.
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/sommelier-x@0.service -> /usr/lib/systemd/user/sommelier-x@.service.
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/sommelier@1.service -> /usr/lib/systemd/user/sommelier@.service.
#   Created symlink /home/rsc/.config/systemd/user/default.target.wants/sommelier-x@1.service -> /usr/lib/systemd/user/sommelier-x@.service.

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
@bdmorin
Copy link

bdmorin commented Jun 7, 2022

This is so amazing. It worked perfectly on my Chromebook Lenovo Duet 5!
I really want to be able to run something other than debian!
THANK YOU!

[bdmorin@arch ~]$ neofetch
                   -`                    bdmorin@arch 
                  .o+`                   ------------ 
                 `ooo/                   OS: Arch Linux ARM on Chrome OS aarch64 
                `+oooo:                  Kernel: 5.10.114-16023-g49367ce3348c 
               `+oooooo:                 Uptime: 49 mins 
               -+oooooo+:                Packages: 306 (pacman) 
             `/:-:++oooo+:               Shell: fish 3.4.1
            `/++++/+++++++:              DE: Generic 
           `/++++++++++++++:             Theme: CrosAdapta [GTK2/3] 
          `/+++ooooooooooooo/`           Icons: Adwaita [GTK2/3] 
         ./ooosssso++osssssso+`          Terminal: ld-linux-armhf. 
        .oossssso-````/ossssss+`         CPU: (8) 
       -osssssso.      :ssssssso.        GPU: 00:02.0 Red Hat, Inc. Virtio GPU 
      :osssssss/        osssso+++.       Memory: 22MiB / 3171MiB 
     /ossssssss/        +ssssooo/-
   `/ossssso+/:-        -:/+osssso+-                             
  `+sso+:-`                 `.-/+oso:                            
 `++:.                           `-/+/
 .`                                 `/

@ngencokamin
Copy link

ngencokamin commented Jul 18, 2022

I'm able to log into arch through crosh, but for some reason when I try to open in terminal it hangs on "Starting the Linux container". Any ideas on how to resolve/troubleshoot this issue? This is on a lenovo duet 5

Edit: eventually broke with error [=======- ] Starting the Linux container Error starting penguin container: 58 Launching vmshell failed: Error starting crostini for terminal: 58

Opening a new tab, I get ERROR vsh: [vsh.cc(150)] Failed to launch vshd for termina:penguin: requested container does not exist: penguin

@bdmorin
Copy link

bdmorin commented Jul 18, 2022

I'm able to log into arch through crosh, but for some reason when I try to open in terminal it hangs on "Starting the Linux container". Any ideas on how to resolve/troubleshoot this issue? This is on a lenovo duet 5

Edit: eventually broke with error [=======- ] Starting the Linux container Error starting penguin container: 58 Launching vmshell failed: Error starting crostini for terminal: 58

Opening a new tab, I get ERROR vsh: [vsh.cc(150)] Failed to launch vshd for termina:penguin: requested container does not exist: penguin

This is common at first, or if you didn't do the sommelier part as the user.
It also matters if you are beta/dev channel of chromeos also. ChromeOS stable currently only let's you easily manage a single linux container "correctly".

This based on MY experience. This might not be correct, or definitive, just MY experience, please don't torch me if I missed something.

If you're running stock ChromeOS (stable)

  1. Get the basic linux/debian/penguin experience working, don't update it or anything, just make sure it launches
  2. Close the linux terminal environment completely. Right click on the icon and close linux.
  3. Go into crosh, vmc delete termina and vmc start termina. This may seem redundant, but this works best on stable chromeOS I've found.
  4. vsh termina and then do your arch download from https://us.lxd.images.canonical.com/ This has is different from the gist above, it's updated.
  5. You can name your image container whatever you like, after you're done, you'll rename it to penguin.
  6. Do pretty much everything else in the gist.
  7. Final step is to be in termina, stop the lxc arch container
  8. RENAME your arch container to penguin
  9. All this should be done BEFORE YOU EVER START UP TERMINAL AGAIN. If you start terminal before you've finalize your arch container and renamed it penguin, it will dork everything up.
  10. IN MY EXPERIENCE in Stable ChromeOS channel, I can't have more than 1 container reliably work. You can absolutely create as many as you have resources for, however I find they break all the f'in time.

If you're running any other channel (beta/dev/whatever)

  1. You enable the linux environment and you DON'T need to vmc destroy termina
  2. You DO need to stop the linux environment, by right clicking on terminal and choosing stop. You can also just stop the instance in lxc, however I like to go the extra mile to ensure terminal isn't watching.
  3. Beta channel has bindings to properly manage more than one container in hterm/terminal
  4. You can just vsh termina in crosh, do your arch download, set arch up correctly, then exit back to crosh
  5. You can rename penguin to debian or whatever, you don't have to destroy it.
  6. You rename your arch container to penguin.
  7. If you did everything correctly, penguin will launch properly as penguin, a completely integrated environment.

Some notes that dork everything up in my experience

  • Terminal is running when you do all this. I don't know what ChromeOS is doing, but it will diddle with your containers if it sees it change while terminal is running. While you're installing arch, ALWAYS have terminal exited, and the linux environment stopped.
  • yay is your package manager now. Use it over pacman where ever you can. The reason is it will install everything as your user, and integrate with ChromeOS, I'm not saying this to be partisan over pacman - in my experience things just run more integrated when it's your user, not root. Root is not integrated with chromeos.
  • GET THE SOMMELIER steps correct. When you are YOUR USER, not root: systemctl enable --now --user sommelier{,-x}@{0,1}.service works perfectly.
  • When you're done with all this, you might still have trouble starting your arch install. Don't fret, just reboot your device. Then try to launch your penguin terminal.
  • I like powerline fonts, it's ridiculous to setup though.
    • You can hit shift-alt-j and paste this into console, and it usually works, but will reset when terminal/reboot does.
term_.prefs_.set('font-family', '"Source Code Pro", monospace'); 
term_.prefs_.set('user-css', 'https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts@ba4426cb0c0b05eb6cb342c7719776a41e1f2114/PowerlineFonts.css');
  • Setting this in hterm config works better for me. chrome-untrusted://crosh/html/nassh_preferences_editor.html
  • then make your font "Source Code Pro", monospace
  • make your custom css url https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts@ba4426cb0c0b05eb6cb342c7719776a41e1f2114/PowerlineFonts.css
  • Now if you use something like lsd for ls you'll see the cute icons, folders and whatever, you'll also be able to use fancy prompts.
  • hterm is a full color terminal, it can do the sixel stuff you might see with iterm/kitty/alacrity/wezterm. You can view images directly in hterm, and it works surprisingly well.
  • Personally, I setup a new folder in my chromebook under /mnt/chromeos/MyFiles/workspace using the ChromeOS files app. Then symlink it in my home directory. ln -s /mnt/chromeos/MyFiles/workspace $HOME Then i put stuff that I might want to keep in case my arch terminal dies a gruesome death, git repos and the like.
    • I use git grab instead of git clone and my working directory is workspace. GRAB_HOME=$HOME/workspace/ git-grab maintains domain/user/repo directory structure, and I don't have to worry about collisions. The performance across the /mnt mount is kinda slow, but I don't have to recreate everything if I loose my arch install.
    • I use chezmoi with 1password to locally backup all my configs to the workspace directory, AND github. Then I can always have my environment in the event of an arch container crash, or I want to start over.
  • mDNS is never covered in these tutorials, and I absolutely HATE that it's not default for personal use. If you want to use your local lan mdns (hostname.local), you'll have to fiddle with systemd-resolve a bunch. After messing this up endlessly, I ended up just using my local home pi.hole installation, and don't even bother trying to get mdns enabled and stay enabled. pi.hole handles all my local resolution. Your requirements may vary, however I found this to be the easiest solution. I don't want to over manage my arch /etc install because shit breaks, I don't want to remember to fix it later.
  • I've started an ansible setup that tries to do everything post arch/penguin install. It's not working great yet, but when I feel it's stablish I'll post my work.

I hope some of this was useful for folks trying to run arch on their chromebooks. I like debian, however bullseye requires custom repos to make everything I use work. Arch/yay makes nearly all that transparent. Bullseye's default fish shell is 3.1, which is horrible, 3.4 or go home! (= So I'm really happy using Arch for my local environment.

@ngencokamin
Copy link

ngencokamin commented Jul 18, 2022

I'm able to log into arch through crosh, but for some reason when I try to open in terminal it hangs on "Starting the Linux container". Any ideas on how to resolve/troubleshoot this issue? This is on a lenovo duet 5
Edit: eventually broke with error [=======- ] Starting the Linux container Error starting penguin container: 58 Launching vmshell failed: Error starting crostini for terminal: 58
Opening a new tab, I get ERROR vsh: [vsh.cc(150)] Failed to launch vshd for termina:penguin: requested container does not exist: penguin

This is common at first, or if you didn't do the sommelier part as the user. It also matters if you are beta/dev channel of chromeos also. ChromeOS stable currently only let's you easily manage a single linux container "correctly".

This based on MY experience. This might not be correct, or definitive, just MY experience, please don't torch me if I missed something.

If you're running stock ChromeOS (stable)

  1. Get the basic linux/debian/penguin experience working, don't update it or anything, just make sure it launches
  2. Close the linux terminal environment completely. Right click on the icon and close linux.
  3. Go into crosh, vmc delete termina and vmc start termina. This may seem redundant, but this works best on stable chromeOS I've found.
  4. vsh termina and then do your arch download from https://us.lxd.images.canonical.com/ This has is different from the gist above, it's updated.
  5. You can name your image container whatever you like, after you're done, you'll rename it to penguin.
  6. Do pretty much everything else in the gist.
  7. Final step is to be in termina, stop the lxc arch container
  8. RENAME your arch container to penguin
  9. All this should be done BEFORE YOU EVER START UP TERMINAL AGAIN. If you start terminal before you've finalize your arch container and renamed it penguin, it will dork everything up.
  10. IN MY EXPERIENCE in Stable ChromeOS channel, I can't have more than 1 container reliably work. You can absolutely create as many as you have resources for, however I find they break all the f'in time.

If you're running any other channel (beta/dev/whatever)

  1. You enable the linux environment and you DON'T need to vmc destroy termina
  2. You DO need to stop the linux environment, by right clicking on terminal and choosing stop. You can also just stop the instance in lxc, however I like to go the extra mile to ensure terminal isn't watching.
  3. Beta channel has bindings to properly manage more than one container in hterm/terminal
  4. You can just vsh termina in crosh, do your arch download, set arch up correctly, then exit back to crosh
  5. You can rename penguin to debian or whatever, you don't have to destroy it.
  6. You rename your arch container to penguin.
  7. If you did everything correctly, penguin will launch properly as penguin, a completely integrated environment.

Some notes that dork everything up in my experience

  • Terminal is running when you do all this. I don't know what ChromeOS is doing, but it will diddle with your containers if it sees it change while terminal is running. While you're installing arch, ALWAYS have terminal exited, and the linux environment stopped.

  • yay is your package manager now. Use it over pacman where ever you can. The reason is it will install everything as your user, and integrate with ChromeOS, I'm not saying this to be partisan over pacman - in my experience things just run more integrated when it's your user, not root. Root is not integrated with chromeos.

  • GET THE SOMMELIER steps correct. When you are YOUR USER, not root: systemctl enable --now --user sommelier{,-x}@{0,1}.service works perfectly.

  • When you're done with all this, you might still have trouble starting your arch install. Don't fret, just reboot your device. Then try to launch your penguin terminal.

  • I like powerline fonts, it's ridiculous to setup though.

    • You can hit shift-alt-j and paste this into console, and it usually works, but will reset when terminal/reboot does.
term_.prefs_.set('font-family', '"Source Code Pro", monospace'); 
term_.prefs_.set('user-css', 'https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts@ba4426cb0c0b05eb6cb342c7719776a41e1f2114/PowerlineFonts.css');
  • Setting this in hterm config works better for me. chrome-untrusted://crosh/html/nassh_preferences_editor.html

  • then make your font "Source Code Pro", monospace

  • make your custom css url https://cdn.jsdelivr.net/gh/wernight/powerline-web-fonts@ba4426cb0c0b05eb6cb342c7719776a41e1f2114/PowerlineFonts.css

  • Now if you use something like lsd for ls you'll see the cute icons, folders and whatever, you'll also be able to use fancy prompts.

  • hterm is a full color terminal, it can do the sixel stuff you might see with iterm/kitty/alacrity/wezterm. You can view images directly in hterm, and it works surprisingly well.

  • Personally, I setup a new folder in my chromebook under /mnt/chromeos/MyFiles/workspace using the ChromeOS files app. Then symlink it in my home directory. ln -s /mnt/chromeos/MyFiles/workspace $HOME Then i put stuff that I might want to keep in case my arch terminal dies a gruesome death, git repos and the like.

    • I use git grab instead of git clone and my working directory is workspace. GRAB_HOME=$HOME/workspace/ git-grab maintains domain/user/repo directory structure, and I don't have to worry about collisions. The performance across the /mnt mount is kinda slow, but I don't have to recreate everything if I loose my arch install.
    • I use chezmoi with 1password to locally backup all my configs to the workspace directory, AND github. Then I can always have my environment in the event of an arch container crash, or I want to start over.
  • mDNS is never covered in these tutorials, and I absolutely HATE that it's not default for personal use. If you want to use your local lan mdns (hostname.local), you'll have to fiddle with systemd-resolve a bunch. After messing this up endlessly, I ended up just using my local home pi.hole installation, and don't even bother trying to get mdns enabled and stay enabled. pi.hole handles all my local resolution. Your requirements may vary, however I found this to be the easiest solution. I don't want to over manage my arch /etc install because shit breaks, I don't want to remember to fix it later.

  • I've started an ansible setup that tries to do everything post arch/penguin install. It's not working great yet, but when I feel it's stablish I'll post my work.

I hope some of this was useful for folks trying to run arch on their chromebooks. I like debian, however bullseye requires custom repos to make everything I use work. Arch/yay makes nearly all that transparent. Bullseye's default fish shell is 3.1, which is horrible, 3.4 or go home! (= So I'm really happy using Arch for my local environment.

No dice :\ should I just switch to beta channel?

image

image

Edit: no luck on beta either

@bdmorin
Copy link

bdmorin commented Jul 18, 2022

What steps did you perform?
Have you removed your original arch install, and started over?

We should probably stop polluting baldrailers gist.

@ngencokamin
Copy link

ngencokamin commented Jul 19, 2022

What steps did you perform? Have you removed your original arch install, and started over?

We should probably stop polluting baldrailers gist.

Ok so I'm now on beta 104.0.5112.36. Wiped my linux setup and re-enabled it. Here are the steps I ran:

  1. vmc start termina
  2. lxc launch images:archlinux/current arch
  3. lxc stop penguin
  4. lxc list # penguin is stopped, arch is running
  5. lxc exec arch bash
  6. groupmod -n nix alarm
  7. usermod -d /home/nix -l nix -m -c nix alarm
  8. passwd nix
  9. visudo # uncommented %wheel ALL=(ALL:ALL) ALL
  10. usermod -aG wheel nix
  11. ip -4 a show dev eth0 # there was output, following steps skipped
  12. exit
  13. lxc exec arch su - nix
  14. sudo pacman -Syu base-devel git curl make vim wl-clipboard zsh
  15. yay -S cros-container-guest-tools-git
  16. cp -r /etc/skel/.config/pulse ~/.config/pulse
  17. yay -S xorg-xwayland wayland mousepad
  18. exit
  19. lxc console arch # login with user
  20. systemctl enable --now --user sommelier{,-x}@{0,1}.service
  21. mousepad # window opened as expected
  22. vsh into termina again
  23. lxc list # arch and penguin show up
  24. lxc stop arch
  25. lxc stop penguin # already stopped but I did it to be safe
  26. lxc rename penguin google
  27. lxc rename arch penguin
  28. lxc list # shows penguin and google as expected
  29. exit
  30. vmc list # only shows termina
  31. vmc stop termina

Result (same before and after reboot):
Screen recording 2022-07-19

Edit:
Still works perfectly consolling in through crosh, it's just broken in the terminal app
image

Second edit: ok so now it almost works. It'll open in terminal if I console in through crosh and then open a new terminal tab, but starting through the terminal app itself results in errors until I do it in crosh

@bdmorin
Copy link

bdmorin commented Jul 19, 2022

When you started default penguin/bullseye was your username nix?

@ngencokamin
Copy link

yeah it was

@bdmorin
Copy link

bdmorin commented Jul 20, 2022

it looks like you did everything correctly. I'm also on a Duet5, and it's working great here. I'm sorry, I wish I had more advice for you.

@oukemi
Copy link

oukemi commented Oct 31, 2022

Same issue here

@luceerose
Copy link

luceerose commented Apr 11, 2024

Everything seemed to work, up until I tried to run mousepad & got a gtk error.
I'm on Dev ChromeOS.

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