Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Revised]HOWTO run Debian Sid on Acer C710 Chromebook

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
hkoster1
Posts: 1264
Joined: 2006-12-18 10:10

[Revised]HOWTO run Debian Sid on Acer C710 Chromebook

#1 Post by hkoster1 »

Well, Wheezy actually... see later.

The easiest and fastest way to get a Debian rootfs to run on the Acer C7 series Chromebook is in a chroot to be entered from ChromeOS (in developer mode). The crouton installation scripts by Google's David Schneider work flawlessly: I had, with install options "-r sid" and "-t lxde" Debian Sid with the LXDE desktop environment up and running in 30 minutes flat. So, read no further if all you want to do is to play around a bit with running a Debian rootfs on your Acer C7 series Chromebook.

The chroot method is not suitable in my view for a serious Debian rootfs installation, as you'll bump into restrictions imposed by the ChromeOS chroot. For example, installing a CUPS network printer in the chroot turned out to be a major headache... You'll be wasting a lot of time chasing solutions to this and similar problems.

Better in that case to run the Debian rootfs directly on the hardware, with its own kernel. Initially, as described in this HOWTO, that will be a copy of the ChromeOS kernel, but this could eventually also be a Debian kernel configured for the Chromebook hardware and firmware.

My Chromebook came with an internal 320GB HDD and 2 GB RAM, which I've upgraded to a 120GB SSD and 8 GB RAM. That makes this Chromebook a very capable machine indeed to run a Debian rootfs on, even with that modest 1.1GHz Celeron dual-core CPU.

While there are umpteen scripts and blogs around showing how to install Ubuntu on this Chromebook, this HOWTO focuses strictly on Debian. The title says Sid, but it works just as well for testing (Jessie) and stable (Wheezy). In fact, this revised HOWTO is based on installing Wheezy, since Sid was on the fritz while writing it at the end of August 2013.

Most commands in the following are to be run with root privileges.

1. Prepare your Chromebook
The Chromebook must be put (and kept) in developer mode: power on while simultaneously pressing the Esc and Refresh buttons, after which a "scary screen" appears with dire warnings. Ignore these, press Ctrl-D, press Enter to confirm the procedure, and press Ctrl-D once more. This takes a little while to complete.

From now on the Chromebook (re)boots into that scary screen (get used to it!); press Ctrl-D to start the priority OS, at first ChromeOS. Once in the login screen, open a shell with Ctrl-Alt-Forward (where Forward is the right-facing arrow in the top row of the keyboard).
Alternatively, after logging in, open a crosh window with Ctrl-Alt-T and start a shell from there.

Become root and upgrade to developer firmware with

Code: Select all

# chromeos-firmwareupdate --mode=todev
after which there is an automatic reboot. You may have to repeat this once in a while, as updates are not pushed.

2. Make space for KERN-C and ROOT-C
Open a root shell and show the partition table of the internal drive with

Code: Select all

# cgpt show /dev/sda
Notice that partitions 6 (KERN-C) and 7 (ROOT-C) are placeholder partitions intended for dual-boot purposes, initially sized at 1 512-byte sector. Space for their operating sizes must be taken from the STATE partition, which starts in my case at sector 8,671,232; on my 120GB SSD it has size 225,734,656, while on the original 320GB HDD it will be larger accordingly.

KERN-C must be given the standard size 32,768 for the ChromeOS kernel. ROOT-C will house our Debian rootfs; its size will be a matter of preference, provided that STATE keeps at least a couple of GBs. My choice for the size of ROOT-C was 60 GiB or 125,829,120 sectors, which together with 32,768 sectors for KERN-C leaves 99,872,768 sectors for STATE.

The required space is taken from the end of STATE, after first repeatedly unmounting it (since it is multiply mounted),

Code: Select all

# umount -l /dev/sda1
until ChromeOS says that it isn't mounted. Then do the repartitioning with

Code: Select all

# cgpt add -i 1 -b 8671232 -s 99872768 -t data -l STATE /dev/sda
# cgpt add -i 6 -b 108544000 -s 32768 -t kernel -l KERN-C /dev/sda
# cgpt add -i 7 -b 108576768 -s 125829120 -t rootfs -l ROOT-C /dev/sda
You may have to adjust the numbers for your situation, if different. Reboot to make the new partition table stick, at which the firmware will automatically rebuild the resized STATE partition.

3. Prepare Debian rootfs on GNU/Linux computer
The Debian rootfs is most conveniently installed with debootstrap on a running Debian GNU/Linux computer or virtual machine. Installation is first to a raw (binary) disk image, from which the completed rootfs partition is extracted and transferred to the Chromebook.

We make that disk image not too large, like 6 GiB or 12,582,912 sectors, so as to keep the time needed for the rootfs transfer reasonable. The rootfs can be expanded later to take up all space available on ROOT-C.

