On 11.13.11, In debian, install, kernel, usb, by jordi
Yes! Finally I could run Debian with my Chromebook with an USB stick instead of installing in hard disk. Currently I’ve Debian on my hard disk too but this opens a lot of possibilities for running any GNU/Linux with only an USB stick on Chromebook. That means that you can boot any GNU/Linux distribution from [...]
Yes! Finally I could run Debian with my Chromebook with an USB stick instead of installing in hard disk. Currently I’ve Debian on my hard disk too but this opens a lot of possibilities for running any GNU/Linux with only an USB stick on Chromebook.
That means that you can boot any GNU/Linux distribution from an USB stick without affecting nothing else as the USB stick. So it’s pretty cool!
Here is the procedure to make your own bootable USB on Chromebook.
WARNING: this method will not work for CR-48 Chromebook, at least on this version
1. An USB stick. The size of USB stick basically depends on your needs, in this guide you will need at least 6 GB because I’m mounting a root filesystem of 5 GB and we need a little more space for the kernel partition. Anyway I tested this with a 16GB basically because was the USB stick which I had.
Basically what we’re going to do is formatting your USB stick with only the required Chrome OS partitions to run the system.
We need at least 2 partitions, one partition for the kernel image and a second partition for the root filesystem.
The Chrome OS bootstub executes the kernel on our first partition, so we need to modify the kernel parameters and pass the correct rootfs or we will get a nice kernel panic.
Partition #1: KERN-A (Chrome OS kernel)
Partition #2: ROOT-A (Chrome OS rootfs)
So the partition schema is something like this:
start size part contents
0 1 PMBR (Boot GUID: 161CE441-575D-B843-A79B-06BAF66184F7)
1 1 Pri GPT header
2 32 Pri GPT table
1024 32768 1 Label: “KERN-A”
Type: ChromeOS kernel
Attr: priority=1 tries=0 successful=1
33792 10485760 2 Label: “ROOT-A”
Type: ChromeOS rootfs
31236063 32 Sec GPT table
31236095 1 Sec GPT header
Preparing the USB stick
We’re going to destroy all the data and partitions in our USB stick to generate a correct GUID partitioning.
Connect your USB stick to your local machine, open a console and enter the Chrome OS chroot.
Here we’re going to assume the USB partition is /dev/sdg, but you need to know what partition corresponds on your system. To know which partition is, execute this command after connecting your USB stick:
This will tells you which partition corresponds to your USB.
Then, delete the current partition table:
dd if=/dev/zero of=/dev/sdg bs=512 count=1
Next, make a new one:
sudo cgpt create /dev/sdg
Put the protective old-style MBR:
sudo cgpt boot -p /dev/sdg
Rescan the drive (or just remove and reinsert)
sudo blockdev –rereadpt /dev/sdg
Create a Chrome OS kernel partition:
sudo cgpt add -b 512 -s 32768 -t kernel -P 1 -S 1 -l KERN-A /dev/sdg
Then rescan the drive again (or remove and reinsert):
sudo blockdev –rereadpt /dev/sdg
Okay, we’ve the kernel partition (KERN-A) in our USB stick. I suggest you to destroy all data in this partition to prevent odd things:
sudo dd if=/dev/zero of=/dev/sdg1
Next, we need to create the root filesystem partition:
sudo cgpt add -b 33792 -s 10485760 -t rootfs -P 1 -S 1 -l ROOT-A /dev/sdg
Clean the data on rootfs partition:
sudo dd if=/dev/zero of=/dev/sdg2
Now we’ve the same partitioning schema that you saw before.
What we need now is to fill this partitions with a valid and signed kernel image and mount a valid rootfs.
Generating a kernel on KERN-A partition
In this guide we’re going to use the Chrome OS kernel, so we need to enter the chroot and generate a Chrome OS kernel with a custom kernel parameters.
Let’s prepare the kernel parameters. Enter the Chrome OS chroot and execute:
echo “console=tty1 init=/sbin/init add_efi_memmap boot=local rootwait ro noresume noswap i915.modeset=1 loglevel=7 kern_guid=%U tpm_tis.force=1 tpm_tis.interrupts=0 root=/dev/sdb2 noinitrd” > usbconfig.txt
This will create a file with our kernel parameters.
Please, take a moment to look what parameters we’re passing to the kernel:
In my case, the USB root partition on my Chromebook is /dev/sdb2, that corresponds the USB partition in my Chromebook, but you need to know which partition is in your Chromebook, you can open a console in your Chromebook and connect an USB stick to make a: dmesg | tail to know which device corresponds.
We pass loglevel=7 to get some verbose kernel information.
And you need the kernel modules too, you need to copy later the kernel modules on folder /lib/modules. Download the kernel modules for Chrome OS kernel 184.108.40.206+ here: http://files.chromebook-linux.com/modules-220.127.116.11.tar.bz2
Next, you need to generate the kernel blob with your current kernel command-line parameters (on file usbconfig.txt), so you need to repack the kernel you had download using the tool vbutil_kernel:
vbutil_kernel –repack newkernel.bin \ –config usbconfig.txt
–signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
Next, copy the binary generated to the USB KERN-A partition:
sudo dd if=newkernel.bin of=/dev/sdg1
Done. A signed kernel with a custom kernel parameters it’s copied in our USB stick, now we need to copy/create the root filesystem.
Generating the root filesystem on ROOT-A partition
Download only the debian_rootfs.binXX.bz2 files! You can create a shell script like this to easy download:
for one in a b
for two in a b c d e f g h i j k l m n o p q r s t u v w x y z
After downloading all the parts, you need to unzip and merge all the downloaded parts.
A quick way to do it:
cat debian_rootfs.bin* > debian_rootfs.bin
Next, we need to copy the kernel modules inside this rootfs or we can’t use the audio, wifi, etc… in our Chromebook.To do it, we need to create a temporary mountpoint and we’re going to copy the kernel modules inside.
sudo mkdir -p /mnt/temp_rootfs
sudo mount -t ext2 debian_rootfs.bin /mnt/temp_rootfs
sudo cp -ar 18.104.22.168+ /mnt/temp_rootfs/lib/modules
sudo umount /mnt/temp_rootfs
Finally, we copy the Debian root filesystem to the ROOT-A partition:
sudo dd if=debian_rootfs.bin of=/dev/sdg2 bs=4096
Done! Our job is finished!
Now we’ve a bootable USB stick with GNU/Linux Debian!
Booting the USB stick
Turn on the developer mode in your Chromebook, put the USB stick in your Chromebook and turn on the Chromebook.
When the “Chrome OS verification is turned off” message appears, press the keys:
This will boot your Chromebook from your USB!
Welcome to GNU/Linux Debian from USB!