Skip to content

prepare microSD card

Frank Bauernöppel edited this page Oct 14, 2018 · 63 revisions

Insert a microSD card (at least 4 GB) in the build host. All data on the card will be overwritten.

Attention: never remove a microSD card from a running Raspi. This may damage the file system. Shut the Raspi down first by executing halt.

In a shell, find the block device of the card:

frank@Mothership17Buntu:~/raspi/yocto/rocko/rpi-build$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 931,5G  0 disk 
└─sda1        8:1    0 931,5G  0 part /home
sdb           8:16   0   5,5T  0 disk 
├─sdb1        8:17   0   128M  0 part 
└─sdb2        8:18   0   5,5T  0 part 
sdc           8:32   0 931,5G  0 disk 
└─sdc1        8:33   0 931,5G  0 part 
sdd           8:48   1   7,2G  0 disk 
├─sdd1        8:49   1    40M  0 part /media/frank/raspberrypi
└─sdd2        8:50   1   7,2G  0 part /media/frank/dcd58811-d225-49a7-847b-1f06f4f2d387
sr0          11:0    1  1024M  0 rom  
nvme0n1     259:0    0 953,9G  0 disk 
├─nvme0n1p1 259:1    0   100M  0 part /boot/efi
├─nvme0n1p2 259:2    0   128M  0 part 
├─nvme0n1p3 259:3    0 476,6G  0 part 
├─nvme0n1p4 259:4    0   500M  0 part 
└─nvme0n1p5 259:5    0 476,6G  0 part /

In this case /dev/sdd is the block device for the card. Your mileage may vary, be careful.

Now, unmount the partition(s) of the card (if mounted):

sudo umount /dev/sdd?

And copy the SD card image to the card using dd. Change the name of the input file (if=) and the output file (of=) according to your system:

sudo dd if='/home/frank/raspi/yocto/rpi-build/tmp/deploy/images/raspberrypi3/rpi-avg-image-raspberrypi3.rpi-sdimg' of=/dev/sdd bs=4M iflag=fullblock oflag=direct conv=fsync status=progress

The status=progress option might not be available on your build host, see dd.

Writing the card takes a few minutes. The write speed will be around 5..20 MB/s.

When done, remove the card. You may

  • insert it into the RasPi for booting (see boot process or
  • re-insert it into the build host for inspection or manual corrections

The card should now be partitioned into a boot partition and a root partition and filled with all needed files.

Note: It is possible to partition (fdisk) and format the card manually and/or to update individual files or the whole root partition.