-
Notifications
You must be signed in to change notification settings - Fork 5
Raspberry Pi Notes
- SD Card Setup
- First Login
- Change the hostname on a Raspberry Pi
- Working with networking and Raspbian Stretch
- Resizing Partitions on a SD card running Raspbian
- Build a Cross-Compile Toolchain for Raspi using docker
- Setup an additional
apt
source - Using Raspberry Pi as a DVR
- Using Raspberry Pi as a Router
- Working with ext filesystems on macOS
- Firefox
- VNC Server Setup
- Gotchas
- Useful Links
- Kodi
- Kodi Articles
- TODOs
- Download the Raspbian distro from the downloads page.
- Use Etcher to burn the
.img
to the SD card.
- Place an empty file named
ssh
on the smaller boot partition after using Etcher to write the OS to the SD card. see for more info.
touch /path/to/boot/volume/boot/ssh
To permit or allow superuser login for ssh
vim /etc/ssh/sshd_config
Add the below line to the above mentioned file
PermitRootLogin yes
The default user for Raspbian is pi
and the password is raspberry
.
If there is no keyboard present, the pi can be directly connected to the router via ethernet, and a virtual keyboard can be installed if SSH has been enabled.
After logging into the pi, a .bash_profile can be setup to add aliases that should work with the default bash shell on the pi. The .bash_profile should be initialized via UART and SSH.
To remove the wolfram-engine and libreoffice components from a Raspbian install
sudo apt-get remove --purge wolfram-engine libreoffice* nuscratch
IMHO both packages are bloat for a basic Raspbian install and are things I will never use.
To upgrade Raspbian from stretch to buster
- Edit the below to files, and change the word
stretch
tobuster
and run the following commands credit
/etc/apt/sources.list
/etc/apt/sources.list.d/raspi.list
sudo apt update
sudo apt dist-upgrade
To get a temperature reading of the CPU, GPU and RAM on a Raspberry Pi running Raspbian.
vcgencmd measure_temp
Traditionally mounting filesystems on a *nix/BSD system has been reserved for the root user for security reasons. That said, a few options to allow non-root users to mount filesystems ie. a removable SD card or USB thumb drive / disk are available.
- setup entries in /etc/fstab
- setup fuse filesystem in userspace to allow users to mount personal / custom filesystems on a per user basis without compromising the initial integrity of the system.
To install fuse on a Debian based distro ie. Raspbian
sudo apt update; sudo apt install fuse3
βοΈ Unfortunately there isn't a fuse driver that supports writing to hfs{+} filesystems.
- Install sysbench via apt
sudo apt-get install sysbench
- To run the CPU benchmark
- sysbench --test=cpu --cpu-max-prime=20000 --num-threads=4 run
+ sysbench cpu --cpu-max-prime=20000 --threads=4 run
As of January 12, 2019 I own a WinTV-dualHD DTV turner with a USB interface made by hauppauge Hauppauge provide a suite of utilities for Microsoft Windows 7 and 10 for watching over the air digital TV and along with recording TV and measure signal strength. Unfortunately, as of January 12, 2019 there appears to be little to no support for macOS, that said, there does seem to be support for GNU+Linux distrobutions.
To setup a TigerVNC Server on Raspbian
- Install TigerVNC
sudo apt-get update
sudo apt-get install tigervnc-common tigervnc-standalone-server tigervnc-viewr
To start a TigerVNC on Raspbian
vncserver -interface 192.168.[ο£ΏΓΌΓ₯Γ ].[ο£ΏΓΌΒΆΓ]
To connect to a TigerVNC server from macOS over SSH
- Create a ssh tunnel to the TigerVNC port
ssh -NTf -L 5901:localhost:5901 [unix_user]@[vnc_server_ip_or_hostname.local]
- Launch the VNC client on macOS
vncviewer vnc_server_ip:[PORT]
search terms retro, gaming, raspi, raspberry pi, raspberrypi, emulation station, emulationstation, emulator
-
βΓΉΓ³ΓβΓ¨ EmulationStation may not be able to run from within an existing X Server session, and may require being launched from a non X based terminal.
-
RetroPie maintains an updated fork of EmulationStation hosted on GitHub.
- RetroPie can be manually installed to coexist with an existing install of Raspbian. See for instructions on setting up RetroPie on Raspbian.
To put a Playstation 4 controller, ie. model CUH-2CT2U into Bluetooth pairing mode
Press and hold the PlaystationβΓΒ’ΓβΓ¨ button and the SHARE button on the controller simultaneously until a blue light starts flashing
- Edit /etc/hosts
- change the entry with 127.0.1.1 [mr-fancy-42-hostname]
- Edit /etc/hostname
- change raspberrypi to [mr-fancy-42-hostname]
An alternative way to change the hostname on a Raspberry Pi running Raspbian is to use raspi-config
sudo raspi-config
Hostnames can not contain underscores _
Running Raspbian based off of Debian Stretch, the below file should be edited for working with network settings.
/etc/dhcpcd.conf
The above mentioned file can be used to setup static IP's for both the ethernet and wireless interfaces for a Pi.
If running an older version of Raspbian, ie. Wheezy then edit the below file
/etc/network/interfaces
To restart the entire networking stack or just the DHCP portion
sudo systemctl restart networking
sudo systemctl restart dhcpcd
For more info about networking on Raspbian see and
If the Raspberry Pi is connected to active internet connection
sudo raspi-config
- Select the Country and then a timezone within the country under the localization settings.
π‘ If issues arise with connections / terminations using the seed studio, or you forget which wire go where, remember the underside of the bus pirate has the pins labeled on the PCB as described in the image below.
Make sure the below line is in the config.txt
enable_uart=1
Edit the /boot/cmdline.txt and add or change
console=serial0,115200 console=tty1
To see kernel boot messages through the console, ie. a verbose boot sequence when booting the pi, remove quiet
from /boot/cmdline.txt
- asciinema > connecting to a Raspberry Pi using a Bus Pirate and screen.
The UART interface on a Raspberry Pi needs be enabled first before being able to use it as a serial console. The interface can be enabled using raspi-config
If a properly configured FTDI board is connected to a macOS system, and jumper wires are connected to the correct GPIO pins of the Raspberry Pi, then a serial connection can be established using screen
To connect to a Raspberry Pi UART using screen on macOS
screen /dev/tty.usbserial-[SERIAL_NUMBER] 115200
If properly connected one should be presented with a login prompt.
To detach from a screen session
control+a then d
To kill a screen session
control+a then k
To attach to a dettached screen session
screen -r
This is extremely useful when building custom Linux kernels for Raspbian
The default Raspbian Stretch image has a 50MB boot partition, which inadequate for building custom Linux kernels for Raspbian.
Disclaimer resizing the boot partition is a total pain the ass, that said, here is my shitty explanations on to get it done.
- After setting up Raspbian on an microSD card the default size for the boot partition is 50MB
This guide will attempt to explain on how to resize the root and boot partitions for Raspbian Stretch.
- Start Raspbian on a Raspberry Pi of some sort then edit the following two files.
/boot/cmdline.txt
/etc/fstab
/etc/fstab can not be accessed from the root partition on macOS out of the box, ie. macOS will need to have support for ext partitions. That said, macOS does support writing to ext* file systems.
- Change /etc/cmdline.txt entry from root=PARTUUID=[HASH]-02 to
root=/dev/mmcblk0p2
A default Raspbian install stores the root partition on the second partition of the uSD card.
- Change /etc/fstab PARTUUID entries to reflect the /dev/mmcblk0p[1-2] entries
βοΈ When specifying block devices for fstab entries make sure to REMOVE the PARTUUID at the beginning of the entry using a block ID.
- After the saves have been made, attempt to boot the Raspbian system on a Pi to make sure the changes are working properly, ie. the Pi can boot.
Update August 2019
- backup the boot partition before resizing / shrinking the root partition.
The default boot partition of a Raspbian install is formatted with a FAT32 filesystem.
Simply copy the contents of the files somewhere safe
cp -ivr /Volumes/boot/* /path/to/backup-of-raspbian-boot-vol/
After the boot partition has been backed up, delete the partition, then resize the root partition to the desired size.
βοΈ A MacBook with an SD card can be used in conjunction with VirtualBox to boot a GParted ISO and mount the uSD card to delete the boot partition and resize the root partition. see for more details on accessing the SD card port of a MacBook Pro from within a Virtual Machine.
- Resize the root partition to the desired size.
Personally I changed the default boot partition from 50MB to 1GB
-
Shrink the root partition using GParted
-
Mount the boot partition
mount /dev/sd[X]1 /path/to/some/mount/point
- Copy the contents of the boot partiton to a place on the local file sytem.
cp -riv /path/to/backed/up/boot-volume/* /path/to/uSD/new/boot/volume
The above steps can be peformed on a Raspberry Pi itself if two uSD cards and a uSD card reader is present. Also GParted can be launched with X11 forwarding if need be.
To get a list of soft-blocked devices on a Raspberry Pi
sudo rfkill list
To unblock all soft-blocked radio devices
sudo rfkill unblock all
To soft-block a radio, ie. Bluetooth or Wi-Fi on a Raspberry Pi
sudo iwconfig wlan0 txpower off
To permananetly disable bluetooth and internal wifi radios on Raspbian
- Edit
/etc/modprobe.d/raspi-blacklist.conf
- Add the below lines to the file.
blacklist btbcm
blacklist hci_uart
blacklist brcmfmac
blacklist brcmutil
If adding an additional access point to connect to ie. connecting to a new router and using raspi-config then wpa will need to be restarted.
wpa_cli -i wlan0 reconfigure
Raspbian based off of Debian Stretch 9.9 should come with mDNS support of the box, but if the hostname is changed, then more than likely the pi will need to be rebooted. mDNS support and manually be added to Raspbian
sudo apt update
sudo apt install avahi-daemon
echo "setup hostname using `rasp-config`"
To bring up a wireless interface on Raspbian Linux
sudo ifconfig wlan0 up
To bring down a wireless interface on Raspbian
sudo ifconfig wlan0 down
A sparse bundle disk image label can be renamed, but the image must first be mounted.
hdiutil attach /path/to/my.sparseimage
diskutil rename old_label new_label
hdiutil detach new_label
Then the sparseimage can be mounted or attached using the new label name.
- continue working on steps to get a xtools toolchain built for Raspbian on macOS
dirmngr
will need to be installed first beforeapt-key
can add a new key to the keyring.
sudo apt-get install dirmngr
To install an additional key from a server
sudo apt-key adv --keyserver hkp://keyserver.mr-fancy.com:80 --recv-keys 4242424242424242
Example
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
Software
To install the bintray version Tvheadend on Raspbian stretch running on a Raspberry Pi
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
sudo apt-get install dirmngr
echo "deb https://dl.bintray.com/tvheadend/deb DISTRO REPO-COMPONENT" | sudo tee /etc/apt/sources.list.d/tvheadend.list
sudo apt-get update
sudo apt-get install tvheadend
For more info on installing a binary version of Tvheadend see
To access the tvheadend server and configure the app
http://localhost:9981
or
http://hostname-of-raspi.local:9981
- #pihole #raspberry pi #raspberrypi #web #webinterface #admin #interface
To access the pihole web admin interface
http://IP_ADDRESS_OF_RASPBERRYPI/admin
Example
https://10.0.1.42/admin
For my particular use case I purchased a TP-Link Archer T9UH AC 1900 Wireless USB adapter with a hardware revision of 1, ie. US/1.0
- Chipset Realtek 8814AU
Various tp-link products can have different hardware revisisions see
There is an official tp-link Linux dirver that can be found here however I was unable to get it to build for Raspbian running a 4.19.x-v7+ kernel.
To get the above mentioned hardware working with a semi modern Linux kernel checkout the following GitHub repo
https://github.com/aircrack-ng/rtl8812au
The README in the repo contains instructions to build for both a Raspberry Pi 3b and 3b+
βοΈ Modern versions of the driver have been having issues with the Archer wireless card(s) and until a fix is applied to the driver, it is suggested to checkout from
https://github.com/aircrack-ng/rtl8812au/commit/0eda114fda2b66682deff77b1259c0aa6d2e6206
See this issue #327
βοΈ The driver currently also requires being built using a 32bit toolchain as a 32bit kernel module even for rpi 3b+ and rpi 4.
The above GitHub repo provides a rather lengthy install process for setting up ext fuse support on macOS; because of the lengthy setup procedure, I have forked the project and wrote a build script for macOS High Sierra.
To mount an ext file system with the newly built tools
sudo fuse-ext2 /path/to/block/device/partition /path/to/mount/point -o rw+,allow_other,uid=[USER_ID],gid=[GROUP_ID]
Ex
sudo fuse-ext2 /dev/disk2s2 ~/mnt/ext-fs -o rw+,allow_other,uid=501,gid=20
The above command will mount the ext file system stored on the SD card for a typical Raspbian install on macOS with a standard user. To find the user ID for a particular user on macOS
id [USERNAME]
Now the filesystem should be available for reading and writing β§*q٩(ΛαΛ*)Ωβ§*q
To umount the filesystem
sudo unmount ~/mnt/ext4
To list the available ext filesystems on macOS
diskutil list
To unmount the previously mounted filesystem
umount /Users/capin/mnt/ext4
echo "deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/firefox.list
echo "deb-src http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/firefox-source.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9BDB3D89CE49EC21
sudo apt update && sudo apt install firefox
If apt-get update
errors out
rm /var/lib/apt/lists/* -vf
apt-get update
To get a detailed package description about an apt package
sudo apt-get show [PACKAGE_NAME]
These steps are optional but help free up some space on the root partition
sudo apt-get remove --purge wolfram-engine
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
π¨ Certain apps will require being run as root, ie. gparted or elese the below message will be displayed. From my emperical evidence gparted will not run when logging in as pi and then running su -
to get be superuser. That said, logging in as root via ssh allows running of gparted as root.
To troubleshoot a Gtk-WARNING **: cannot open display: localhost:10.0
export DISPLAY='IP:0.0'
may not fix the above issue, but see
To setup a VNC server see
If a physical USB keyboard is not present install
apt-get install matchbox-keyboard
The matchbox-keyboard can be started from the GUI,
Menu >> Accessories >> Keyboard
To mount a NFS Network File Share using smbclient
smbclient //[IP_ADDRESS_OF_NFS]/Data -U WORKGROUP
The stock smbclient setup on Raspbian has higher security settings than those setup on an Apple Time Capsule. That said, the below settings can be added to /etc/samba/smb.conf
[global]
echo "{$USER} added settings"
echo "Experimental settings"
client use spnego = no
client ntlmv2 auth = yes
The above command can be used to a network share setup in an Apple Time Capsule and should prompt for a password if one is setup for the network share.
The above command will mount a NFS share using Samba ie. the smbclient that is located on a host with a mount of of /Data.
To troubleshoot a smbclient connection
smbclient -L [SERVER_IP] -U [USERNAME] -d 256
To mount a Common Internet File System (CIFS) in Linux, ie. Raspbian via a CLI
sudo mount -t cifs \
//[IP_ADDRESS_OF_NFS]/[MNT_POINT] \
/path/to/local/mnt \
-o rw,uid=1000,gid=1000 \
-o iocharset=utf8,sec=ntlm,vers=1.0
- Q what is the difference between arm32v6 & arm32v7, ie. what did v7 add to the arm instruction set.
If you find any of this info helpful on your journey π click that π βοΈ star button. It sure makes me feel warm and fuzzy π» on the inside.
-
Linux and macOS Operation Notes
- β macOS Op Notes
- π§ Linux Op Notes
- Vim & Neovim Notes
- git Notes
- π fish shell Notes
- ECMAScript Tooling
- π₯§ Raspberry Pi Notes
- asdf version manager Notes
- Bind9 Notes
- Creating a custom motd on Debian Jessie
- ECMAScript Tooling
- Email client Notes
- Email Server Setup Notes Postfix & Dovecot
- Emoji side quest
- fish shell Notes
- π₯ π€ git it got it good Notes
- git Notes
- Graphics and Image Processing Notes
- GUI text editor Notes
- π»π§ Homebrew and Linuxbrew formula Notes
- Linux and macOS Administration Notes
- Linux and macOS Troubleshooting Notes
- MacBook Pro Late 2013 Notes
- Vim & Neovim Notes
- Video Production Notes
- Python Notes
- radare Notes
- Raspberry Pi Notes
- Terminal Emulators
- Tmux Notes
- Web Browser Notes
- Weechat Notes
- Microsoft Windows Notes