22 Jul 2017, 21:28

Arch Linux on a Chromebook Asus C301SA

I’ve got an Asus C301S at work, it’s a Chromebook with Chromeos.

I like those little laptops, for the price it’s actually a very good little machine.
ChromeOS is responding very well, ssh and Chrome are working too.
But I often need more, like X11 forwarding or offline coding …

You will see the C301SA is marked as a C300SA internally.

Here are the steps to install Arch Linux on it, do it at your own risk, you can brick your computer, you will need an external USB keyboard.

  • Activate the recovery mode, by using ESC + F3 (refresh) and the power key

  • Activate the developer mode with ctrl + d, confirm you want to continue, it will take a long time before it’s finished preparing the developer mode.

  • Shutdown and remove the write protection screw
    It’s actually written as not mandatory but also “could be dangerous”, didn’t take the chance.
    Gently dismount the keyboard (by removing the back screws), warning the screws are different, so remember their positions.
    Locate the write protection screw, mine was covered with a black tape, (on the left close to the USB port) and remove it
    c301 screw

  • Reboot into ChromeOS by pressing ctrl + d

  • Patch the firmware [Ctrl+Alt+T] to get a ChromeOS terminal
    type or copy paste cd; curl -LO https://mrchromebox.tech/firmware-util.sh && sudo bash firmware-util.sh
    Choose 1 to enable legacy boot then n to boot from internal then shutdown the computer.

  • Create a bootable USB key for Arch Linux
    sudo dd if=/home/akh/Downloads/archlinux-2017.06.01-x86_64.iso of=/dev/sde bs=512

  • Boot on Arch by pressing ctrl + l then ctrl + u, sometimes it fails

  • The actual Arch kernel does not see the keyboard … you’ll need an external USB keyboard.

  • Perform a normal installation of Arch (I’ve totally removed ChromeOS partitions) and even performed an MBR install (instead of GPT) with only 2 partitions.
    The internal SSD disk is /dev/mmcblk0

  • Install grub
    grub-install --target=i386-pc /dev/mmcblk0
    grub-mkconfig -o /boot/grub/grub.cfg

  • Install yaourt

git clone https://aur.archlinux.org/package-query.git
cd package-query
makepkg -si
cd ..
git clone https://aur.archlinux.org/yaourt.git
cd yaourt
makepkg -si
cd ..
  • Install the galliumos patched kernel, you can go to bed coz it will take a long time to compile
    yaourt --tmp /var/tmp -S aur/linux-galliumos-braswell

The keyboard should work now.
Also install or grab the config file from aur/galliumos-braswell-config for audio support.

If it won’t boot don’t worry you can still boot using the Arch USB key, then remount your system:

mount /dev/mmcblk0p1 /mnt
arch-chroot /mnt

Touch pad config:

Section "InputClass"
    Identifier "Elan Touchpad"
    Driver "libinput"
    MatchIsTouchpad "on"
    Option "Tapping" "on"
    Option "NaturalScrolling" "true"  
    Option "ClickMethod" "clickfinger"
EndSection

Congratulations you have a fully working computer.

EDIT: Arch kernel 4.12 is fully working without the need to use aur/linux-galliumos-braswell, but 4.13 breaks this support, so keep 4.12 for now.

25 Feb 2017, 09:57

From OSX to Linux

I’ve been a long time UNIX user, ditched Microsoft back in the 90s for FreeBSD, Solaris and Linux on the desktop, but when Apple released MacOS X, I’ve used it as a workstation.

For the last years I’ve used Linux desktops but not on my main computer, today here I am switching back to Linux.

This post is not about the reasons I’m switching, they are simple.
My typical work day is mostly about parsing giant files, running VM and Dockers, coding in Go and not about developing for iOS anymore.

I’m using Arch Linux and KDE/Plasma but many items from this list apply to any Linux distributions.

Put your user in the following groups uucp audio input lp.

Bonjour, mDNS and .local

I was used to query the .local domain to ssh my laptop back.

  • Install nss-mdns, add mdns_minimal [NOTFOUND=return] before resolve in /etc/nsswith.conf
  • Install avahi and start avahi-daemon.service.
  • To make your ssh server visible to others, cp /usr/share/doc/avahi/ssh.service /etc/avahi/services/

Try pinging a Mac host on your LAN with ping hostname.local

Google drive

Install kio-gdrive then start Dolphin and go to Network then Google drive and set up your account or by running the shell command: kioclient5 exec gdrive:/.

Emojis in color 💻

Install noto-fonts-emoji and edit .config/fontconfig/fonts.conf as follow

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <alias>
  <family>sans-serif</family>
  <prefer>
   <family>NotoSans</family>
   <family>NotoColorEmoji</family>
   <family>NotoEmoji</family>
  </prefer>
 </alias>
 <alias>
  <family>serif</family>
  <prefer>
   <family>NotoSerif</family>
   <family>NotoColorEmoji</family>
   <family>NotoEmoji</family>
  </prefer>
 </alias>
 <dir>~/.fonts</dir>
