Lubuntu 14.10 on the Acer C720 Chromebook
For six long months, I used a Crouton chroot (running Debian Sid) alongside my Acer C720 Chromebook’s native Chrome OS as my primary working environment: the Secure Shell extension provided direct, non-SSH terminal access to the chroot, where I did all of my real work, while Chrome browser provided a means to access my e-mail and the Internet.
However, I wasn’t able to reliably run graphical X11 applications in Chrome OS when the need arose occasionally (e.g. to display a plot in R or Octave) and, by the time a workaround for this problem was identified, my growing dissatisfaction with Chrome OS’ limitations and my concerns over personal data and activities being collected, stored, and processed in Google’s cloud prompted me to completely replace Chrome OS with a standard Linux installation.
I tried Elementary OS Freya, Xubuntu 14.10, and Lubuntu 14.10 and finally settled on the latter because it had the smallest operational overhead (in terms of power, CPU, and memory consumption) when my laptop was idle, according to Intel’s PowerTOP tool.
Now that this configuration has stabilized, having lasted an entire week
of continuous use (no shutdown, only suspend and resume) without any
problems, I decided to write this article and share it with the world:
documented below is how I replaced Chrome OS with Lubuntu 14.10 on my
Acer C720 Chromebook. May this knowledge liberate you from Google’s
clutchescloud as well. :-)
Setup
Install John Lewis’ custom Chromebook firmware as described in the_unconventional’s guide. Doing this eliminates the annoying time-delayed “scary boot screen”, boots directly into SeaBIOS, fixes issues with Linux kernel modules.
Write the 64-bit Lubuntu 14.10 installation image to a USB stick:
sudo dd if=lubuntu-14.10-desktop-amd64.iso of=/dev/sdXYZ
Plug in your USB stick and run
dmesg | tail
to find the XYZ value.Boot your Acer C720 Chromebook from the USB stick prepared above.
Choose “Try Lubuntu without installing” at the USB stick’s boot menu.
Press Control+Alt+T to open a terminal and then type in the following:
xbacklight = 15 # temporarily reduce laptop's display brightness sudo swapoff -a # disable swap to avoid security error later on
Double-click the “Install Lubuntu 14.10” icon on the desktop to start the installation process, in which:
- Choose “Erase disk and install Lubuntu”.
- Choose “Encrypt the new Lubuntu installation for security”. Make
sure to turn off swap by running
sudo swapoff -a
before entering your encryption passphrase to avoid a security error that aborts the installation. - Choose “Use LVM with the new Lubuntu installation”.
- Choose “Continue Testing” instead of rebooting.
Press Control+Alt+T to open a terminal and then type in the following:
sudo -s swapoff -a lvremove /dev/lubuntu-vg/swap_1 lvextend --extents +100%FREE /dev/lubuntu-vg/root e2fsck -f /dev/lubuntu-vg/root resize2fs /dev/lubuntu-vg/root
This will absorb the encrypted swap volume into your root volume, thereby giving you an extra 4 GiB (or 2 GiB depending on your Chromebook model) of disk space to work with.
Reboot the computer when you are ready to start using Lubuntu 14.10.
Disable encrypted swap, which the root volume absorbed earlier:
sudo sed -i 's,^/dev/mapper/lubuntu--vg-swap_1,#&,' /etc/fstab
Enable TRIM support on the root volume since it’s on a solid state disk:
sudo sed -i '/vg-root/s/errors=remount-ro/&,noatime,discard/' /etc/fstab
Fixes
After successful installation, apply the following fixes.
Touchpad
Enable touchpad by upgrading your Linux kernel to version 3.17 or newer,
which has the touchpad driver built-in. To do this, download the upgrade
packages
(namely the linux-headers*amd64.deb
and linux-generic*amd64.deb
files)
and install them using the sudo dpkg -i
command.
Kernel
Prevent system freezes that randomly occur under Linux kernel 3.17+:
echo 'options i915 semaphores=0' | sudo tee -a /etc/modprobe.d/i915.conf
I arrived at the above solution by starting with John Lewis’ suggested
workaround and
experimentally removing redundant overrides (according to modinfo i915 |
grep parm
output) that re-specified default values.
Power
Prevent instant shutdown when power key is (accidentally) pressed:
echo 'HandlePowerKey=ignore' | sudo tee -a /etc/systemd/logind.conf
Wi-Fi
Enable Wi-Fi power savings and improve connection stability:
echo 'options ath9k ps_enable=1 use_chanctx=1 btcoex_enable=1 bt_ant_diversity=1' | sudo tee -a /etc/modprobe.d/ath9k.conf
Sound
Specify the sound card that alsamixer(1) should use by default:
echo 'options snd_hda_intel index=1' | sudo tee -a /etc/modprobe.d/alsa.conf
Keyboard
Install the Chromebook keyboard layout provided by Crouton:
wget https://raw.githubusercontent.com/dnschneid/crouton/master/targets/keyboard
sudo env DISTRO=debian bash ./keyboard
Apply the Chromebook keyboard layout from within an X11 session:
setxkbmap -model chromebook
Sleep
Make suspend and resume work correcly when lid is closed and opened:
/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# prevent ehci-pci errors that occur after resume from suspend:
# [ 386.093443] ehci-pci 0000:00:1d.0: port 2 resume error -19
# [ 386.093699] ehci-pci 0000:00:1d.0: port 1 resume error -19
echo -n 0000:00:1d.0 > /sys/bus/pci/drivers/ehci-pci/unbind
/etc/pm/sleep.d/20_acer_c720_chromebook
exit 0
/etc/pm/sleep.d/20_acer_c720_chromebook
#!/bin/sh
# the following tweaks were suggested by powertop https://01.org/powertop
# turn off bluetooth, which causes OS hangs
rfkill block bluetooth
# Wireless Power Saving for interface wlan0
iwconfig wlan0 power on
# NMI watchdog should be turned off
echo 0 > /proc/sys/kernel/nmi_watchdog
# VM writeback timeout
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
# Enable audio codec power management
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
# Enable SATA link power Management for *
for policy in /sys/class/scsi_host/*/link_power_management_policy
do echo min_power > $policy
done
# Runtime PM for PCI Device *
for control in /sys/bus/pci/devices/*/power/control
do echo auto > $control
done
# Runtime PM for PCI Device Intel Corporation 8 Series USB xHCI HC
echo auto > /sys/bus/pci/devices/0000:00:14.0/power/control
# Runtime PM for PCI Device Intel Corporation 8 Series USB EHCI #1
echo auto > /sys/bus/pci/devices/0000:00:1d.0/power/control
Extras
After successful installation, you can set up these extras.
Install skippy-xd to emulate Chrome OS’ window list (F5) key:
sudo add-apt-repository ppa:landronimirc/skippy-xd-daily sudo apt-get update && sudo apt-get install skippy-xd
Fix zsh-history-substring-search reverse video highlighting in tmux:
wget https://mirrors.kernel.org/ubuntu/pool/main/n/ncurses/ncurses-base_5.9+20140118-1ubuntu1_all.deb sudo dpkg -i ncurses-base_5.9+20140118-1ubuntu1_all.deb sudo apt-mark hold ncurses-base
Get low-battery notifications from LXDE’s battery monitor:
- Right-click on the panel (task bar)
- Choose “Add / Remove Panel Items”
- Click the “Add” button
- Choose “Battery Monitor” from the list
- Click the “Edit” button
Set the “Alarm command” field to:
notify-send -u critical -i battery-empty "Your battery is low" "Plug in the charger!" || xmessage Battery low
Note that you must install
sudo apt-get install libnotify-bin
in order to receive fancy notifications from the command above.Set the “Alarm time (minutes left)” field to: 30
Automatic HDMI
The following scripts configure external displays automatically:
- plugin in a HDMI cable and the external display will be used
- unplug the HDMI cable and the internal display will be used
Simply run acer-c720-reactor&
after starting LXDE to use them.
~/bin/acer-c720-display
#!/bin/sh
# Uses external display if connected; or internal display otherwise.
if grep -q '^connected' /sys/class/drm/card0-HDMI-A-1/status
then xrandr --output HDMI1 --auto --dpi 96 --output eDP1 --off
else xrandr --auto
fi
~/bin/acer-c720-reactor
#!/bin/sh
# Reacts to hardware events and (re)configures the system accordingly.
trap "kill -- -$$" EXIT # terminate all background processes on exit
trap exit INT TERM # ensure the above trap is triggered on interrupt
dmesg='dmesg --facility auth'
depth=$($dmesg | awk '
/ systemd-logind.+: New session c.+ of user .+/ { depth=NR }
END { print depth-1 }
')
$dmesg --follow | {
# discard old events
i=1
while [ $i -le $depth ]; do
read _discard
i=$(( i + 1 ))
done
# process new events
while read event; do
case "$event" in
# lock screen was unlocked after initial login
# or after the laptop was resumed from suspend
(*' systemd-logind'*': New session c'*'of user '*\
|*' systemd-logind'*': Lid opened.'\
|*' systemd-logind'*': Operation finished.')
acer-c720-docking
;;
esac
done
} &
stdbuf -oL udevadm monitor --udev | while read event; do
case "$event" in
# HDMI cable was either plugged in or unplugged
(*' change '*'/devices/pci0000:00/0000:00:02.0/drm/card0 (drm)')
acer-c720-display
;;
esac
done &
wait