raspberry pi

2020-09-04 06:26

setup

recover forgotten password

  1. remove SD Card
  2. append init=/bin/sh to cmdline.txt
  3. $passwd
  4. if error: $mount -o remount,rw /dev/mmcblk0p2 /
  5. remove SD Card
  6. delete lines in cmdline.txt

setup with mac

help link

Wipe the SD card

$brew cask install sdformatter

SD Formatter > Overwrite

$diskutil list

Look for /dev/disk# (as opposed to /dev/disk#s#)

$diskutil unmountDisk /dev/disk#

Note the ‘r’

$sudo dd bs=1m if=image.img of=/dev/rdisk# conv=sync

Send a SIGINFO by pressing Ctrl-T to check progress

Optionally:

$sudo dd bs=1m if=image.img of=/dev/rdisk# conv=sync && say "DISK OPERATION
COMPLETE"

setup with linux

Installing on Linux

$lsblk

insert SD

$lsblk

$umount /dev/sda#

$unzip -p 2018-11-13-raspbian-stretch.zip | sudo dd of=/dev/sdX bs=4M
status=progress conv=fsync

raspbian install steps

username: pi
password: raspberry

$sudo raspi-config

Localization options > Change Locale to deselect en_GB.UTF-8 UTF-8 to select en_US.UTF-8 UTF-8 to select to accept to en_US.UTF-8 to select system language to accept

Localization options > Change Timezone to select America to select to confirm to select New York to select to confirm

Localization options > Change Wifi Country to select US United States to select to confirm

Localization options > Change Keyboard Layout Generic 105 Intl Other En (US) English (US) Ok Ok

Network Options > Wifi

Enter SSID
Enter passkey

Interfacing Options Enable SSH

Other commands

$setfont /usr/share/consolefonts/Uni3-Terminus32x16.psf.gz

$set -o vi

$history | tail -3 > ~/.bash_profile

$vi ~/.bash_profile

:%s/\v^\s+\d+\s+//

$find /etc/ -name *key*

$sudo sed -i 's_XKBOPTIONS=""_XKBOPTIONS="caps:escape"_'
/etc/default/keyboard && sudo setupcon

Network Setup

$sudo iwlist wlan0 scan | grep -i --color=always 'skynet' | less -R

$sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

network={
    ssid="testing"
    psk="testingPassword"
}
$sudo reboot

$ping www.google.com

$sudo apt-get update -y && sudo apt-get upgrade -y
cd /boot
touch ssh
sudo reboot

update

$sudo apt-get update -y && sudo apt-get upgrade -y

arch installation

$ lsblk
$ fdisk /dev/sdX

o -> p -> n,p,1,,+100M -> t,c -> n,p,2, -> w

$ mkfs.vfat /dev/sdX1
$ mkdir boot
$ mount /dev/sdX1
$ mkfs.ext4 /dev/sdX2
$ mkdir root
$ mount /dev/sdX2
$ su

$ wget http://os.archlinuxarm.org/os/ArchLinux-rpi-3-latest.tar.gz

$ bsdtar -xpf ArchLinuxArm-rpi* -C root
$ sync
$ mv root/boot/*
$ unmount boot root

At this point put the SD card in the raspberry pi using the default credentials

username: alarm
password: alarm

username: root
password: root

$ pacman-key --init
$ pacman-key --populate archlinuxarm

$ ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
$ hwclock --systohc -v

$ set -o vi
$ vi /etc/locale.gen

uncomment en_US.UTF-8 UTF-8

$ locale-gen

$ vi /etc/local.conf

LANG=en_US.UTF-8

$ vi /etc/hostname
$ vi /etc/hosts

$ useradd -m loganf
$ passwd loganf

$ userdel -r alarm

$ ifconfig wlan0 up
$ iwlist wlan0 scan | grep <ESSID>

$ vi /etc/wpa_supplicant.conf

ctrl_interface=/run/wpa_supplicant update config=1

$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

$ wpa_cli -i wlan0
> scan
> scan_results
> add_network
0
> set_network 0 ssid <ESSID>
> set_network 0 psk <PSK>
> enable_network 0
> save_config
> quit

$ dhcpcd wlan0

$ ifconfig wlan0

$ cat /etc/resolv.conf
$ ip route show
$ ping 8.8.8.8
$ ln -s /usr/share/dhcpcd/hooks/10-wpa_supplicant /usr/lib/dhcpcd/dhcp-hooks/

$ vi /etc/nsswitch.conf

comment out hostst, add resolve ahead of [!UNAVAIL]

$ resolvconf -u
$ pacman -Syu
$ pacman -S sudo
$ visudo

loganf ALL=(ALL) ALL

login as loganf

$ pacman -S basedevel
$ mkdir ~/source ; cd ~/source
$ sudo pacman -S git
$ git clone https://github.com/vim/vim
$ cd vim
$ make
$ sudo make install

$ echo $0

$ pacman -S zsh
$ echo "set -o vi" >> ~/.zshrc
$ echo 'export EDITOR="vim"' >> ~/.zshrc