Sunday, July 2, 2017

Chromebook II - a linux laptop

My previous foray into chromebooks

So it was about time again to get a new laptop. While I did have a recent windows laptop, my wife needed it more than I did, so $500 later, I was the owner of the fairly recent Asus c302 Chromebook.

This Chromebook is one of the nicest laptops I've ever owned. The all aluminum smooth lines make "it looks like a mac" comments common. The keyboard is wonderful to work on. The screen is above average brightness, full HD and touch capable, decent CPU etc.


Specs:

The CPU is fairly powerful while sipping current (4.5W "TDP"). Not much different from the MacBook 12". 4GB of RAM is an upgrade compared to my previous 2GB RAM Chromebook. I really wish I could get 8 or 16GB but the laptop is proving itself capable even at 4, so no real complaints there. The onboard SSD works at a decent clip, and 64GB is plenty for a Chromebook's standard kit plus some Android apps, and Linux installs. While it does have 2 USB-C ports, I do wish they included the old USB-A 3.0 receptacle. The larger ports would have allowed tiny drives and micro-SD card adapters to fit nearly flush with the case. At the current time, there's nothing for USB-C that fits the bill as "low profile". It does have a regular micro-SD card slot though and I wasted no time dropping in a 128GB card for more storage.


Here's what $500 got me:
CPU     : Core M3 6Y30 (0.9-2.2GHz dual core, hyperthreading)
RAM     : 4GB
Storage : 64GB (emmc)
Screen  : 12.5" 1920x1080, touch capable, folds for "tablet mode"
Battery : 6-8 hours moderate usage, 8ish hours of video playback,
          several days of standby

Ports   : 2 USB-C, a micro SD slot, audio/mic
Weight  : 2.6 pounds




My previous Acer cb3 11" is going for $80 on ebay. It's incredible for the price, but sluggish with more than moderate use.
The CPU of the Acer 11" cb3 is a Celeron N2840 (baytrail). That CPU runs from 2.16-2.58GHz - and it's trounced by the lower clocked 0.9-2.2GHz core M3 (skylake). A prime example of how a better IPC ratio works.


Pros and Cons of Chromebooks:

The Good:
  • Chromebooks are cheap.
  • Usually light and slim formfactor.
  • Excellent battery life.
  • Keyboard dumps lesser used keys, so even small keyboards have larger than average keys.
  • The boot time is fantastically short - <10 seconds.
  • Relatively decent specs for the price.
  • Security - the OS is designed to protect the user from malicious code.
  • Recovery - the OS is designed to reset to a new state.
  • Backup - The OS is designed to load all user settings and apps from the cloud if wiped or new.
  • The OS auto updates.
  • NEW Chromebooks can run Android Apps.
  • Can run Linux chroots.
  • Linux chroot runs in parallel, no reboot needed.
  • Chroot can be backed up, restored, updated in simple one line commands.
  • Can manage chroots while still getting full use from ChromeOS.

The Bad:
  • Need to get used to a slightly different kind of keyboard
  • ChromeOS itself has a limited selection of offline applications
  • Heavy reliance on Google accounts (all your info in one place isn't good)
  • Setting up Chroots is mildly technical. The warning screen should be completely blockable but isn't unless you modify the bios.
The Ugly:
  • ChromeOS update potentially can break a chroot install, requiring a chroot update to fix.
  • Warning screen is annoying long, and pressing <SPACE> will powerwash the laptop. 
  • Warning screen cannot be eliminated, but reduced to 2 seconds and beep disabled. Required opening the laptop.

Given the bad and the ugly, this is still something I really want.
once the laptop is opened and warning screen mostly neutered, it's mostly fine. One line backup/restore also mitigates that problem. Stopping the update system when entering linux also prevents updates from breaking a chroot unless you specifically let your laptop update.




My intention:

This Chromebook is among the first to be released with the intended purpose of running android applications. Initially the Google Play Store wasn't available. This was remedied by switching to the beta channel.


My intended purpose of this was to replace my old "supercheap" Acer Chromebook 11 cb3-111. It should be noted that the cb3-111 is trending on ebay at ~$80. This is dirt cheap and actually quite a decent laptop for casual work. This meant I'm really using ChromeOS as a stepping stone to the new Android application the Play Store can provide and the majority of usage is in a Linux chroot.

Setting up a Linux chroot is quite simple. going a step further and removing the write protect screw further helps by reducing a blaring warning screen that dangerously gives the option to overwrite your work by pressing space. That's really it. 
  • put device in developer mode
  • download crouton and run to install Linux chroot
  • open laptop and remove write protect screw
  • run command to shorten warning screen to minimum and stop beep
  • put screw back and close laptop
That's the plan. 


Get Android and Linux on there:

The first thing I did when I got this was just test out the basic functionality. browse the web a little, pull up the system information, run a benchmark or two. Then I put the device on the beta channel and the playstore installed. I didn't see any problems running the beta channel, so I left it. I actually don't seem to be using Android apps much really anyway, so maybe I'll switch to stable later on.

Next I wanted this to run Linux. Here's the steps:
  • Enable developer mode (ESC + F3 + Power), ctrl+D on start up. I didn't enable debugger features.
  • Download crouton https://github.com/dnschneid/crouton
  • Open crosh (ctrl+alt+t), type "shell" for bash
  • cd ~/Downloads
  • sudo sh crouton -r xenial -t xfce,xorg,xiwi,extension

Cleaner Linux Setup:

That's it. I now have Linux installed. Doing this means booting the laptop is met with a looooong beep on startup and 60 second warning screen saying "OS verification is disabled, press space to re-enable" which will powerwash the Chromebook and undo all of this. To get around it I opened the laptop and removed the write protect screw.

Do yourself a favor and use a GOOD screwdriver to handle the screws. Cheap metal tips can strip the screw head - and then you're screwed. You need a fine T5 torx tip to get at them too. 

The write protect screw is under a padded flap (circled in the image above). Unscrew and remove for now. 

Just as two years before, the following commands are run to reduce the delay and disable the beep:
sudo /usr/share/vboot/bin/set_gbb_flags.sh 0x1
sudo /usr/share/vboot/bin/set_gbb_flags.sh 0x8

I should note that after this the delay was still there. I had to enter these in crosh again to get it working. Not sure what happened there.





in order to develop stuff for servers, if you want to host anything:
in crouton, install IP tables:
sudo apt-get install iptables

vi /etc/rc.local
add:
/sbin/iptables -P INPUT ACCEPT



Linux gaming lives! just install libraries for i386 as a lot of game binaries are still 32bit, not 64.
libraries for games:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libjson0:i386
sudo apt-get install libopenal1:i386
sudo apt-get install libgl1-mesa-glx:i386
sudo apt-get install openssl:i386
sudo apt-get install lib32z1
sudo apt-get install libgtk2.0-0:i386 libidn11:i386 libglu1-mesa:i386 libxmu6:i386
sudo apt-get install libpangox-1.0-0:i386 libpangoxft-1.0-0:i386
sudo apt autoremove


Lets make crouton a little easier to manage...

Create the following files in /usr/local/bin:
linux-backup:
sudo edit-chroot -b -c /mnt/stateful_partition/chroots xenial
linux-restore:
sudo sh ~/Downloads/crouton -f -$1
linux-update:
sudo sh ~/Downloads/crouton -u -n xenial
linux-xiwi:
sudo /sbin/initctl stop update-engine
sudo startxfce4 -X xiwi
Linux-xorg:
sudo /sbin/initctl stop update-engine
sudo startxfce4 -X xorg

This simplifies your management of the setup chroot. Just type "linux-update" to update the chroot. Or "linux-restore [archive]" to restore from an archive.

I've added stopping the ChromeOS updater as well to whenever the chroot is started. The reason for this is sometimes an update can stop the chroot from starting. This prevents that from happening unexpectedly. Automatic updates are awesome, but I much prefer control over it when it can break something. If I'm traveling for example, and happen to get wifi access momentarily, I wouldn't want an update pushed preventing me from using Linux for the rest of the trip.

Last thing - within the chroot, make a script:
remountSD:
sudo mount -o remount,exec /var/host/media/removable/SD\ card

Normally removable media is mounted with noexec, so you can't execute binaries and scripts. Running this will remount it so you can. In this case, the label of my microSD was "SD card" so adjust that line to suit your needs.