The Ultimate RPi Installation Guide

From XPUB & Lens-Based wiki
Revision as of 22:01, 27 February 2017 by Aymeric Mansoux (talk | contribs)

TODO

  • Read about overclocking settings and apply if necessary
  • Some devices trigger an alternative browser to sign-in when it figures out it is a captive portal, it is useless for us, but bot sure if there is a way to redirect it back to the main browser (spotted on some Android devices, but not all)

Basic Setup

MINIBIAN installation

sudo dd bs=4M if=minibian.img of=/dev/sdc status=progress
  • Insert SD, Power the RPi, wait for crazy blinking to stop
  • Figure out what's the RPi IP (adjust mask to reflect own network)
nmap -sP 192.168.1.1-255
  • ssh into RPi (default MINIBIAN passwd is raspberry)
ssh root@192.168.1.73

Expand filesystem (optional)

This is optional. Indeed, depending on the application, the little room left on the minibian image might be just enough to add a couple software and config files. However, it is necessary if the kernel needs to be updated, as the process needs a bit more space than what we have by default. Also, you can repeat the process again at later stage if you need more space than the suggested 2GB total size in the example below. Just make sure you do not exceed the size of your medium/sdcard.

  • install parted utility
apt update
apt install parted
  • check that, indeed, it's a bit tight in there. The following command will show that the main system partition (partition 2 formatted as ext4) is roughly 700-800MB:
parted /dev/mmcblk0 --script print
  • run the same command with unit s, to get more precise information (sectors)
parted /dev/mmcblk0 --script unit s print
  • Note down the Start value of the partition Number 2. Here is an example:
 Number  Start     End       Size      Type     File system  Flags
  1      16s       125055s   125040s   primary  fat16
  2      125056s   1626111s  1501056s  primary  ext4

The value to remember in this example would be 125056s.

  • Delete partition 2, you will get an error and complaining about the need to reboot, IGNORE THIS
parted /dev/mmcblk0 --script rm 2
  • Double check that partition 2 is gone:
parted /dev/mmcblk0 --script print
  • Create a new partition that starts exactly at the point 125056s but goes until 2GB. Adjust the command with your own value. Ignore the warning for now.
parted /dev/mmcblk0 --script mkpart primary 125056s 2GiB
  • Check that new partition has been created
parted /dev/mmcblk0 --script print
  • Reboot to make the system aware of the changes
reboot
  • ssh back in and finally resize the filesystem to benefit from the expanded partition
resize2fs /dev/mmcblk0p2

Base system

  • flavouring
echo "BMO" > /etc/hostname
hostname -F /etc/hostname
  • what time is it
dpkg-reconfigure tzdata
  • don't bloat the system
echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' > /etc/apt/apt.conf.d/90norecommend
  • update system
apt update
apt upgrade
  • update to latest kernel
apt install rpi-update
rpi-update
reboot

Comfy environment (optional)

Now you can install all your comfy l33t command line tools and whatnot, fav editors, etc. This is just an example of what I (aymeric) always put on top of my pi, YMMV:

  • comfy tools and stuff
ln -s /usr/bin/vim.tiny /usr/bin/vim
apt-get install tmux tcsh ncurses-term git
chsh -s /bin/tcsh root
  • create /root/.tcshrc
if ($?prompt) then
      set prompt = "%N@%m:%~ %# "
      set promptchars = "%#"
      set filec
      set history = 1000
      set savehist = (1000 merge)
      set autolist = ambiguous
      set autoexpand
      set autorehash
      if ( $?tcsh ) then
              bindkey "^W" backward-delete-word
              bindkey -k up history-search-backward
              bindkey -k down history-search-forward
      endif
endif
  • logout and log back in

THIS IS IT!

Well done, you now have a minimal RPi installation, the guideline stops here, anything past this point is just a matter of what the RPi will be used for.

Extras

All the following steps are optional and depend on the use of the RPi.

Align Partitions

Only do it for production RPi setups and when the final medium/sdcard is chosen because it is hardware dependent. Skipping this part won't affect anything. In fact, most (if not all) standard RPi installations do not have proper partition alignment and most people do not know about it or care. To know why you should care and how it will affect performances, read https://superuser.com/questions/225936/what-does-it-mean-to-align-partitions.

Note: this operation can be done at any stage. So it can be skipped for now and done later if needed.

The partition that matters the most is /dev/mmcblk0p2, the one that contains the whole OS. On the RPi, it is possible to check if this partition is aligned:

parted /dev/mmcblk0 align-check optimal 2

The result is likely to be negative:

 2 not aligned

To fix this, the easiest way is to move the partition just a tiny bit and let parted do the math for correct alignment. There is catch though, because the partition will be moved, the data needs to be moved as well, and therefore the operation cannot be done live on the RPi, it must be done from another machine with the sdcard attached (directly or with a USB reader).

FIXME: need to write the rest :)

Read-only system

TODO

Making and Sharing images

TODO