The creation of SD card is a recurrent problem when, for instance, you will install a new raspberry pi.

The command line is a good solution for several reason:

  • If you must do the action only one time, it's useless to install a graphical interface.
  • On a server or on a live installation, you should not have a graphical interface. Only a terminal.
  • It's a good thing to understand a command line !
  • You can automatize it !

You might need administration right to execute some command. Use sudo command to upgrade your rights.

Get image

The first step is getting a disk image to install on your SD card.

For instance for a raspbian image, download it with the command:


and unzip the file. You will have a new file like: 2020-02-13-raspbian-buster-lite.img

Find your SD card

After the insertion of your SD card in your device, you must find it. The most simple way is this command:

sudo ls -ltr /dev/

You will have a list like:

brw-rw----   1 root  disk        7,  23 mars  19 20:37 loop23
brw-rw----   1 root  disk        7,  24 mars  19 20:37 loop24
brw-rw----   1 root  disk        7,  25 mars  19 20:37 loop25
brw-rw----   1 root  disk        7,   7 mars  19 20:37 loop7
brw-rw----   1 root  disk        7,   2 mars  19 20:37 loop2
brw-rw----   1 root  disk        7,   6 mars  19 20:37 loop6
brw-rw----   1 root  disk        7,   9 mars  19 20:37 loop9
drwxr-xr-x   4 root  root           440 mars  20 17:58 snd
drwxr-xr-x   4 root  root           480 mars  20 17:58 input
crw-------   1 root  root      243,   5 mars  20 17:58 hidraw5
drwxr-xr-x   2 root  root          5260 mars  20 17:58 char
**brw-rw----   1 root  disk        8,  32 mars  21 20:38 sdc
brw-rw----   1 root  disk        8,  33 mars  21 20:38 sdc1
brw-rw----   1 root  disk        8,  34 mars  21 20:38 sdc2**
drwxr-xr-x   2 root  root           860 mars  21 20:38 block
crw-rw-rw-   1 root  tty         5,   0 mars  21 20:38 tty
crw-rw-rw-   1 root  tty         5,   2 mars  21 20:38 ptmx
drwxrwxrwt   2 root  root            40 mars  21 20:38 shm

The card name will appear like mm* or sd*. (In bold on in above example).

If the name appear several time with a digit at the end, you must use the name without digit: sdc in my case.

The digit specify the partition on card, we want use the entire card

Copy the image on SD card

We will use the command dd to copy the image on the SD card:

sudo dd bs=1M if=your_image_pathfile of=/dev/your_card_name status=progress conv=fsync

In my case the command is:

sudo dd bs=1M if=./2020-02-13-raspbian-buster-lite.img of=/dev/sdc status=progress conv=fsync

The command parameters are:

  • bs=1M : read and write up to 1M bytes at a time
  • if=./2020-02-13-raspbian-buster-lite.img : read from ./2020-02-13-raspbian-buster-lite.img instead of stdin
  • of=/dev/sdc : write to /dev/sdc instead of stdout
  • status=progress : The LEVEL of information to print to stderr; 'progress' shows periodic transfer statistics
  • conv=fsync : convert the file as per the comma separated symbol list

Now your SD card is ready to used !

Next Post Previous Post