Installing Ubuntu on an Acer C720P chromebook

There is a lot of information available regarding installation of single-boot Ubuntu on an Acer C720P but here I’m posting what works for me in Jan 2017.

I am not going to explain how to prepare the Chromebook for  installation of Ubuntu, I’m just posting notes on certain configurations that work for me:

Basic hardware functionality

  1. Elantech touchpad: the newest kernels recognize the touchpad perfectly (>= 4.8). Previously, only the GalliumOS kernel made the touchpad usable for me.
    1. Download the amd64 kernel from here and install: http://kernel.ubuntu.com/~kernel-ppa/mainline/
    2. For example, for 4.9, you need to download   linux-headers-4.9.0-040900_4.9.0-040900.201612111631_all.deb
      linux-headers-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb
      linux-image-4.9.0-040900-generic_4.9.0-040900.201612111631_amd64.deb
    3. Install using dpkg -i linux-*.deb
  2. Touchscreen: works with any kernel.
  3. Microphone: does not work
  4. Speakers: work with any kernel

Enabling keyboard functions and keys

  1. Install programs to control brightness and map keys:
    1. apt-get install xbindkeys xdotool xbacklight
    2. create ~/.xbindkeysrc with these contents to map keys (customize to your needs)
      "xdotool keyup F1; xdotool key alt+Left"
      F1
      "xdotool keyup F2; xdotool key alt+Right"
      F2
      "xdotool keyup F3; xdotool key ctrl+r"
      F3
      "xdotool keyup F4; xdotool key F11"
      F4
      "xdotool keyup F5; gnome-screenshot -f $HOME/Pictures/Screenshot_$(date +%F_%T).png"
      F5
      "xdotool keyup F6; xbacklight -dec 3"
      F6
      "xdotool keyup F7; xbacklight -inc 3"
      F7
      "xdotool keyup F8; pactl set-sink-mute alsa_output.pci-0000_00_1b.0.analog-stereo toggle"
      F8
      #"xdotool keyup F9; pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo -10%"
      "xdotool keyup F9; amixer -D pulse sset Master 5%-"
      F9
      #"xdotool keyup F10; pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo +10%"
      "xdotool keyup F10; amixer -D pulse sset Master 5%+"
      F10
      
      "xdotool keyup control+shift+Down Arrow; xdotool key Page_Down; xdotool keydown shift"
      control+shift+Down Arrow
      
      "xdotool keyup control+shift+Up Arrow; xdotool key Page_Up"
      control+shift+Up Arrow
      
      "xdotool keyup control+shift+Left Arrow; xdotool key Home"
      control+shift+Left Arrow
      
      "xdotool keyup control+shift+Right Arrow; xdotool key End"
      control+shift+Right Arrow
      
      "xdotool keyup XF86PowerOff; xdotool key Delete"
      XF86PowerOff
    3. Notice that I disable the power button and map it to Del. To shutdown the computer, I use the shutdown button in Gnome panel.

