NERDBUDE

[ code. keyboards. terminals. cyber. ]

[HOWTO] [WHOAMI] [PODCAST] [GERMAN]


How to flash SD Cards


If you play around with small computers a lot, you also need operating systems that usually have to be flashed onto SD cards or micro SD cards. This process is quite simple and can be done under Linux or macOS with the same tools.

First we need to find out what name or address our SD card has. We do this as usual via the terminal:

shell
diskutil list


This command shows all mounted devices in your system:

output
/dev/disk0 (internal, physical): #: TYPE NAME SIZE ID 0: GUID_partition_scheme *251.0 GB disk0 1: EFI EFI 314.6 MB disk0s1 2: Apple_APFS Container disk1 250.0 GB disk0s2 /dev/disk2 (synthesized): #: TYPE NAME SIZE ID 0: SD CARD - +250.0 GB disk2s2


With this we already have the ID of our SD card. In this case "disk2". So that we can flash the OS on it, we must unmount the SD card. This is done with:

shell
diskutil unmountdisk disk2


As soon as you get the message that the SD card is unmounted, you can start flashing it. For this we use the tool dd which is preinstalled under macOS and Linux. ATTENTION: If you accidentally use the wrong ID, this can overwrite your entire internal hard drive and your data is gone. So better double assure before that you flash the right device!

shell
sudo dd if="/Pfad/zum/Image" of="/dev/disk2" bs=8m


What does "dd" do here? The parameter "if=" indicates the path to the OS image, the parameter "of=" points to the path to the SD card, and "bs=8m" is the block size at which the image is written to the SD card.

Don't be surprised if nothing happens in the terminal for a long time - "dd" does not show the status of the write process by default. Since version 8.24 of "dd" there is probably the possibility to display the status - I have not tried it myself yet. With status the command would look like this:

shell
sudo dd if="/Pfad/zum/Image" of="/dev/disk2" bs=8m status=progress


If "dd" is rattled through you will get a message that looks similar to this one:

output
12780+0 records in 12780+0 records out 6543360 bytes (6.4 MB) copied, 5.9723 seconds, 1 MB/s


Once the flashing is complete, the SD card can be inserted into your Raspberry Pi or similar computer and you are ready to go.



//EOF