Difference between revisions of "Flashing Linux to SD Card"

From Dejvino's Knowledge Base
Jump to navigation Jump to search
(Created page with "How to flash Linux onto an SD Card? <pre>dd if=file.img of=/dev/sdx bs=4M status=progress</pre> where /dev/sdx is the SD Card block device (NOT a partition, the whole thi...")
 
Line 3: Line 3:
 
<pre>dd if=file.img of=/dev/sdx bs=4M status=progress</pre>
 
<pre>dd if=file.img of=/dev/sdx bs=4M status=progress</pre>
 
where /dev/sdx is the SD Card block device (NOT a partition, the whole thing!).
 
where /dev/sdx is the SD Card block device (NOT a partition, the whole thing!).
 +
 +
=== Clearing an SD Card ===
 +
The following clears the start and the end of an SD Card (or any block device in general).
 +
 +
<code>
 +
SD_CARD_DEVICE=/dev/sdX
 +
sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 count=1024
 +
sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 seek=$(( $(blockdev --getsz $SD_CARD_DEVICE) - 1024 )) count=1024
 +
</code>

Revision as of 05:43, 14 April 2020

How to flash Linux onto an SD Card?

dd if=file.img of=/dev/sdx bs=4M status=progress

where /dev/sdx is the SD Card block device (NOT a partition, the whole thing!).

Clearing an SD Card

The following clears the start and the end of an SD Card (or any block device in general).

SD_CARD_DEVICE=/dev/sdX sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 count=1024 sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 seek=$(( $(blockdev --getsz $SD_CARD_DEVICE) - 1024 )) count=1024