Using a lightweight Desktop (Openbox):

  1. Even Gnome 2 uses too much memory for my likings. Openbox uses < 350 MB idle and Gnome ~ 600 MB idle. 250 MB in a 2 GB system is a lot for me. With Openbox I get a light Gnome-like desktop.
  1. Install Openbox:
    sudo apt-get install openbox
  2. Install gnome-session-fallback:
    1. sudo apt-get install gnome-session-fallback
    2. I use some Gnome applications.
    3. Also, Chromebooks don’t have a “Super” key, which is required in Openbox to add buttons to gnome-panel. In Gnome, you can add buttons by clicking the right mouse button and Alt only. So I login to Gnome, configure gnome-panel, logout and login to Openbox.
    4. Alternatively, plug in a keyboard and click Super+Alt and the right mouse key on the Gnome panel in Openbox to add items). But this means you always depend on an external keyboard to configure Gnome panel in Openbox.
  3. Install volti to control the sound volume. Gnome’s won’t work:
    sudo apt-get install volti
  4. Configure gnome-panel. The native Gnome indicator applet won’t work in Openbox, which means no network manager, no clock, etc.To configure Gnome panel in Openbox without plugging an external keyboard: login to Gnome (metacity) and configure the gnome-panel with the mouse, adding:
    1. A custom application launcher that will be the shutdown button. Select a shutdown icon to be displayed.
      1. Create this script and configure the shutdown button in Gnome panel to call this script:
        #!/bin/bash
        gmessage "Are you sure you want to shut down your computer?" -center -title "Take action" -font "Sans bold 10" -default "Cancel" -buttons "_Cancel":1,"_Log out":2,"_Reboot":3,"_Shut down":4,"_Suspend":5 >/dev/null
        case $? in
        1)
        echo "Exit";;
        2)
        killall openbox;;
        3)
        shutdown -r now;;
        4)
        shutdown -h now;;
        5)
        pm-suspend
        esac
      2. Remove the bottom panel bar for more screen real estate.
      3. Add a window selector to the top panel bar.
      4. Add desired application shortcuts.
      5. Add a clock.
    2. Logout from Gnome and login to Openbox.
    3. In a terminal, create .config/openbox/autostart.sh
    4. Install gxmessage to show the shutdown dialog when you press the shutdown button:
      apt-get install gxmessage
    5. Configure sudoers to allow any user to shutdown:
      1. sudo visudo
      2. Insert this at the end of the file:
        %users ALL=NOPASSWD: /usr/bin/shutdown
    6. I’m still working on how to make pm-suspend work without sudo.
  5. Configure start up applications: Edit .config/openbox/autostart.sh to start several applications upon login:
    gnome-panel & # openbox has no panels, you need to start one
    volti & # sound control
    nm-applet & # for network management
    xbindkeys # for key mapping to the weird Chromebook keyboard
    xscreensaver &
    synclient ClickFinger3=2 # to enable right click on the touchpad (tap the touchpad with 2 fingers simultaneously)
    synclient TapButton3=2 # to enable pasting with the touchpad (tap the touchpad with 3 fingers simultaneously)
    earlyoom # aggressively kill programs when there's no RAM available, see below
    
  6. Enable a screensaver:
    1. gnome-screensaver doesn’t work.
    2. Install xscreensaver instead and remove gnome-screensaver:
      sudo apt-get remove gnome-screensaver
      sudo apt-get install xscreensaver
    3. run xscreensaver-demo to configure the screensaver.
  7. Backup .config/ so anytime you have to reinstall you don’t need to reconfigure Gnome panel and start up applications.