3.1 Prepare the rootfs partition
Create the disk image in a working directory on the GNU/Linux computer with

Code: Select all

# dd if=/dev/zero bs=512 seek=12582911 count=1 of=debian.bin
Mount it as a loop device,

Code: Select all

# losetup /dev/loop0 debian.bin
then open it with

Code: Select all

# gparted /dev/loop0
to give it a GUID partition table (GPT) and a single Ext4 formatted partition /dev/loop0p1 taking up all available space.

3.2 Debootstrap
Mount the intended rootfs partition somewhere convenient,

Code: Select all

# mount -o dev,exec /dev/loop0p1 /mnt
then bootstrap Debian Wheezy with

Code: Select all

# debootstrap --verbose --arch=i386 --foreign wheezy /mnt <your-preferred-mirror>
taking care to use the --foreign option just in case the host OS doesn't have the i386 architecture.

The bootstrap is completed when chrooted to the new rootfs, for which the packages qemu-user-static and binfmt-support must be installed on the host OS:

Code: Select all

# cp /usr/bin/qemu-i386-static /mnt/usr/bin/
# mkdir /mnt/dev/pts
# modprobe binfmt_misc
# mount -t proc /proc /mnt/proc
# mount -t devpts /dev/pts /mnt/dev/pts
# chroot /mnt
The prompt in the chroot will indicate that there is as yet no name---this will be fixed later. First, complete the installation of the base system with

Code: Select all

# /debootstrap/debootstrap --second-stage
3.3 Configuring the rootfs
It is convenient, while still in the chroot, to configure the base system. First, edit /etc/apt/sources.list as per usual, then

Code: Select all

# aptitude update
Next configure language and locale,

Code: Select all

# export LANG=C
# aptitude install dialog locales
# dpkg-reconfigure locales
where I chose to install

Code: Select all

# export LANG=en_US.UTF-8
Now is also the time to install some additional packages, like wpasupplicant and dhcp3-client; but more encompassing installations such as the XFCE desktop environment are best left for later (would probably fail in the chroot).

Edit /etc/network/interfaces as follows

Code: Select all

auto lo wlan0
iface lo inet loopback
iface wlan0 inet dhcp
      wpa-ssid <SSID>
      wpa-psk  <passphrase>
where wireless access particulars should be inserted. Alternatively, the lines

Code: Select all

auto eth0
iface eth0 inet dhcp
could be substituted or added.

Finally, we fix passwords, user and hostname with

Code: Select all

# passwd
# adduser <user>
# vi /etc/hostname
and also add your chosen hostname to /etc/hosts with the line

Code: Select all

127.0.1.1              <your-hostname>
Exit the chroot, unmount /mnt (possibly after killing some processes still using the latter), and release the disk image with

Code: Select all

# losetup -d /dev/loop0
Transfer the disk image to the Chromebook, for example on an 8GB USB memory stick or SDHC card with an Ext2 filesystem (since VFAT cannot handle files larger than 4 GB).

4. Install rootfs and kernel on Chromebook
Open a root shell when back in ChromeOS on the Chromebook.

4.1 Extract Debian rootfs
Mount the USB memory stick or SDHC card on the new mount point /tmp/debian, then

Code: Select all

# cd /tmp/debian
# cgpt show debian.bin
to see that the rootfs partition starts at sector 2048 and has size 12,578,816. Extract the rootfs and write it to the (unmounted) ROOT-C partition with

Code: Select all

# dd if=/tmp/debian.bin bs=512 skip=2048 count=12578816 of=/dev/sda7
which will take a while. When done, expand the rootfs to use all available space in ROOT-C,

Code: Select all

# e2fsck -f /dev/sda7
# resize2fs -p /dev/sda7
This completes installation of the Debian rootfs to ROOT-C, except for some housekeeping.

4.2 Package a kernel
Some minimal kernel command line is needed for the ChromeOS kernel to work with the Debian rootfs, like

Code: Select all

console=tty1 debug verbose root=/dev/sda7 rootwait rw lsm.module_locking=0
typed all on one line. Note that kernel modules will currently not load without that last option, ascribed to a bug in modprobe and/or busybox. Collect this kernel command line in the file /tmp/config.

Find the current kernel version with

Code: Select all

# uname -r
showing it to be 3.4.0 in my case. As ChromeOS has now done away with the /boot directory, we must repackage the running kernel for our use. Find the ChromeOS kernel with the highest priority with

Code: Select all

# cgpt show /dev/sda
showing it in my case to be KERN-B in partition /dev/sda4. Copy the kernel blob to the file /tmp/oldblob with

Code: Select all

# dd if=/dev/sda4 of=/tmp/oldblob
Next, collect the lengthy repackaging and signing command in a file, call it /tmp/repack,

Code: Select all

vbutil_kernel --repack /tmp/newkern \
  --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
  --version 1 \
  --signprivate \
       /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
  --config=/tmp/config \
  --oldblob /tmp/oldblob
