Saturday, March 07, 2015

Burning RASPBIAN Linux image onto micro sd card

Recently I got Raspberry PI 2 and I got around to burning RASPBIAN image onto micro SD card.

Here is a step by step guide what I did:

Please note that the use of the dd tool can overwrite any partition of your machine. If you specify the wrong device in the instructions below you could delete your primary Linux partition. Please be careful.
  • Run df -h to see what devices are currently mounted.
  • Insert the micro sd card into 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.On my machine it was listed as /dev/sdb1 . The last part (i.e. 1) is the partition number.
  • Run umount /dev/sdb1 
  • In the terminal, write the image to the card with the command:
sudo dd bs=4M if=2015-02-16-raspbian-wheezy.img of=/dev/sdb
  • Run sync to ensure the write cache is flushed and that it is safe to unmount your SD card.
  • Remove the SD card from the card reader.

I did this all in Virtualbox VM, therefore did not have hard disk space in the VM to dd-ing from the micro SD card back to another image on my hard disk.If I had the hard disk space in the VM I would have done the following to check what had be writtten to the SD card:
sudo dd bs=4M if=/dev/sdb of=from-sd-card.img
sudo truncate --reference 2015-02-16-raspbian-wheezy.img from-sd-card.img
diff -s from-sd-card.img 2015-02-16-raspbian-wheezy.img

diff should report that the files are identical.

No comments: