Raspberry Pi - Teach, learn, make !


Minimal Debian setup on a Raspberry Pi 4


Some context data :

"Install" Debian on the SDCard

The steps below are executed on your workstation, you can leave your Raspberry Pi board aside for the moment.
  1. download the Debian image matching your hardware as well as the corresponding SHA256 checksum file
  2. check the downloaded file :
    sha256sum -c 20200909_raspi_4.xz.sha256
    20200909_raspi_4.img.xz: OK
  3. identify the SDCard :
    • Do this before and after plugging the SDCard into your card reader, the device that will appear is the SDCard :
      sda               8:0    0 111.8G  0 disk
      ├─sda1            8:1    0  55.9G  0 part /
      └─sda2            8:2    0   7.5G  0 part [SWAP]
      sdb               8:16   0   3.7T  0 disk
      └─sdb1            8:17   0   3.7T  0 part
        ├─myLVM-homes 254:0    0     4T  0 lvm  /home
      sde               8:64   1  28.9G  0 disk		here it is!
      ├─sde1            8:65   1   299M  0 part
      └─sde2            8:66   1  28.6G  0 part
    • Alternate method, as root :
      tail -f /var/log/messages
      Sep 14 20:06:52 myWorkstation kernel: [ 9592.290555] sd 8:0:0:0: [sde] 15687680 512-byte logical blocks: (8.03 GB/7.48 GiB)
      Sep 14 20:06:52 myWorkstation kernel: [ 9592.291638] sd 8:0:0:0: [sde] Write Protect is off
      Sep 14 20:06:52 myWorkstation kernel: [ 9592.292758] sd 8:0:0:0: [sde] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
      Sep 14 20:06:52 myWorkstation kernel: [ 9592.319790]  sde: sde1 sde2
      Sep 14 20:06:52 myWorkstation kernel: [ 9592.324091] sd 8:0:0:0: [sde] Attached SCSI removable disk
  4. "flash" the image to the SDCard, as root :
    xzcat 20200909_raspi_4.img.xz | dd of=/dev/sde bs=64k oflag=dsync status=progress

Boot your Raspberry Pi

  1. place the SDCard into its slot
  2. connect keyboard + mouse + monitor
  3. plug the AC adapter : the boot starts
  4. the system LED will turn on :
    1. red + green (both solid)
    2. solid red + blinking green
    3. solid red
    4. both off

After the boot

  1. You should get a prompt like :
    Debian GNU/Linux 10 rpi4-20200909 tty1
    rpi4-20200909 login: 
    login : root, password : no password (source)
  2. configure the keyboard layout
  3. make everything up-to-date :
    apt update && apt upgrade && apt dist-upgrade
  4. make the SSH configuration very unsecure :
    echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
    echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config
    sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
    systemctl restart ssh
    no need to change PasswordAuthentication since it defaults to yes
  5. open an SSH session from another computer :
    ssh -F /dev/null root@ip.address.of.raspberry
    You should be instantly logged in as root with no password prompt.

Make a backup image

At that time, you may be pretty excited to start playing with your new Raspberry Pi and start building things (manually or with tools like Ansible and the likes).

However, experience proves that sooner or later, you'll try something we'll see if it works and break everything (). The only solution will then be to restart from the beginning :

  1. flash the image on the SDCard
  2. configure the keyboard layout
  3. make the system updates
  4. make the minimal sshd setup
Making an image of the SDCard right now will backup its current state, and should things break bad, you'll just have to "reflash" it and save these manual steps.

dd status=progress bs=64k if=/dev/sde | xz > path/to/myImage.img.xz