Logicalwebhost Cheatsheet

Linux & Open Source Cheatsheets & Howto's

Skip to: Content | Sidebar | Footer

Raspberry Pi

Raspberry Pi is a project that provides a small (credit card size) computer that can run a desktop, server, or a project OS. When you get it, you have to load an Operating System, in this case we use Debian.

Install Raspbian (Debian) on Raspberry Pi 3

First, you have to put Rapsbian on a microSD, which you plug into your laptop on one of the USB ports with the tiny microSD-to-USB adapters you get for like $10.

On Linux, you just use dd to write the image, but first you have to download it from here, pick either the Desktop or Lite version. The Lite is a lot smaller.

Now, put the microSD in the USB-to-microSD adapter and plug it into your Linux laptop.

You have to figure out which drive it will show up, which you do by running:

fdisk -l
 
Disk /dev/sda: 75 GiB, 80530636800 bytes, 157286400 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: 0xb62bc1e8
 
Device     Boot     Start       End   Sectors Size Id Type
/dev/sda1  *         2048 148897791 148895744  71G 83 Linux
/dev/sda2       148897792 157286399   8388608   4G  5 Extended
/dev/sda5       148899840 157286399   8386560   4G 82 Linux swap / Solaris
 
Disk /dev/sdb: 119.1 GiB, 127865454592 bytes, 249737216 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: 0x00000000
 
Device     Boot Start       End   Sectors   Size Id Type
/dev/sdb1       32768 249737215 249704448 119.1G  7 HPFS/NTFS/exFAT

Okay, so you need to be REEEEEEALLY sure that you have the right drive when you want to format it and turn it into your Raspbian system. It’s common that the miroSD will be /dev/sdb1 (the first partition on that device), but certainly not always, yours could be /dev/sdc1 or something, you really have to know which one it is. In the command above, you can tell that /dev/sdb1 is the blank microSD, because mine is 128GB, which is close to what it says. You have to make sure the operating system hasn’t mounted that drive, so run:

umount /dev/sdb1
umount: /dev/sdb1: not mounted

Okay, mine isn’t mounted. So now you’re ready to put Raspbian on it. You should’ve downloaded something like 2017-09-07-raspbian-stretch-lite.zip, you have to unzip it and write it to your microSD. Since you’re overwriting the WHOLE disk, you just specify the disk like /dev/sdb, rather than the partition like /dev/sdb1, make sure not to skip that step.

cd /wherever/you/downloaded/it/
unzip 2017-09-07-raspbian-stretch-lite.zip
Archive:  2017-09-07-raspbian-stretch-lite.zip
  inflating: 2017-09-07-raspbian-stretch-lite.img
dd bs=4M if=2017-09-07-raspbian-stretch-lite.img of=/dev/sdb conv=fsync
442+1 records in
442+1 records out
1854590976 bytes (1.9 GB) copied, 147.045 s, 12.6 MB/s

This took about 5 minutes on my laptop, but it doesn’t look like it’s doing anything during that time, which is annoying. Whatever you do, DON”T STOP IT unless it just dies. Now I ran gparted so I can expand the new partition it made. First I stretched /dev/sdb2 to take up the whole rest of the drive. So you have to first select the /dev/sdb drive like:

Now resize the partition

Now drag the arrow to the right to fill up the space like:

Then hit “apply”

and confirm:

Now this will take awhile to actually do:

when it’s done, you can eject your USB/microSD and put it in the slot on the bottom of your Rapsberry Pi 3 and boot it!

the default user is ‘pi’ and the password is ‘raspberry’