(for convenience complete with backslashes and linebreaks) then run this command with

Code: Select all

# sh /tmp/repack
which sees the new kernel stored in /tmp/newkern.

4.3 Install kernel, modules and firmware
The resulting new kernel is written to the KERN-C partition with

Code: Select all

# dd if=/tmp/newkern of=/dev/sda6
Now is also the time, in the same session, to copy the kernel modules and the firmware to the Debian rootfs. (Don't wait, as ChromeOS makes unannounced changes!)

Code: Select all

# mount /dev/sda7 /tmp/sda7
# cp -ar /lib/modules /tmp/sda7/lib/
# cp -ar /lib/firmware/* /tmp/sda7/lib/firmware/
We adjust the boot priority of our new kernel with

Code: Select all

# cgpt add -i 6 -S 1 -T 5 -P 5 /dev/sda
after which the new Debian rootfs can be booted.

5. Running with the Debian rootfs
We must first make sure that we can also reboot ChromeOS. Download and install the cgpt package from the Debian unstable (Sid) repository, as this is not available in the Debian stable (Wheezy) release,

Code: Select all

# dpkg -i cgptxxxxxxx_i386.deb
where there shouldn't be any dependency problems.

Rebooting ChromeOS requires changing the boot priority of KERN-C back to zero. It is convenient to do this with the script chromeboot placed in /usr/local/bin,

Code: Select all

#!/bin/sh
## (Re)boot Chromebook with ChromeOS.
## Usage: chromeboot [now]
## to be run with root privileges.
cgpt add -i 6 -S 1 -P 0 /dev/sda
case "$1" in
   now* ) echo "Will reboot ChromeOS now..."
          sleep 3
          reboot ;;
      * ) echo "Will boot ChromeOS on next (re)boot..." ;;
esac
exit 0
and likewise to boot with the Debian rootfs from ChromeOS with the setting "-P 5". These scripts must be made executable with root privileges with chmod 744 <path-to-script>.

6. Back to ChromeOS in user mode
The Chromebook can be restored to the original ChromeOS in user mode by first reverting the firmware in a ChromeOS root shell with

Code: Select all

# chromeos-firmwareupdate --mode=tonormal
before hitting the space bar in that "scary screen.''

Note that this does not undo our earlier partitioning of the internal drive. If you also want to undo that partitioning (and lose everything on it), then you should have a "recovery image" handy before zeroing the GPT table entries with

Code: Select all

# cgpt -Z create /dev/sda
before rebooting.

In conclusion
Most everything seems to work out-of-the-box when running the Debian rootfs on this Chromebook, including sound. I'm running XFCE as a desktop environment, and I'll be posting separately about screen brightness and audio volume keys.

Enjoy!

Credits: Much info gleaned from various forums and blogs, especially the blogs of Google's Olof Johansson.
Last edited by hkoster1 on 2013-09-05 12:31, edited 8 times in total.
Real Debian users don't do chat...

hkoster1
Posts: 1264
Joined: 2006-12-18 10:10

Re: [Updated 2x]HOWTO run Debian Sid on Acer C710 Chromebook

#2 Post by hkoster1 »

Enabling screen brightness and audio volume keys
The screen brightness keys F6/F7 can be made to work by binding them to a brightness control script that uses the gnome-settings-daemon package. You may need to unbind those keys from other functions in your desktop environment.

Edit the script /usr/local/bin/brightness as follows

Code: Select all

#!/bin/sh
## Control screen brightness on Acer C7 series Chromebook with
## /usr/bin/gnome-settings-daemon/gsd-backlight-helper
##
## Usage: brightness [u|d]
##
## Adjusts brightness u[p] or d[own] in 8 steps of 100
## between 86 - 886.
## Returns current brightness without argument.
PKX=/usr/bin/pkexec
HLP=/usr/lib/gnome-settings-daemon/gsd-backlight-helper
BRX=$( ${PKX} ${HLP} --get-brightness )
case "$1" in
   u* ) ${PKX} ${HLP} --set-brightness $(($BRX+100))  ;;
   d* ) ${PKX} ${HLP} --set-brightness $(($BRX-100))  ;;
    * ) echo "Screen brightness = " $BRX " (max = 886)" ;;
esac
exit 0
and make it executable with the command

Code: Select all

# chmod a+x /usr/local/bin/brightness
Of course, this script may also be run from the command line.

Likewise, the audio volume keys F8/9/10 may be bound to the following amixer commands, respectively,

Code: Select all

# amixer -c 0 set Master toggle
# amixer -c 0 set Master 5%-
# amixer -c 0 set Master 5%+
again possibly after first unbinding those keys from other functions assigned in your desktop environment. Note that the interface is called "Master", not "Speaker" as on the ARM Chromebook.
Real Debian users don't do chat...

Post Reply