Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BlaiseRideout/d353893c250f3bb9320b to your computer and use it in GitHub Desktop.

Select an option

Save BlaiseRideout/d353893c250f3bb9320b to your computer and use it in GitHub Desktop.
Install Debian on an Asus C300 Chromebook

Install Debian on an Asus C300 Chromebook

TODO: Make this back into a bash script instead of a human one

Enable developer mode if you haven't already

  1. Hold down Esc + Refresh and press the Power button.
  2. Once you see the Recovery Mode screen, press Ctrl-D, then press Enter.

Configuring your partitions

The following section assumes your chromebook's SSD is /dev/mmcblk0. If you're unsure, run:

rootdev -d -s

  1. Get to a root shell.

  2. Decide what size you want to make Debian's root partition and the stateful partition.
    The size of the stateful partition should be at least 256MiB and the sum of the sizes of the stateful partition and the Debian root partition should be equal to the current size of the stateful partition+1.
    Note that the sizes used by cgpt are in sectors, or 2KiB.
    You can find the current size of the stateful partition by running the following command:

cgpt show -i 1 -n -s -q /dev/mmcblk0

  1. Unmount your stateful partition

umount -f /mnt/stateful_partition

  1. Find the current start offset of your stateful partition:

cgpt show -i 1 -n -b -q /dev/mmcblk0

  1. Resize the stateful partition. This will wipe all user data stored on this partition.

cgpt add -i 1 -b $stateful_start -s $stateful_size -l STATE /dev/mmcblk0

  1. Resize the new kernel partition. $kernc_start can be found by adding $stateful_size to $stateful_start. Note that the kernel partition is always 16MiB.

cgpt add -i 6 -b $kernc_start -s 32768 -l KERN-C /dev/mmcblk0

  1. Resize the new root partition. $rootc_start can be found by adding 32768 to $kernc_start.

cgpt add -i 7 -b $rootc_start -s $rootc_size -l ROOT-C /dev/mmcblk0

  1. Reboot your system. It will reformat the stateful partition.

reboot

  1. Get to a root shell.

  2. Create a new ext4 filesystem in your new root partition.

mkfs.ext4 /dev/mmcblk0p7

  1. Make a directory called /tmp/urfs and mount your new Debian root partition into it

mkdir /tmp/urfs
mount /dev/mmcblk0 /tmp/urfs

Getting your enviroment ready to run debootstrap

  1. Create a directory in /tmp/urfs called debootstrap to store files needed for installation and cd into it.

mkdir /tmp/urfs/debootstrap
cd /tmp/urfs/debootstrap

  1. Get debootstrap dependencies from another x86_64 Linux box or download them from http://blaiseritchie.com/UPLOAD_TAR_GZ_HERE and copy them into /tmp/urfs/debootstrap/{bin,lib}: /usr/bin/ar, /usr/lib/libbfd-2.22-system.so, /usr/bin/perl, and /usr/lib/libperl.so.5.14

wget -O deps.tar.gz http://blaiseritchie.com/URL
tar xf deps.tar.gz

  1. Download and extract debootstrap

wget http://http.debian.net/debian/pool/main/d/debootstrap/debootstrap_1.0.48+deb7u1.tar.gz
tar xf debootstrap_1.0.48+deb7u1.tar.gz

  1. Add /tmp/urfs/debootstrap/lib to LD_LIBRARY_PATH and /tmp/urfs/debootstrap/bin to PATH

export PATH="$PATH:/tmp/urfs/debootstrap/bin" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/tmp/urfs/debootstrap/lib"

Running debootstrap and configuring your system

  1. cd into /tmp/urfs run debootstrap

cd /tmp/urfs debootstrap --arch amd64 testing . http://http.debian.net/debian/

  1. Remove unneeded debootstrap directory

rm -rf debootstrap

  1. Bind mounts

mount -o bind /proc proc
mount -o bind /dev dev
mount -o bind /dev/pts dev/pts
mount -o bind /sys sys

  1. Copy files from ChromeOS.

cp /etc/hosts etc
cp /proc/mounts etc/mtab
cp /etc/resolv.conf etc
cp /usr/bin/old_bins/{cgpt,chromeos-tpm-recovery,common_minimal.sh,crossystem,dev_debug_vboot,dev_sign_file,dumpRSAPublicKey,dump_kernel_config,enable_dev_usb_boot,gbb_utility,make_dev_firmware.sh,make_dev_ssd.sh,resign_firmwarefd.sh,set_gbb_flags.sh,tpm-nvsize,tpm_init_temp_fix,tpmc,vbutil_firmware,vbutil_kernel,vbutil_key,vbutil_keyblock,vbutil_what_keys} usr/local/bin
KERN_VER=$(uname -r)
mkdir -p lib/modules/$KERN_VER/
cp -ar /lib/modules/$KERN_VER/* lib/modules/$KERN_VER/
mkdir -p lib/firmware
cp -ar /lib/firmware/* lib/firmware/

  1. Pick a hostname and put it in etc/hostname and etc/hosts

echo "ChrDebian" > etc/hostname
echo -e "\n127.0.1.1 ChrDebian" >> /etc/hosts

  1. chroot into your new system.

chroot . /bin/bash

  1. Install needed packages.

apt-get -y update
apt-get -y dist-upgrade
apt-get update
tasksel install standard
tasksel install laptop

  1. Configure a user account

useradd -m -s /bin/bash -G adm,sudo,audio user
echo user:password | chpasswd

  1. Exit your chroot

exit

  1. Create /kernel-config

echo "console=tty1 debug verbose root=/dev/mmcblk0p7 rootwait rw lsm.module_locking=0" > kernel-config

  1. Write the kernel into the new kernel partition

current_rootfs="$(rootdev -s)"
current_kernfs_num=$((${current_rootfs: -1:1}-1))
current_kernfs=${current_rootfs: 0:-1}$current_kernfs_num
vbutil_kernel --repack /dev/mmcblk0p6 \
--oldblob $current_kernfs \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--version 1 \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config kernel-config \
--arch x86

  1. Set debian kernel partition as top priority for next boot (and next boot only)

cgpt add -i 6 -P 5 -T 1 /dev/mmcblk0

Optional: install reboot-debian and reboot-chromeos scripts

  1. Download the scripts

wget -O scripts.tar.bz2 http://blaiseritchie.com/scripts.tar.bz2

  1. Install scripts to Debian

tar xf scripts.tar.bz2 -C usr/local/bin

  1. Install scripts to ChromeOS

tar xf scripts.tar.bz2 -C /usr/local/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment