Difference between revisions of "Flashing Linux to SD Card"

From Dejvino's Knowledge Base
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
The following clears the start and the end of an SD Card (or any block device in general).
 
The following clears the start and the end of an SD Card (or any block device in general).
  
<code>
+
<pre>
 
SD_CARD_DEVICE=/dev/sdX
 
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 count=1024
 
sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 seek=$(( $(blockdev --getsz $SD_CARD_DEVICE) - 1024 )) count=1024
 
sudo dd if=/dev/zero of=$SD_CARD_DEVICE bs=512 seek=$(( $(blockdev --getsz $SD_CARD_DEVICE) - 1024 )) count=1024
</code>
+
</pre>
 +
 
 +
=== Resizing an SD Card ===
 +
After flashing the image you might wish to resize your filesystem to use all of your eMMC or SD-card.
 +
 
 +
Open cfdisk to change the partition size:
 +
{{codeblock|1=sudo cfdisk /dev/mmcblkX}}
 +
 
 +
Select [Resize] and resize your partition to maximum. The select [Write] and accecpt with "yes". Select [Quit] to exit.
 +
 
 +
Clean the filesystem:
 +
{{codeblock|1=sudo e2fsck -fy /dev/mmblkXpX}}
 +
 
 +
Finally resize your partition:
 +
{{codeblock|1=sudo resize2fs /dev/mmblkXpX}}
 +
 
 +
Source: [https://gitlab.com/mobian1/wiki/-/wikis/Install]

Latest revision as of 20:54, 21 May 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

Resizing an SD Card

After flashing the image you might wish to resize your filesystem to use all of your eMMC or SD-card.

Open cfdisk to change the partition size: sudo cfdisk /dev/mmcblkX

Select [Resize] and resize your partition to maximum. The select [Write] and accecpt with "yes". Select [Quit] to exit.

Clean the filesystem: sudo e2fsck -fy /dev/mmblkXpX

Finally resize your partition: sudo resize2fs /dev/mmblkXpX

Source: [1]