</fontconfig>

This setup is working in most applications but can sometimes display weird results in terminals.

2 Factor USB key U2F

I have a cheap Fido U2F key but Chrome was unable to see it. Edit /etc/udev/rules.d/50-fido-u2f.rules

# this udev file should be used with udev 188 and newer
ACTION!="add|change", GOTO="u2f_end"
# Key-ID FIDO U2F
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="096e", ATTRS{idProduct}=="0850|0880", TAG+="uaccess"
LABEL="u2f_end"

Win key aka ⌘ cmd key

On a PC keyboard the left alt and the windows key are inverted in opposite to a Mac where alt is left of ⌘.
To avoid being lost when I switch back to my Macbook I’ve physically inverted the keys and change the behavior in Plasma in “Hardware | Input Devices”.

⌘

Compose key

To type special or accentuated characters you’ll use the “Compose” key.
You can set the compose key in Plasma in “Hardware | Input Devices”.

Compose

I’m using the right alt, which is the right ⌘ cmd on a Mac (and also a compose key).

For a complete list of compose shortcuts see the bottom of this page

Spotlight

The tool/window equivalent to running Spotlight is called “Plasma Search”, you can configure what it can search for.
The mapping for this key in “System Settings | Global Shortcuts | Run Command”.

System Settings | Global Shortcuts | Run Command

It’s also capable of indexing files content, in KDE/Plasma this service is provided by baloo, ignored directories can be set by calling “Configure File Search”.

You can empty your baloo index by stopping by killing all your baloo processes and rm -r .local/share/baloo then restart for indexation balooctl start

Exposé and active corners

It’s called “Screen Edges” and it’s under “Windows behavior”.

edges

Alternative for Dash

Dash was part of my workflow to get documentation, an alternative solution is to install zeal it’s using the exact same docsets as Dash.
Also see DevDocs

Samba share

Install samba, tweak /etc/samba/smb.conf and enable nmbd.service.
I personally prefer a different password than my shell account: smpasswd -a yourusername.

Taking Screenshot

Install spectacle and use the Ptr Sc key (this shortcut can be setup in Plasma).

Webcam, Hangout and Skype

I have a Logitech C920, it worked without any configuration, inside Chrome so Hangout and even with Skype for Linux.

Mounting a macOS disk

That one is weird …
mount -o ro,sizelimit=498876809216 /dev/sda2 /mnt/OSX

If your existing partition was big, you need to find this magic number by following this guide

Steam

Steam needs x86 32 bits libraries, on Arch you have to enable multilib by editing /etc/pacman.conf

[multilib]
Include = /etc/pacman.d/mirrorlist

Then install the steam package.

Virtualbox / QEMU

I prefer QEMU/KVM & libvirt-manager, when available, over Virtualbox, it’s more integrated into the system, and it’s capable of emulating other cpu architectures like aarch64…

One more huge advantage for QEMU it’s also capable of booting a virtual macOS X

Printing

Install cups and print-manager then enable org.cups.cupsd.service, note that you need the .local resolution above for network printer resolution.
Also install hplib for HP printers.

Share your session aka remote desktop

Install x11vnc and run x11vnc -usepw -once -noxdamage -ncache 10 from your X session.

Note that this vnc server is not compatible with macOS X embedded vnc viewer (vnc://hostname), here is one for Chrome RealVNC

Remember vnc protocol is not secure and you must use an SSH tunnel over it.

Magic Trackpad

I’m using a magic trackpad 2, after enabling bluetooth and pairing the trackpad, one, two & three fingers touches, vertical & horizontal scroll worked via hid_magicmouse module.

For gestures you need libinput-gestures, here is an example /etc/libinput-gestures.conf file:

gesture swipe left 3 xdotool key control+Right

gesture swipe right 3 xdotool key control+Left

gesture swipe up 3 xdotool key control+F9

The bad

  • Not as nice, not as well integrated, for example supporting HiDPI with only one retina screen is weird with Xorg.
  • Key shorcuts are a giant mess under Linux, every applications have their own and it can’t be configured centrally.
  • I’m still missing some applications like Sketch, but most of all Tower when dealing with a git merge issue.

The good

After 8 years of absence on Linux as main desktop, things have changed, it’s not free from bugs but way more simpler to use now than before, and way more configurable than macOS X.

It won’t work for everybody but I’m really happy with this setup, the gain compared to a Mac is big, first the machine itself a 4Ghz i7 with 64G of ram does not even exist at Apple (Hackintosh is not a good solution), ZFS, native Docker over ZFS, better OpenGL (faster fps in games), well maintained packages over Brew/Macports, well maintained drivers, my work is easier …

Notes