Saturday, March 9, 2013

Installation Method

[Edit]  This method is now deprecated in favor of the USB Bootable Media Toolbox.  This post remains  for historical reference only.  [08/31/13]

Here's a rather verbose & needlessly complex explanation of how I test Linux Distros on the Acer C7.  However, I think it should work with any Chromebook capable of booting from USB, but might require modification in some cases.  It is and will always be a "work-in-progress", so please let me know if something isn't clear.

Requirements

     1. A Chromebook in "Developer Mode."
     2. Same Chromebook running Developer Firmware.
     3. Same Chromebook with USB Boot enabled.
     4. USB bootable media (thumb drive or SD card).  From 4 - 16 GB will suffice.  16 GB will match the internal storage of every Chromebook prior to the Pixel, except for the Acer C7.  So, you could duplicate your SSD for development purposes.  See Tips #1 & #3 for relevant info.


The Method

     A. From ChromeOS, use cgpt to create a GPT partition table on your media (I'm using a 16GB SD card in the reader slot), add a kernel partition #6 which is 16 MB in size, and add a rootfs partition #7 using the remaining space.  Something like this:

cgpt create /dev/mmcblk0
cgpt show /dev/mmcblk0
       start        size    part  contents
           0           1          PMBR
           1           1          Pri GPT header
           2          32          Pri GPT table
    31537119          32          Sec GPT table
    31537151           1          Sec GPT header
cgpt add /dev/mmcblk0 -i 6 -b 34 -s 32768 -t kernel -l KERN-C -P 1 -T 1

The size of partition #7 here is the beginning sector of "Sec GPT table" (31537119) MINUS the beginning sector of partition #7 (32802).  Yes, the font is very tiny, but it preserves the appearance of the output.

cgpt add /dev/mmcblk0 -i 7 -b 32802 -s 31504317 -t rootfs -l ROOT-C
cgpt show /dev/mmcblk0
       start        size    part  contents
           0           1          PMBR
           1           1          Pri GPT header
           2          32          Pri GPT table
          34       32768       6  Label: "KERN-C"
                                  Type: ChromeOS kernel
                                  UUID: B6BF18B8-5B01-384F-AA69-7AD61AB56646
                                  Attr: priority=1 tries=1 successful=0
       32802    31504317       7  Label: "ROOT-C"
                                  Type: ChromeOS rootfs
                                  UUID: F33BC249-4577-D94A-8B7B-5B13D68DE423
    31537119          32          Sec GPT table
    31537151           1          Sec GPT header

Please note that (at least on the C7) although you can use the built-in card reader to create such media, you may be unable to boot from it without an external USB card reader.  At least, I haven't been able to.  So, it may be more practical to simply use a thumb drive. See Tip #3 for a theory.

     B. Create a debugging-enabled kernel from the current kernel, copy it to partition #6 and prioritize it to boot once.  See Tip #2 for an explanation here.

rootdev -s
    /dev/sda3
dd if=/dev/sda2 of=kernel_2.blob
dump_kernel_config kernel_2.blob > kernel_2.cfg
cp kernel_2.cfg kernel_debug.cfg

Now, replace the contents of kernel_debug.cfg with the following:

add_efi_memmap 
boot=local 
console=tty1 
disablevmx=off 
i915.modeset=1 
init=/sbin/init 
kern_guid=%U 
loglevel=7 
lsm.module_locking=0 
rw 
root=PARTUUID=%U/PARTNROFF=1 
rootwait 
tpm_tis.force=1 
tpm_tis.interrupts=0

These are commandline arguments passed to the kernel, so they should only be separated by spaces.  Here, I've alphabetized them on separate lines for clarity.  Now, wrap the new kernel with the verified block and  the new config:

vbutil_kernel --repack kernel_debug.blob \
  --keyblock /usr/share/vboot/devkeys/kernel.keyblock \
  --version 1 \
  --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
  --config=kernel_debug.cfg \
  --oldblob kernel_2.blob

Make sure the new kernel verifies OK and finally copy it to partition #6 and prioritize it.

vbutil_kernel --verify kernel_debug.blob
dd if=kernel_debug.blob of=/dev/mmcblk0p6
cgpt add /dev/mmcblk0 -i 6 -P 1 -T 1

     C. Boot your chosen distro on another machine (real or virtual) and install it onto partition #7 of your bootable media.  In some cases, you may need to create a filesystem on partition #7 prior to the installation, so I do just in case.  I've used both Ext2 and Ext4 successfully.  Either skip installing a bootloader or attempt to place the bootloader on partition #7.  I assume the distro must support GPT disks in order for this to work.

     D. Double check the GPT partition table for any changes that might prevent booting.

     E. Copy the necessary stuff from the current Chrome OS rootfs to partition #7.  Include the following complete folders:

/lib/firmware
/lib/modules
/usr/share/vboot

And these files as well:

/usr/bin/cgpt
/usr/bin/dump_kernel_config
/usr/bin/vbutil_*

Overkill perhaps, but handy for working on kernels from Linux too.

     F. Cross your fingers, reboot & attempt to boot from USB.  If it boots, reprioritize partition #6 and mark it as having booted successfully.

cgpt add /dev/sdb -i 6 -P 1 -T 0 -S 1


I adapted this method from the technique published by Olof Johannson, a member of the Chrome OS development team.

46 comments:

  1. In step E how do you know what the necessary stuff from rootfs is> I am currently at this step trying to install Kali on the C7.

    ReplyDelete
    Replies
    1. Sorry bud, I guess it's not quite as obvious as I thought that the document is still incomplete. Please stand by ...

      Delete
    2. Did you ever get Kali working on the C7?

      Delete
    3. I was able to make it through the "setup" phases successfully, but then tried the installation of Kali Linux 1.0.3 i386 to my partition #7. Does not want to boot on my Acer C710-2487 ... just here the "single beep" when I hit CTRL+u on startup.

      Anyone else have any luck trying to get Kali up? This would really be a great test environment, so I am hoping that we can get this working in the near future!

      Delete
    4. More often than not, the single beep is in response to a problem with the kernel on partition #6. Check the Priority, Tries and Successful fields with "sudo cgpt show /dev/sdb". If they're o.k., then try copying the kernel to sdb6 again, occasionally the write fails without producing an error message.

      Delete
    5. Thanks Barry ... I re-checked the settings and all appears to be fine:

      localhost user # cgpt show /dev/sdb
      start size part contents
      0 1 PMBR
      1 1 Pri GPT header
      2 32 Pri GPT table
      34 32768 6 Label: "KERN-C"
      Type: ChromeOS kernel
      UUID: 038B9391-4FC9-774D-8BAE-CCC5E4C8D3B0
      Attr: priority=1 tries=1 successful=0
      32802 31293373 7 Label: "ROOT-C"
      Type: Linux data
      UUID: 002E440B-723B-3544-B875-2F5F4B77B82F
      31326175 32 Sec GPT table
      31326207 1 Sec GPT header

      One point I want to confirm ... in Step B, should you "completely replace" the contents of kernel_debug.cfg with those listed, or just make sure these settings are included in the file?

      One final thing is that when I looked at the "new" kernel file created (kernel_debug.blob), it is only 3.3M versus 16M of the original one extracted from the ChromeOS image. Is this correct?

      localhost user # ls -lh
      -rw-r--r-- 1 root root 16M Jul 14 09:59 kernel_2.blob
      -rw-r--r-- 1 root root 663 Jul 14 10:00 kernel_2.cfg
      -rw-r--r-- 1 root root 3.3M Jul 15 06:40 kernel_debug.blob
      -rw-r--r-- 1 root root 208 Jul 15 06:38 kernel_debug.cfg

      Delete
    6. Yes, the size of the kernel is correct - copying it with dd takes the whole partition - not just the kernel itself. Yes, kernel_debug.cfg should contain only the arguments listed.

      The problem is partition #7 being "Type: Linux data." This happens when something other than cgpt modifies the disk. Try "cgpt add /dev/sdb -i 7 -t rootfs" to fix it. Then it should be "Type: ChromeOS rootfs" and the kernel should recognize & boot it.

      Delete
  2. Also in instruction B you might want to explain why you typed the rootdev -s and get the result /dev/sda3 and then sent all the commands through /dev/sda2. Also in instruction C do we add the boot flag or leave off? Finally what are the commands for instruction F.

    ReplyDelete
    Replies
    1. OK, I think I've filled in the missing details, at least enough for you to complete your task. Thanks for the feedback! AFAIK, the GPT partition table or cgpt or both don't support a "bootable" flag, so I'm kinda lost on that question.

      Delete
  3. Thank you I will give this a shot tonight/tomorrow and let you know how it goes.

    ReplyDelete
  4. May you please make a video tutorial.....and add some screenshots if you may.....and thanks for the blog many chromebook users that use the Acer C7 are looking for alternative OS.

    ReplyDelete
    Replies
    1. Thanks for your suggestions. I appreciate feedback of any kind! However, I think I may have failed to clearly articulate my intentions here. After following the ChrUbuntu Blog for the first few months of it's existence, I concluded that making something like this do-able by the average user is clearly a bad idea. IMHO, the average user will be far better off sticking with Chrome OS. Google has done a remarkable job keeping it simple and virtually bullet-proof!

      I post this information only for geeks (like me) who want to explore using a chromebook as more than a web appliance.

      Delete
  5. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I agree completely - the C7 has incredible potential! I would truly like to see one in the hands of every kid in public school!

      And I have come to realize that booting Linux from USB can be accomplished with minimal risk to the SSD/HDD. In addition, the relative ease with which a chromebook can be "un-bricked" changes the landscape somewhat.

      I still hope to find a "worthy" distro (that isn't too bloated to run well from usb) that I can safely release as a bootable image "For Everyone."

      To clarify again, I was trying to say that my experimental methodology should not be attempted by the "average user." Thanks so much for the feedback!

      Delete
    2. Try Puppy Linux Precise 5.5 (Ubuntu based). It is small, normally runs entirely out of RAM=very fast and is VERY feature rich! Runs great from a USB stick on most any traditional 32bit x86 machine. After initial configuration, Puppy can even be booted from a hardware write-locked USB stick.

      Delete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. A spamming troll plugging an official Acer retail channel?!? Very disturbing!

      In response, I'd like to suggest that folks living down under find a vendor through Google: http://www.google.com.au/intl/en/chrome/devices/

      Delete
  7. Hey Barry S. Schultz,
    so I've made it far enough to the point of which I made it to this step in your tutorial......I'm using an 8 G.B. falshdrive I'm trying to install LMDE XFCE on my acer chromebook C7


    rootdev -s
    /dev/sda5
    dd if=/dev/sda4 of=kernel_2.blob
    dump_kernel_config kernel_2.blob > kernel_2.cfg
    cp kernel_2.cfg kernel_debug.cfg


    Now, replace the contents of kernel_debug.cfg with the following:

    CODE: SELECT ALL
    add_efi_memmap
    boot=local
    console=tty1
    disablevmx=off
    i915.modeset=1
    init=/sbin/init
    kern_guid=%U
    loglevel=7
    lsm.module_locking=0
    ro
    root=PARTUUID=%U/PARTNROFF=1
    rootwait
    tpm_tis.force=1
    tpm_tis.interrupts=0

    Essentially how do I replace the "CONTENTS OF THE KERNEL_DEBUG.CFG" do I use Bash >>>>>> OR is their some other way.......

    ReplyDelete
  8. Sorry about the delay ... HDD boot failure on my desktop. Short answer:

    Any way you can! Because I find Linux's command line text editors hideously archaic, I refuse to use them. So, I copied the file to a flash drive and edited it from Ubuntu. If you must use Windows, "Ted Notepad" is great & Unix compatible: http://jsimlo.sk/notepad/

    ReplyDelete
    Replies
    1. Thanks Barry... I used the built in vim in Chrome OS, edited it and successfully verified the kernel.

      "Boot your chosen distro on another machine (real or virtual) and install it onto partition #7 of your bootable media. In some cases, you may need to create a filesystem on partition #7 prior to the installation, so I do just in case. I've used both Ext2 and Ext4 successfully. Either skip installing a bootloader or attempt to place the bootloader on partition #7. I assume the distro must support GPT disks in order for this to work."

      When you refer to install on partition #7 are you still using the command line to install the os on the ssd card or did you boot the live environment and used the installer to install it on the partition, like maybe for lmde xfce you used gparted to format the partition for the rootfs.....or did you go "sudo mkfs.ext4 /dev/sdX3" and then installed it.



      Delete
    2. Vim?!? You, sir, are a braver hacker than I!

      I use cgpt exclusively to create/manipulate the partitions, because CrOS doesn't seem to like gparted. I've used gparted and/or ubuntu's disk utility to format the partition for the rootfs, but whenever I tried to shrink, grow or move partitions with gparted, the media subsequently failed to boot.

      In every case so far, I installed from a Live CD. BTW, you are aware that the C7 won't boot from an SD card in the on-board card slot?

      Delete
  9. Yes, I am aware that it will no boot from the on-board card slot, I'm using a USB, by the way have you used a USB flashdrive to boot a different Linux O.S. using the method you posted on this blog, also I've noticed that

    "cgpt show /dev/mmcblk0

    start size part contents
    0 1 PMBR
    1 1 Pri GPT header
    2 32 Pri GPT table
    34 32768 6 Label: "KERN-C"
    Type: ChromeOS kernel
    UUID: B6BF18B8-5B01-384F-AA69-7AD61AB56646
    Attr: priority=1 tries=1 successful=0
    32802 31504317 7 Label: "ROOT-C"
    Type: ChromeOS rootfs
    UUID: F33BC249-4577-D94A-8B7B-5B13D68DE423
    31537119 32 Sec GPT table
    31537151 1 Sec GPT header



    are in fact just two different partitions one for the kernel and another for the rootfs, did you install the rootfs with a bootloader

    also when I attempt to view it on gparted I get a bug error when attempting to view the usb drive maybe its because it doesnt recognize the partitions created by cgpt in chrome os....

    ReplyDelete
    Replies
    1. Yes, I've used a variety of thumb drives (4GB, 16GB & 32GB) to boot various Linux distros, Chrome OS & Hexxeh's Chromium OS.

      Correct, only 2 partitions are needed for Linux (ChromeOS also requires a STATEful partition). I number them 6 & 7 simply for compatibility with the HDD layout. A bootloader is not used, but if the distro's installer insists, it can be installed safely ONLY on the rootfs partition (#7). Which, of course, is frowned upon!

      Gparted squawks at partitions of type "ChromeOS kernel" on the HDD as well.

      Delete
  10. "Gparted squawks at partitions of type......."

    Indeed it does when I was at the final stages of installing lmde xfce on the flashdrive after successfully verifying the kernel, on my other computer it did not recognize the partitions on the flashdrive even though they were in the exact same format as the one on your blog, so I ended up with two seperate partitions one for the kernel which gparted did not recognize and I could not open with a file manager to verify that it had a linux kernel inside and a second one on which lmde was going to be installed, I opened gparted to format the second one, it asked me if it was a gpt partition and that it was invalid something related to the msdos partition table....so I answered yes formatted the second partition proceeded to install lmde on that partition but it did not boot, despite my acer c7 chromebook being on developer mode and usb boot enable......where did I go wrong.......or did gpart screw me over

    ReplyDelete
    Replies
    1. There shouldn't be anything MS-DOSish on that media. Examine it with "cgpt show" and see if it still looks correct. Most likely, the P and T flags have been zeroed. If not, you can try "cgpt repair" or rebuild the GPT data by re-entering the commands again. As long as the partitions themselves are intact, I've been able to recover from a "gparted repair."

      But, it would probably be safer to format from the command line. Sorry, my bad. I just HATE having to look up syntax!

      In short, don't let gparted touch anything except the rootfs partition. At this point, gparted doesn't know what it's doing with CrOS, but this will surely change in time.

      Delete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. Hi, I love this post. Thank you. I've been using it to attempt to get a distribution that will work with my RTL8187 Wireless Adapter running, and although I've been unsuccessful so far (about to try Backbox, which I'm hopeful with) it's been a great experience.

    Anyway, the comments so far have helped almost as much as the post itself. I hate VIM (with a passion) and transferring it is kind of a long process, so here's an easy way to pass those options to kernel_debug.cfg:

    echo "" > kernel_debug.cfg
    echo "add_efi_memmap boot=local console=tty1 disablevmx=off i915.modeset=1 init=/sbin/init kern_guid=%U loglevel=7 lsm.module_locking=0 ro root=PARTUUID=%U/PARTNROFF=1 rootwait tpm_tis.force=1 tpm_tis.interrupts=0" > kernel_debug.cfg

    Thanks again for this post, I'm learning so much about using Linux because of this post and my Acer C7.

    ReplyDelete
    Replies
    1. Great hint and Thank you! Comments like yours make this exercise most gratifying.

      Yeah, I have a sort-of mental block where the command line in general (and echo in particular) are concerned. They can re-activate my PTSD from MS-DOS and the flashbacks are a real PITA! Just kidding, of course.

      Delete
  13. Hello Barry

    I'm just enjoining all the comments and reading the whole thing before attempting to install slackware on this thing. My chromebook arrived 2 days ago.

    I assume you haven't tried slackware linux as it is not listed on your spreadsheet..?

    ReplyDelete
    Replies
    1. You are correct. Although, I think I've tried a derivative or two without success.

      Delete
  14. well

    slackware stable tree doens't support uefi boot... I'm sure the port was based on an older stable tree.

    ReplyDelete
    Replies
    1. Might be worth a try then. Technically speaking, I don't think the 2nd generation x86 Chromebooks (like the C7) use UEFI, but IDK how verified boot might interact with such support.

      Delete
  15. I already downloaded slackware 14 tree.. my issue is that i can't find a decent usb key.... everything i have is 1 gb.

    My old 8 gb thumbdrive died and i have a couple of USB hard disk with bunch of data... in other words.. I'll be shopping one this weekend.

    my uefi statemet was wrong as slackware is fully capable of booting from uefi after a couple of tweaks after version 13.37...

    I'll report back after my first attempt.

    ReplyDelete
  16. Ok guys... this is my first report.

    I did the whole thin on the chromebook and I finally got the system to boot; but not following your method. I used a usb thumb drive and the dd=if kernel of=/dev/sdbp6 didn't write anything on the usbkey...

    I ended doing the partitions on gdisk and re-prioritizing etc with cgpt. it booted from the thumbdrive giving me a kernel panic.

    ReplyDelete
  17. The Bootable Media Toolbox is the preferred method now. It's easier and much faster to create. I'm sorry, I assumed you were aware of it. Start at the Home page with the link below.

    ReplyDelete
  18. well
    i don't have an ubuntu system with me other that this chromebook with a basic croutons install...

    anyways, my usb thumbdrive boots... but give me a kernel panic, which means I'm halfway there... some parameter must be wrong, or just the system won't boot.

    either way, i'm attemping this later as the wife took the slack/win netbook with her.

    ReplyDelete
    Replies
    1. I think Crouton will work wherever Debian/Ubuntu is needed (i.e. installing gdiskdump.deb, etc.) but is less convenient than ChrUbuntu because I don't think it provides access to the Chrome OS utilities (i.e. cgpt, etc.) OOTB. So you'd have to jump back and forth from Chrome to Crouton to Chrome in order to complete the process.

      You'll still need another machine to boot Linux and install it on your media, but with a Live CD/DVD/USB, even a Windows box can serve that purpose.

      I wish I could be more helpful. However, since I don't know how you arrived at a kernel panic, I can't really provide any insight. But, good luck & please keep us posted!

      Delete
  19. well
    i managed to boot.... which makes me have mixed feelings about this.


    i got last night the installpkg script to install on the device the slack tree... However, username/pass and other conf were not done. chomebook booted from usb on single user mode and as soon as i reboot it doesnt want to boot from usbkey anymore...

    have to dd the kernel again in order to boot from it (in single user mode again)... but it did boot.

    this is the way it is with slackware always. Not pritty at all; but once it's done, a fairly powerful machine with rock solid stability.

    i was very happy and pleased with my lame asus 1005ha; so imagine how exited i am with the real possibility of slack this chromebook

    ReplyDelete
  20. by the way
    the panic was related to me not labling the kernel partition as 6. i blow the partition on gdisk and created a new set name 6 and 7 and it went thru. i thought it would work no matter the partition name.

    ReplyDelete
  21. update:

    TOTAL WIN!

    I'm writing this from firefox on kde from slackware 14 booted from my kingston data traveler 2.0.1


    Happens that, as the system who i used to run the installpkg script didn't mount the thumbdrive as sdb, the /etc/fstab file was pointing to somewhere else. That's why it gave me the single user... because the partition was mounted as read only.

    I rebooted my brain and saw that i didn't marked the partition as successfully booted, so that took care of the boot once thing... and editing the fstab file in vim on the chromebook did the trick.


    now... i wonder how i could "dual boot" this without the need of a thumbdrive...

    ReplyDelete
    Replies
    1. If you were using media built with my toolbox and had ChrUbuntu installed on HDD, you could simply copy partitions #6 & #7 from USB to the same slots on the HDD, overwriting ChrUbuntu. Once the OS is booting from HDD, you can translate my logic used to expand the rootfs partition on bootable media to the HDD.

      In fact, this is the course of action I would recommend. The "dual-boot" scenario has been explored fully with ChrUbuntu.

      Of course, you could also re-partition the hard drive manually but I'd still recommend studying Jay Lee's ChurUbuntu install script first. Re-partitioning a Chrome HDD frequently leaves it un-bootable requiring a Chrome Restore which wipes the drive clean and then you must start all over again. If you choose this course of action, the only real advice I can give you is to use nothing but cgpt on a Chrome HDD.

      Delete
  22. Well

    I'll definitely try the chrubuntu script and pass the partitions... if something goes horribly wrong I already have a usb thumbdrive with a recovery image to leave everything factory default.


    I assume i'll have to dd the kernel to sda as my thumbdrive partition 6 have like 30 mb.

    I'll like to point out that performance is pretty good... and mind that i'm running kde 4.85 with full eye candy. This machine is amazing... i'm starting to love my chromebook :D

    ReplyDelete
  23. This chrubuntu script is elegant... but been me ofcourse i didn't use it.

    :D

    I ran the cgt part to repartition the hdd and dd the kernel into partition 6... then boot from my already made bootable usb and install fresh on sda7.


    ReplyDelete
  24. I forgot to mention..

    I'm runnint Version 29.0.1547.70, and the cgt script on /usr/bin is some kind of a soft link... you need to pass over the /usr/bin/old_bins folder.

    ReplyDelete
  25. Hi, I ran the sudo /usr/share/vboot/bin/make_dev_ssd.sh --force --remove_rootfs_verification command in my chromebook, now it's stuck at a black screen, and the fan turns on. nbo booting is happening. what did I do wrong?

    ReplyDelete
  26. I'm afraid that I don't know. I'm not familiar with that script and I've never even owned a laptop with an SSD. What were you attempting to do?

    ReplyDelete