Thursday, January 23, 2014

[Guide] How To Install Elementary OS on an HP Chromebook 14 Using Crouton


Elementary OS is my favorite Linux distribution. It's simple, fast and well designed. On the HP Chromebook 14, it's the perfect companion to Chrome OS. Here's how to install it using crouton (see below for differences between crouton and Chrubuntu).

This post is written with the average user in mind - like myself, so I hope a lot of people will find it helpful. I don't take credit for this tutorial, since it's heavily based on this guide I found on Reddit, as well as another article from a user 'Brad' (for the Acer C7). However, I will detail each step further and adding tweaks specifically for the HP Chromebook 14.

There are many ways to install Elementary OS. The approach that works best (with minimal bugs) seems to involve a clean install of Ubuntu 12.04 with XFCE environment, then adding Elementary desktop, and finally removing XFCE. Some users may take shortcuts or go a different way, but this worked for me and I can personally vouch for it.


Elementary OS 0.2 Luna

After this tutorial :

- You will have a chroot with Elementary OS 0.2 Luna
- You'll be able to switch seamlessly between Chrome OS and Elementary OS
- No need to reboot!
- Synced clipboard across both OS
- Fixes and improvements for performance
- Working hotkeys for volume, brightness and full screen mode
- Elementary Tweaks for additional interface customization and themes



Crouton vs. Chrubuntu

Before you begin, you should be aware of the basic differences between crouton and Chrubuntu. Some people may prefer the latter.

In very simple terms, Chrubuntu lets you dual-boot and choose either Chrome OS or Elementary OS upon startup. You can only run one at a time. To switch, you need to reboot your machine. It's great if you intend to spend more time in one environment. However, current installation methods using Chrubuntu require a kernel upgrade, a fix for suspend mode, and another script to fix the touchpad before Elementary OS becomes usable at all.  [instructions here]

Crouton, on the other hand, is a bit like virtualization (but not quite). Instead of booting a second OS, Elementary runs natively with Chromium OS. You must know that a chroot is inherently less secure (vulnerable to root exploit). And some settings, such as Wi-Fi and time & date can only be changed in Chrome. Finally, starting Elementary OS involves opening Terminal and entering a command line (because the Chromebook will boot Chrome OS by default).

Caveats aside, the biggest benefit of crouton is that you can run Elementary and Chrome OS side by side. You can switch seamlessly with a keyboard shortcut. You can use the same /Downloads folder. There is even a Chrome extension to share the clipboard (copy/paste across both). The RAM is shared, but there are less hardware bugs to fix upon install. This setup is great if you intend to use Chrome OS as a default, and occasionally run Elementary OS whenever you need.

Ok let's do this !

First things first


1. Enable developer mode on your Chromebook (warning - this will wipe your device) :
  • Hit ESC Refresh, then press Power
  • At the recovery screen, hit CTRL-D, then ENTER to turn OS verification off
  • Wait for the machine to reboot in dev-mode and do its reset
  • After it's done, hit CTRL-D again to start Chrome OS
From now on, you'll see that "scary boot screen" every time you'll power on the Chromebook; because you're in developer mode. Unfortunately, there's no way around this with Chrome OS. So whenever you power on, remember to hit CTRL-D to start Chrome OS. However, you won't see this screen when waking up from suspend.
If you're already in developer mode, make sure your partitions are 'factory state'; for example if you experimented with Chrubuntu or have installed a different chroot before, I recommend that you at least do a power wash before proceeding.

Note (Jan 24, 2014):   Due to a bug involving X Server and crouton, you must be on the stable channel of Chrome OS before proceeding, or else, your chroot may fail to initiate (it happened to me while I was on the dev channel). Even for those on the beta channel, I strongly recommend that you switch to stable to avoid any issues with Elementary OS (mine has been stable for several weeks now).


Download crouton


2. Login Chrome OS or use Guest mode, then grab crouton from here or http://goo.gl/fd3zc ; it will save into your Downloads folder

Going forward, I will highlight Terminal command lines in yellow when in Chrome OS (chrosh), or turquoise when in XFCE/Elementary (chroot).


Install Ubuntu 12.04 (precise)


3. In Chrome, open a new terminal with CTRL-ALT-T. Type shell , and hit ENTER.

4. Type

sudo sh -e ~/Downloads/crouton -t xfce,keyboard,extension -n elementary 

then ENTER.

This will install Ubuntu 12.04 as a chroot named 'elementary', with the XFCE desktop - which we'll use temporarily - as well as support for keyboard hotkeys and clipboard synchronization later in this guide.

5. Go make coffee. Or watch my awesome video of 35 voice searches on Android. Installation will take a while, depending on your network speed; around 10-15 minutes.

https://plus.google.com/107200121064812799857/posts/LGKQz4u8ttY

6. Towards the end, you'll be prompted to create a UNIX username and password. I went with user/user (very hard to guess, I know). Pick anything. Just know that you'll be using that password often in Elementary.


Start crouton and download files for Elementary


7. While you're still in the Chrome terminal, start crouton (or chroot) with  sudo startxfce4  . This will start Ubuntu 12.04.



XFCE desktop environment, before we switch to Elementary


8. Make sure the touchpad is working. If it's not, use a USB mouse. On the welcome screen, choose default config for the panels.  In the next step, we will download the files and repositories necessary to install Elementary.

9. Open a Terminal in Ubuntu (there should be a shortcut in the task bar), and run the following commands in this order. You'll be prompted for your root/UNIX password the first time.

sudo apt-get install python-software-properties
sudo add-apt-repository -y ppa:elementary-os/stable
sudo apt-get update
sudo apt-get install elementary-desktop
sudo apt-get install gtk2-engines-pixbuf


Create startup scripts for Elementary OS


This is the part that gave me headaches (as a Linux newbie), since there are very few users of HP Chromebook 14 + Elementary - and scarce documentation - but don't worry, if I got it working, you will too. In this section, we will copy the XFCE startup script and modify it to run Elementary using the xinit system initializer

At this point, we need to download a text editor. There are many choices out there, such as gedit. However, we will be using nano in this guide. It's a simple editing tool and runs completely inside Terminal, so we won't need to switch windows.

10. In Terminal, install nano by typing :

