Arch Linux on Toshiba CB30-102 (Chromebook)

Posted on Sun 21 June 2015 in tech

The Beginners guide in the wiki is straightforward. Here are just some additional notes on setting up Arch Linux on my chromebook.

Planned setup

My device has a 16GB ssd. I'm planning to wipe ChromeOS and partition the disk into two partitions: 2GB /boot (ext4) and a 14GB encrypted partition (dm-crypt + LUKS). A 2GB swapfile will be created inside the encrypted partition.

Preparations

Check the Arch wiki for chrome device specific preparations. My device has an alternative boot loader so I just need to press CTR+L at the splash screen to boot from usb-stick or (later) GRUB.

Installation steps

Follow the beginners guide. After creating the two partitions and making the /boot partition bootable, proceed to setup the encrypted partions.

# assuming /dev/sda2 is the 14GB partition that will be encrypted
cryptsetup -v --cipher twofish-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda2
# now open the LUKS partition
cryptsetup open --type luks /dev/sda2 root
# the decrypted partition is now available at /dev/mapper/root
mkfs.ext4 /dev/mapper/root
mount /dev/mapper/root /mnt
# proceed with installation according to the beginners guide

Check Device_encryption for encryptions settings etc.

Before the first reboot

Assuming GRUB is used as a boot loader we'll need to make sure that it finds the root device and that the initramfs contains everything necessary to decrypt the partition.

Edit /etc/default/grub and configure cryptdevice in GRUB_CMDLINE_LINUX_DEFAULT:

GRUB_CMDLINE_LINUX_DEFAULT="quiet cryptdevice=UUID=6364123f-3052-4745-bb79-ee60416b4309:root:allow-discards"

The UUID should in my case point to /dev/sda2. :root: will make the decrypted partition available at /dev/mapper/root and allow-discards is needed to make the discard mount-option work through disk-encryption. Note: allow-discards may be a security risk. I'm using it anyway. After configuring update the grub configuration with grub-mkconfig -o /boot/grub/grub.cfg

At last make sure to add encrypt to /etc/mkinitcpio.conf before the filesystems hook:

HOOKS="base udev autodetect modconf block encrypt filesystems keyboard fsck"

and update the initramfs:

mkinitcpio -k 4.0.5-1-ARCH  -g /boot/initramfs-linux.img

(the -k 4.0.5-1-ARCH argument was only needed in my case, because the installed kernel was newer than the one running on the usb-stick. Try it without -k and if it doesn't work, check /lib/modules/ for the correct kernel-version) You're now ready to exit chroot and reboot (do not forget to install all necessary modules and firmware for the network to work... check the wiki!).

Configuration

After the first reboot we should now have a working arch installation. I set up x11, gdm and cinnamon following the wiki instructions. GDM can be enabled at boot with systemctl enable gdm.service

ChromeOS Buttons

I used sxhkd to make the ChromeOS Buttons work.

~/.config/sxhkd/sxhkdrc

# Web browser Back/Forward shortcuts
[email protected],@F2}
  xte 'keydown Alt_L' 'key {Left,Right}' 'keyup Alt_L'

# Web browser Refresh shortcut
@F3
  xte 'keydown Control_L' 'key r' 'keyup Control_L'

# Awesome WM maximize current window
# Adjust as necessary for different window managers
[email protected]
#  xte 'keydown Super_L' 'key m' 'keyup Super_L'

# Awesome WM move one desktop right
@F5
  xte 'keydown Super_L' 'key Right' 'keyup Super_L'

{F6,F7}
  xbacklight -{dec,inc} 10

F8
  amixer set Master toggle

{F9,F10}
  amixer set Master 5%{-,+} unmute

Then add /usr/bin/sxhkd to the autostart of your desktop env. For cinnamon I used gnome-session-properties (installable from AUR). You'll need alsa-utils, xorg-backlight, xautomation for the config above to work. The config above is a modified version from the wiki (% for F9, F10). Check Chrome_OS_devices#Sxhkd_configuration.

Swapfile

I use a swapfile inside the encrypted partition. Create a 2GB swapfile with:

dd if=/dev/zero of=/swapfile bs=1M count=2000
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

and enable it in /etc/fstab:

cat >> /etc/fstab
/swapfile   swap    swap    defaults    0 0

CTRL+D

Hibernation

For hibernate to work, the resume= and resume_offset= (only when a swapfile is used) kernel params must be set and the resume hook in initramfs must be enabled.

add

resume=/dev/mapper/root resume_offset=OFFSET_NO

to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub and update the grub config. OFFSET_NO is the first row of physical_offset in filefrag -v /swapfile.

Then add resume to HOOKS in /etc/mkinitcpio.conf after the encrypt hook (otherwise it would try to resume before decrypting the partition) and update initramfs with mkinitcpio -p linux

Hibernation should now work with systemctl hibernate.

AUR packages

Checkout yaourt. Quite useful for installing AUR packages.