Copy Image to a SD-Card
Tobias Müller, M. Eng edited this page 5 years ago

📜 Table of Contents


Copy Image to a SD-Card

This section describes how to copy the given Raspberry PI image-file to a SD-card. There is a Linux and a Windows instruction available.

Download-Link Raspberry Pi Image-File: https://gogs.es-lab.de/mueller_to/Xcom-API/src/master/Raspberry-Pi-Image

Linux Instruction

After downloading you need to unzip the image-file first, which can be done for example with the bash-command:

unzip Raspberry_Pi_Image.zip -d <destination_folder>

If "unzip" is not installed, you can install it with the bash-command:

sudo apt-get install unzip

Copying the image-file to a SD-Card will be done with the dd command.

Note: 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.

  • Insert a SD-Card into your computer with at least 8 GB storage capacity.
  • Run the bash-command:

  • df -h
    

    The left column of the results from df -h command gives the device name of your SD card. It will be listed as something like /dev/mmcblk0p1 or /dev/sdX1, where "X" is a lower case letter indicating the device. The last part (p1 or 1 respectively) is the partition number. You want to write to the whole SD card, not just one partition. You therefore need to remove that section from the name. You should see something like /dev/mmcblk0 or /dev/sdX as the device name 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 you have noted the device name, 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. So run the bash-command umount /dev/sdX1, replacing sdX1 with whatever your SD card's device name is, including the partition number. If your SD card shows up more than once in the output of df, this shows that the card has multiple partitions. You should unmount all of these partitions.
  • Now in a terminal window, write the image to the card with the command below, making sure you replace the input file if= argument with the path to your img file, and the /dev/sdX in the output file of= argument with the correct device name. This is very important, as you will lose all the data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card as described above, not just a partition. For example: sdd, not sdds1 or sddp1, and mmcblk0, not mmcblk0p1.

  • dd bs=4M if=Raspberry_Pi_Image.img of=/dev/mmcblk0 conv=fsync
    

    Note: The block size set to 4M will work most of the time. If not, try 1M, although this will take considerably longer. Also note that if you are not logged in as root you will need to prefix this with sudo.

  • After copying the image-file to the SD-Card, you can insert the SD-Card to your Raspberry Pi and boot it up [1].

Login-informations:
   Username: pi
   Password: iotraspi

The test-programs can you find under /home/pi/pythonapps.

Note: DHCP for the ethernet port of the Raspberry Pi has been disabled. The static ip-address is: 192.168.137.2. You can change this by opening the file /etc/dhcpcd.conf with an editor like "nano" and with admin privilege.

Windows Instruction

After downloading the image-file, you can unzip the archive with windows itself or with a third party tool like "7-ZIP".

Download-Link 7-ZIP: http://www.7-zip.de/

Now you need a tool called "Win32DiskImager" to copy the image-file to a SD-Card.

Download-Link Win32DiskImager: https://sourceforge.net/projects/win32diskimager/

The picture below shows the "Win32DiskImager".

  • Insert a SD-Card into your computer with at least 8 GB storage capacity.

  • In "Win32DiskImager" choose the image-file and the drive of your SD-Card.

  • Click on the button write (at the picture the german word "schreiben") to copy the image-file to the SD-Card.

  • After copying the image-file to the SD-Card, you can insert the SD-Card to your Raspberry Pi and boot it up

Login-informations:
   Username: pi
   Password: iotraspi

The test-programs can you find under /home/pi/pythonapps.

Note: DHCP for the ethernet port of the Raspberry Pi has been disabled. The static ip-address is: 192.168.137.2. You can change this by opening the file /etc/dhcpcd.conf with an editor like "nano" and with admin privilege.

References

    [1]  Raspberry Pi
           Installing operating system images on Linux
           https://www.raspberrypi.org/documentation/installation/installing-images/linux.md (20/08/2017)


Hochschule Anhalt | Anhalt University of Applied Sciences | Department 6 EMW
Xcom-API

Tobias Müller, M. Eng.
📧 Tobias.Mueller@HS-Anhalt.de

© es-lab.de, 31.10.2017