Lamp Coder

Web development & stuff

Make bootable micro SD for Raspberry Pi 3

Posted by Vasilis on January 22, 2018

Before you proceed with your micro SD card I suggest to check which cards work/dont work in raspberry

Preparing the SD card

Detect the card with this command

sudo fdisk -l

You can run the command once before you connect the SD card and again after you plug it. So  you can detect it easily. You may see a result like this.

Disk /dev/sdb: 1.9 GiB, 2002780160 bytes, 3911680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9d4c0628

We found that device is /dev/sdb, easy recognizable from its size.

Maybe you want to unmout the partition first with

umount /dev/sdb1


Now let's go format it with the command 

fdisk /dev/sdb

You enter the utility of fdsik

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help):

With m you can see all the commands you can use.

We use d to delete a partition (it may autosect it).

With p we list the partition and make sure that there no partition left in the drive.

Now we go to create a new partition, we  type n:

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-3911679, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-3911679, default 3911679): 

Created a new partition 1 of type 'Linux' and of size 1.9 GiB.

Command (m for help):

The new partition created is 'Linux' type, we want to change it to W95 FAT32 for the bootable disk.

We use the t command:

Command (m for help): t
Selected partition 1
Partition type (type L to list all types):

With L you can list all the available partition types and then select one. b is for W95 FAT32 and we get the response

Changed type of partition 'Linux' to 'W95 FAT32'.

In my case iI had to make sure that the bootable flag on the new partition is enabled. This is done with a command

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Now we are ready to write the partition. We do it with w

We changed the partitions but now we have to fromat it (the partition NOT the disk).

sudo mkfs.vfat /dev/sdb1

That's it, unplug the disk and plug it again. Now you can unplug it and plug it again to add the files on the disk.

Download the OS

On you download the operatiing system. For NOOBS you will have a .zip  file with the bootable file. You just unzip the files in the SD disk. Raspbian  is an .img file that has to be written on the disk, is an easy way to flash the image file on the disk.

Now you are ready to plug the SD disk on the raspberry's slot, plug the HDMI, mouse and keyboard and finally connect the power cable. Rasberry will automatically reboot.