This is how to write Raspbian OS image to SD card by using Linux command line. Since the steps below use “dd” command which may cause damage to your system if used wrongly, please be careful about the usage.
Contents
– Assumptions
– Steps
1. Download Raspbian OS Image
2. Find device name of SD card on Linux
3. Write Raspbian OS image to SD card
– Reference
- Raspberry Pi board
- Micro SD card
- Linux PC
- Micro SD card adapter
Steps
1. Download Raspbian OS Image
1-1. Download Raspbian OS zip archive from the official site to your Linux PC.
2. Find device name of SD card on Linux
2-1. Before insert SD card into your PC, check all the mounted devices by typing:
df -h
Output should be like this:
$ df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 789M 9.5M 780M 2% /run /dev/sda1 451G 17G 412G 4% / tmpfs 3.9G 61M 3.8G 2% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup tmpfs 789M 72K 789M 1% /run/user/1000
2-2. Then, insert the SD card and check it again.
$ df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 789M 9.5M 779M 2% /run /dev/sda1 451G 17G 412G 4% / tmpfs 3.9G 61M 3.8G 2% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup tmpfs 789M 72K 789M 1% /run/user/1000 /dev/sdb2 30G 8.4G 20G 31% /media/max/037616fd-28fe-4652-8248-2042ea30b929 /dev/sdb1 42M 21M 21M 51% /media/max/boot
2-3. Compare the outputs. Newly added device is for the SD card. Since the last part (“1”) is the partition number, the device name for whole SD card is /dev/sdb. Take a note of the device name.
2-4. Unmount the SD card partition(s). Type below, replacing /dev/sdb1 with your SD card device name.
umount /dev/sdb1
3. Write Raspbian OS image to SD card
3-1. Type below to unzip the archive and write it to SD card. Please replace “2017-08-16-raspbian-stretch.zip” with the file name of your OS image archive and “/dev/sdb” with your SD card device (see step 2-3).
unzip -p 2017-08-16-raspbian-stretch.zip | sudo dd of=/dev/sdb bs=4M status=progress conv=fsync
In case you are writing .img file, type below:
sudo dd bs=4M if=2017-08-16-raspbian-stretch.img of=/dev/sdb status=progress conv=fsync
Reference
– INSTALLING OPERATING SYSTEM IMAGES ON LINUX
https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
– RPi Easy SD Card Setup
http://elinux.org/RPi_Easy_SD_Card_Setup