sudo apt-get install nano
(press Y for "yes" if you're prompted)

11. We will copy the XFCE startup script and call it "startelementary" :

cd /usr/bin
sudo cp startxfce4 startelementary

12. Now that we've copied the script, we will edit that new file with nano :

sudo nano startelementary

13.  Your Terminal is now the interface for nano. Use the arrow keys and scroll down to the second-to-last line of the script where it says :

exec $prog /etc/xdg/xfce4/xinitrc $CLIENTRC $SERVERRC .

Leaving the rest intact, replace the above part in red with this (in blue) :

exec $prog /usr/bin/xinit_pantheon

Do not hit ENTER. Instead, hit CTRL-O (to save), then ENTER (to confirm filename), then CTRL-X (to exit nano and go back to Terminal).

14. In the same directory (/usr/bin/) we will now create a file called xinit_pantheon :

sudo nano xinit_pantheon

15. The script will be blank. Write the following two lines exactly as they appear (in blue) :

For those reading this on a mobile device, the first command line is #!/bin/sh , then everything else is a single line.

#!/bin/sh
/usr/sbin/lightdm-session "gnome-session --session=pantheon"

Again, hit CTRL-O (to save), then ENTER (to confirm filename), then CTRL-X (to exit nano and go back to Terminal).

16. Finally, we need to make xinit_pantheon executable :

sudo chmod +x xinit_pantheon
sudo chown root:root xinit_pantheon



Copy nano to Chrome OS


17. Before we switch back to Chrome OS, we will copy the nano editor to the /Downloads/ folder, so we can use it in Chrome later :

sudo cp /usr/bin/nano ~/Downloads/



Edit startup scripts in Chrome OS


18. Log out of your XFCE chroot (top-right corner > logout). You'll be brought back to Chrome. Wait for the script to finish, until you see a green "chronos@localhost" line.

19. We'll move nano to the Chrome binary folder (so we can actually use it) :

sudo mv ~/Downloads/nano /usr/local/bin/
sudo chown root:root /usr/local/bin/nano

20. We will now copy and edit one last file :

cd /usr/local/bin
sudo cp startxfce4 startelementary
sudo nano startelementary

Using the arrow keys, scroll down to the very last line where it says :

exec startxfce4

Replace that with :

exec startelementary

Hit CTRL-O (to save), then ENTER (to confirm filename), then CTRL-X.


Are you ready for Elementary OS ?


21. Run sudo startelementary



http://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Screenshot_from_2013-08-11_15_57_35.png/800px-Screenshot_from_2013-08-11_15_57_35.png

Congratulations! You should now be running Elementary in crouton. You'll notice that the touch pad works, but performance is a bit jittery, and none of the hotkeys work yet (volume / brightness). 

Anytime you need to switch between Chrome OS and Elementary OS, use CTRL+ALT+SHIFT+BACK or CTRL+ALT+SHIFT+FORWARD. It should be instant.


Recommended fixes


Upgrade XSERVER-XORG right away to address lag and performance


1. In Elementary OS, hit CTRL-ALT-T to open Terminal

2. Type  sudo apt-get install xserver-xorg-lts-raring

3. You'll be prompted with a pink screen to upgrade GRUB-PC package. Since we're running Elementary as a chroot, there's no need to modify the boot loader on the Chromebook. Hit TAB to highlight "OK", ENTER, then hit TAB again and make sure that none of the devices (such as /dev/sda) are checked. Say "OK". At the next screen, where it says "you chose not to install GRUB to any devices", hit "OK" again. Finally, "Continue without installing GRUB?" - hit YES.

4. Wait for the script to complete.

5. Log out from Elementary OS (top-right corner)

6. In Chrome, open Terminal and run  sudo startelementary

You should now notice much better performance in Elementary OS (smoother animations, less CPU usage, etc.)


Fix volume hotkeys


1. In Elementary, go to System Settings > Keyboard > Media
2. Click on Volume Up, and assign the proper key (should be F10 on the HP Chromebook 14)
3. Do the same for Volume Down (F9) and Mute (F8)
4. Your volume keys should work immediately!


Install Elementary Tweaks


http://www.elementaryupdate.com/2013/06/finally-elementary-tweaks.html

You can learn more about Elementary Tweaks here. There are tons of options to customize the interface and themes/icons you can install later on. But for now, we will need it to fix our brightness keys.

To install, do this in Terminal :

sudo add-apt-repository ppa:versable/elementary-update
sudo apt-get update
sudo apt-get install elementary-tweaks

Elementary Tweaks should be available immediately (check in the Applications Launcher, System Settings, then look for Tweaks). If you run into any bugs, try logging out and restarting Elementary OS.


Fix brightness hotkeys

In order to fix our brightness shortcuts, we will use Elementary Tweaks (updated: Feb 27, 2014)

1. Go to System Settings > Tweaks > Shortcuts
2. Press the (+) sign at the lower left
3. Create a shortcut named "Brightness up"
4. Click the Shortcut button and press F7 to assign it (brightness increase key on the Chromebook)
5. In the Command field, type " brightness up "
6. Click on the green (+) button to save the shortcut.
7. Re-do steps 4 to 8 for brightness down (this time, the key is F6, and the command will be " brightness down "

Your brightness keys should work immediately!

Thanks to Andy Castille for this fix!



A note about suspend mode


You can close the lid and the Chromebook will go to sleep mode as usual. Re-opening the lid should bring you right back to Elementary, thanks to the xinit_pantheon script we edited earlier. Some users have reported that their screen doesn't turn on automatically. If that happens to you, press on the 'brightness up' keyboard shortcut and your screen will come back.

In the meantime I'm trying to find a fix and will update the blog post when successful.


Remove XFCE and anything else you don't need


To save disk space, you can optionally remove XFCE as well as some of the apps that came with it (or Elementary OS), assuming you don't need them. You can remove packages with the command sudo apt-get purge packagename . You can remove multiple package by listing them in the same command (separated by a space), or adding an asterisk as a wildcard.  You should also make sure to remove unused dependencies by running sudo apt-get autoremove after a package has been removed.

SOME PACKAGES YOU CAN REMOVE :

xfce4  (to remove XFCE desktop)
xfce4-goodies (to remove apps that came with XFCE)
xfce*  (to remove all of the above - will clear approx 75 MB)
shimmer-themes (themes that came with XFCE, approx 8 MB)
netsurf-gtk (the browser that came with XFCE, approx 2.5 MB)

empathy (chat client that came with Elementary)
telepathy* (chat indicator service in the status bar)
indicator-messages (indicator for telepathy)
brasero (CD burner - useless on the HP Chromebook 14, approx 1 MB)
geary (default mail app)
maya-calendar (calendar)
elementary-scan (scanner)
shotwell* (photo manager)
totem (media player, if you intend to use VLC instead)
onboard (onscreen keyboard)
gnome-orca (screen reader)
xscreensaver (I recommend you remove this one)
software-center (we don't need Ubuntu sofware center since Elementary comes with its own lightweight package installer)
midori* (default browser)

Re-adding one of the above packages is as simple as running sudo apt-get install packagename .

For a complete list of packages, you can visit these links (repositories):

- Elementary Update PPA (themes and icon packs for Tweaks listed)
- Elementary Stable PPA (default packages and apps for Elementary/stable)


How to make the clipboard work


If you've followed this guide from the beginning, then you've already installed Ubuntu 12.04 with the target "extension". All you need to sync the clipboard is to install the crouton integration extension from the Chrome Web Store. When it's done, try copy-pasting across both OSes!  This extension also does Chromium URL handling.



More themes, icons and wallpapers!


http://www.elementaryupdate.com/2013/07/5-new-awesome-elementary-themes.html


My favorite feature of Elementary OS (by far) is the ability to install Elementary Tweaks - giving you dozens of ways to customize the interface. This website is a great resource to find and discover themes and icons. Or you can view the repositories above (PPA links).

Below are just some of the possible packages you can try using sudo apt-get install packagename .  Try them out and have fun tweaking !

INTERFACE THEMES

elementary-blue-theme
elementary-colors-theme
elementary-champagne-theme
elementary-lion-theme    (for Mac OS lovers!)
elementary-milk-theme
elementary-dark-theme
elementary-harvey-theme
elementary-whit-e-theme
elementary-plastico-theme

PLANK (taskbar)

elementary-plank-themes
elementary-plank-extra

WING PANEL (to customize the top bar)

super-wingpanel

ICON PACKS

elementary-elfaenza-icons
elementary-emod-icons
elementary-enumix-utouch-icons
elementary-nitrux-icons
elementary-taprevival-icons
elementary-thirdparty-icons



Keep crouton up to date

As detailed by the crouton developer, your chroot may become obsolete when a new version of crouton is available. To keep it up to date, you must use the -u command in Chrome OS:

sudo sh -e ~/Downloads/crouton -u -n elementary


A note on installing .deb packages


Many users will want to install applications in the form of downloadable .deb packages. Examples include Skype, Dropbox and Firefox.

All you need to remember is that Elementary OS 0.2 Luna is based on Ubuntu 12.04 (precise), and the HP Chromebook 14 uses the 64 bit architecture. When choosing a package version, look for '64-bit Ubuntu 12.04 precise'.

I will be making separate blog posts on how to properly install Dropbox (with a file plugin), KingSoft Office alpha 12 (my favorite office suite for Linux) and Steam in the future.

EDIT: Here are instructions to install KingSoft Office Alpha 12 (2013).