Other configurations

  1. SSD settings: configure /etc/fstab with configurations that are more gentle on your SSD: Add discard,noatime,errors=remount-ro to /dev/sda1:
    /dev/sda1   /               ext4    discard,noatime,errors=remount-ro 0       1
  2. Swap: I used to disable swap completely and let programs crash if they used too much memory. However, there seems to be a bug in 16.04 and sometimes kswapd0 runs at 100% CPU for several minutes when there’s not swap. So now I:
    1. create a very small swap (10 MB)
    2. decrease swappiness (sudo sysctl vm.swappiness=10)
    3. use earlyoom (https://github.com/rfjakob/earlyoom) to aggressively kill programs. I add it to .config/openbox/autostart
Advertisements

Installing Ubuntu 16.04 on an Acer C720p chromebook

I booted a Ubuntu LiveUSB on my Acer C720p and I got this error:

Missing parameter in configuration file. Keyword: path
gfxboot.c32: not a COM32R image
boot :

Pressing tab shows boot options: live live-install

But typing live and pressing Enter results in another error:

Not enough memory to load specified image
boot:

The solution is to type live mem=1900m or whatever amount of memory you have.

Not enough memory to load specified image
boot: live mem=1900m

Then Ubuntu LiveUSB will boot as normal.

Creating a ChromeOS recovery drive using Ubuntu

The way to reinstall ChromeOS using Linux is to download a script from Google and run it.

Running sudo linux_recovery.sh failed with an error about the config file:

ERROR: The config file isn't valid.

linux_recovery.sh downloads /tmp/tmp.crosrec/config.txt which contains the URL of the image to download.

The entry for my Chromebook in /tmp/tmp.crosrec/config.txt is:

name=Acer C720 Chromebook
version=8172.62.0
desc=Acer C720 Chromebook
channel=stable-channel
hwidmatch=^PEPPY .*
hwid=
md5=a04e467b5a7727aee51c0079f4bd33cb
sha1=8cecc85e044b363f0b96e096619e24f8dfd96525
zipfilesize=585977912
file=chromeos_8172.62.0_peppy_recovery_stable-channel_mp-v2.bin
filesize=1535082496
url=https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_8172.62.0_peppy_recovery_stable-channel_mp-v2.bin.zip
/tmp/tmp.crosrec/config.txt

I downloaded the image and used dd to create the USB drive:

wget https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_8172.62.0_peppy_recovery_stable-channel_mp-v2.bin.zip
unzip chromeos_8172.62.0_peppy_recovery_stable-channel_mp-v2.bin.zip
sudo dd bs=4194304 of=/dev/sdb if=chromeos_8172.62.0_peppy_recovery_stable-channel_mp-v2.bin conv=sync

Installing Ubuntu on a Mac Pro 6,1 (late 2013) and 5,1 (mid 2010)

Thanks to many resources online I was able to install full single-boot Ubuntu on a Mac Pro that I was given at work. Normally I would not buy an unnecessarily expensive computer like this, but since it was free and it had 64 GB of RAM, I decided to keep it.

Initially, I used a third party LiveUSB creator, but later I realized that creating a regular LiveUSB works just fine. All I needed to do was boot with “nomodeset” as a boot parameter and edit the EFI bootloader.

The easiest and most functional procedure was to:

  1. Create a LiveUSB as usual, for example using Startup Disk Creator.
  2. Boot the LiveUSB (boot with option nomodeset) and install Ubuntu on a hard drive.
  3. In the Live USB, use efibootmgr to allow EFI to boot Ubuntu.
  4. Boot Ubuntu with option nomodeset.

Procedure:

  1. Create a LiveUSB Ubuntu as usual. I used Startup Disk Creator in Ubuntu.
  2. Boot Mac OS X and hold Alt while booting. You should see two icons, one saying “Macintosh HD” and another “EFI”.
  3. [Only 6,1] Press “e” and edit the boot command, adding “nomodeset”. This was only necessary on the 6,1. 5,1 booted fine without “nomodeset”.
    setparams 'Install Ubuntu Server'
        set gfxpayload=keep
        linux /install/vmlinuz file=/cdrom/preseed/ubuntu-server.seed nomodeset quiet --
        initrd /install/initrd.gz
  4. [Only 6,1] Press F10 to boot the Ubuntu LiveUSB. Skip this step if installing on 5,1.
  5. Install Ubuntu. I installed it to a USB 3.0 external hard drive because I wanted to preserve Mac OS X in case somebody else inherited this computer later. Install the bootloader on the desired device.
  6. Still in Ubuntu LiveUSB, modify EFI to boot Ubuntu. Follow the steps in this tutorial to get Ubuntu to boot in EFI mode (no need for refind). I did try to use rEFInd but while Ubuntu did boot, it couldn’t use the monitor, even setting nomodeset. Here are the commands I used:
    sudo apt-get update

    Install efibootmgr:

     sudo apt-get install efibootmgr

    Check your EFI to see what Ubuntu is called:

    sudo efibootmgr

    Set Ubuntu to boot first:

    sudo efibootmgr -o 0,80
  7. [Only 6,1] Now it should be possible to reboot and Ubuntu should present the boot screen where different kernels can be chosen. If you see that screen, add “nomodeset” to the boot parameters by pressing “e” in the boot screen. Add “nomodeset” to the end of line starting with “linux”, similarly to step 3.
  8. [Alternative to 7.] In case you don’t see the boot screen, boot the LiveUSB again. Mount the freshly installed / (replace sdc3 by the partition that contains /)
    mkdir fix
    sudo mount /dev/sdc3 fix
    cp fix/boot/grub/grub.cfg fix/boot/grub/grub.cfg.old
    sudo nano fix/boot/grub/grub.cfg

    This file shouldn’t be edited manually, but for the first boot it’s OK. Add nomodeset to the first entry so it looks like this:

    linux /boot/vmlinuz-3.19.0-66-generic.efi.signed root=UUID=242526b7-2821-473d-b0dc-9e9a48ea6364 ro nomodeset quiet splash $vt_handoff
  9. Reboot the LiveUSB Ubuntu, remove the pendrive and Ubuntu should boot normally. It does take a long time to boot and a purple screen (desktop edition) is shown for a while. Eventually it does boot to a full Ubuntu.
  10. [Only 6,1] Insert a USB WiFi adapter, update apt-get. Install Broadcom drivers to use the built-in WiFi:
    sudo apt-get install bcmwl-kernel-source
  11. [Only 6,1] After the first boot, permanently add nomodeset as a boot parameter: Edit file /etc/default/grub
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"
    sudo update-grub; sudo update-grub2

The computer still boots Mac OS X. I just need to hold Alt while booting and I can choose “Macintosh HD” to boot. Not that I care about having Mac OS X there, but this way I can easily restore the computer back to its original state. I haven’t tested, but it should be a matter of using efibootmgr to reset EFI to boot Mac OS X only:

sudo efibootmgr -o 80

Note 1:

In this setup, Ubuntu is on /dev/sdb but mounts /dev/sda1 (the original Mac SSD), which contains /boot/, a vfat partition. On a Mac Pro 5,1 (late 2010), I physically removed the hard drive containing Mac OS X and installed Ubuntu to a new drive. I created a 200 MB vfat /dev/sda1 as /boot and installed Ubuntu as usual. I was able to single boot Ubuntu without any hiccups.

By the way, installation was easier than in the 6,1 because I didn’t need to use nomodeset; once I had the LiveUSB drive it was just like installing Ubuntu on a regular PC.

Note 2:

I later installed Ubuntu server. The process is the same as the one for the desktop edition.

Note 3:

Due to some bug in Xorg, when running a desktop Ubuntu on the Mac Pro 6,1 and disconnecting the VGA cable, I would get 100% CPU usage caused by kworker. The command below fixed the problem.

sudo sh -c "echo disable > /sys/firmware/acpi/interrupts/gpe16

When I removed Xorg, the problem went away and I could disconnect and connect the VGA cable without any increase in CPU activity. The server edition doesn’t present this problem.

Note 4:

I find the design of the Mac Pro the cheesiest thing ever. Apple designers: “Let’s put as many round edges as possible on this computer because round is cool, right?” No, it looks like an expensive trash can on my desk or a futuristic food processor. Tacky, tacky.

Out of memory problem in linux

I was running an R program written by a third-party and for one specific dataset the process was getting killed. My machine had plenty of RAM available and the process was repeatedly getting killed by the OOM killer.

I read a little about the subject and I learned that I can tune the OOM killer by allowing my system to overcommit memory:

echo 1 > /proc/sys/vm/overcommit_memory

To permanently change this setting from 0 to 1, add this line to /etc/sysctl.conf:

vm.overcommit_memory=1

After doing this, the R process is no longer getting killed.

Problems with Ethernet card NetXtreme BCM5720 on a Dell T320

I have a Dell T320 connected directly to another computer via their gigabit ethernet cards, both running Ubuntu 14.04.

At seemingly random occasions, when transferring data constantly from the Dell to the other computer (several hundred MB’s), the connection dropped both using NFS and ssh. It seemed to be a software problem since restarting the network interface on the Dell fixed the problem (temporarily).

I couldn’t find a pattern but when I was running two tasks concomitantly that made quite a few reads and writes via ethernet over an hour or so, I repeatedly saw the network interface crash. On other light or heavy loads I couldn’t reproduce the problem.

Searching online, I found many reports of similar problems. It’s still unclear to me whether this is a problem with the tg3 driver or a bug in this chipset.

In any case, I decided to install another ethernet card on the Dell. Now, NIC’s for this server are >$100. The solution that I hope will work long-term and has survived the situation above is a cheap (~$15) USB Ethernet adapter connected to a USB 2.0 port.

I am using an Asix AX88179, which required downloading (http://www.asix.com.tw/FrootAttach/driver/AX88179_178A_LINUX_DRIVER_v1.14.2_SOURCE.tar.gz), compiling and installing (very easy) a driver, although I read somewhere that kernels >3.9 don’t need the compiled driver. According to iperf I’m getting gigabit speeds and looking at bmon I don’t notice a performance difference compared to the original card.

So here’s my suggestion if you’re having problems with your original Dell NIC and don’t want to spend much on a solution: buy a USB gigabit Ethernet adapter for $15!

One note: I had to reboot the system after installing the driver to obtain gigabit speeds.