Sunday, 1 May 2016

How to Prepare Raspberry Pi SD Card on Google Chromebook / Chrome OS

If you are running Chrome OS (ie: a chromebook or chromebox) you can install raspbian to your SD card using the dd tool for linux. Please note that this method requires your computer to be in developer mode to gain access to your shell. If you don't already have your chromebook in dev mode check out How to enable developer mode Chromebook. Be aware that switching to dev mode will also reset your computer to factory defaults.

- Download and extract your raspbian image to your downloads folder from here

- Open the crosh terminal by pressing  Ctrl+Alt+T  on your keyboard

- Access the linux shell by typing  shell  at the prompt and pressing enter

- Run  df -h  to see what devices are currently mounted.

-If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer.

- Run  df -h  again. The new device that has appeared is your SD card. The left column gives the device name of your SD card; it will be listed as something like /dev/sdb1. The last part ( 1 respectively) is the partition number but you want to write to the whole SD card, not just one partition. Therefore you need to remove that part from the name (getting, for example, /dev/sdb) as the device for the whole SD card. Note that the SD card can show up more than once in the output of df; it will do this if you have previously written a Raspberry Pi image to this SD card, because the Raspberry Pi SD images have more than one partition.

-Now that you've noted what the device name is, you need to unmount it so that files can't be read or written to the SD card while you are copying over the SD image. Open the Files app in the start menu and look for the SD card on the left. (If you are using an sd card that already has raspberian installed you may have what appears as two cards. One for each partition. Right click on each and select Eject from the menu

- In the terminal window change directory to your downloads folder by entering  cd ~/Downloads/ 

- Your present working directory should look like /home/chronos/user/Downloads  and can be verified by entering  pwd 

- Write the image to the SD card  sudo dd bs=4 if=2015-11-21-raspbian-jessie-lite.img of=/dev/sdb  When using admin commands you may be prompted to enter the developer password for your chromebook. Depending on your version you may be able to hit enter and continue. If that doesn't work you can manually set the password with this command  sudo chromeos-setdevpasswd 

- From this point you can eject the SD card and load it up in you're raspberry pi. If you would like to verify the integrity of the SD card you can follow the remaining steps

- The dd command does not give any information of its progress and so may appear to have frozen; it could take more than five minutes to finish writing to the card. If your card reader has an LED it may blink during the write process. To see the progress of the copy operation you can run sudo pkill -USR1 -n -x dd in another terminal. The progress will be displayed in the original window and not the window with the pkill command; it may not display immediately, due to buffering.

- You can check what's written to the SD card by dd-ing from the card back to another image on your hard disk, truncating the new image to the same size as the original, and then running diff (or md5sum) on those two images. ie:  sudo dd bs=4 if=/dev/sdb of=from-sd-card.img  

sudo truncate --reference 2015-11-21-raspbian-jessie-lite.img from-sd-card.img
-  sudo truncate --reference 2015-11-21-raspbian-jessie-lite.img from-sd-card.img  

-  sync 

sudo truncate --reference 2015-11-21-raspbian-jessie-lite.img from-sd-card.img

This tutorial is an adaptation of the linux tutorial from and can be referenced here.