-
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
aptsource - 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
.imgto the SD card.
- Place an empty file named
sshon 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/sshTo permit or allow superuser login for ssh
vim /etc/ssh/sshd_configAdd 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* nuscratchIMHO 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
stretchtobusterand run the following commands credit
/etc/apt/sources.list
/etc/apt/sources.list.d/raspi.list
sudo apt update
sudo apt dist-upgradeTo get a temperature reading of the CPU, GPU and RAM on a Raspberry Pi running Raspbian.
vcgencmd measure_temp- 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-viewrTo 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-configHostnames can not contain underscores _
Running Raspbian based off of Debian Stretch, the below file should be edited for working with network settings.
/etc/dhcpcd.confThe 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/interfacesTo restart the entire networking stack or just the DHCP portion
sudo systemctl restart networking
sudo systemctl restart dhcpcdFor 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.
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] 115200If 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 -rThis 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/mmcblk0p
-
Change /etc/fstab PARTUUID entries to reflect the /dev/mmcblk0[1-2] entries
-
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.
If the Pi can boot then resize the root partition using GParted
sudo apt-get update
sudo apt-get install gparted- 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 /media/boot ~/tmp/boot.updateMake certain to unmount the boot partiton after copying the contents of the boot partition.
-
Delete the original boot partition.
-
Create a new boot partition to fill the free space using GParted
-
Copy the contents of ~/tmp/boot.update to the new boot partition.
cp -irv ~/tmp/boot.update/* /media/boot/- Cross fingers and power off pi, and swap out micro SD cards, and see if new Raspbian OS will boot.
To get a list of soft-blocked devices on a Raspberry Pi
sudo rfkill listTo unblock all soft-blocked radio devices
sudo rfkill unblock allTo soft-block a radio, ie. Bluetooth or Wi-Fi on a Raspberry Pi
sudo iwconfig wlan0 txpower offTo 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
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 upTo bring down a wireless interface on Raspbian
sudo ifconfig wlan0 downA 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_labelThen 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
dirmngrwill need to be installed first beforeapt-keycan add a new key to the keyring.
sudo apt-get install dirmngrTo install an additional key from a server
sudo apt-key adv --keyserver hkp://keyserver.mr-fancy.com:80 --recv-keys 4242424242424242Example
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61Software
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 379CE192D401AB61sudo apt-get install dirmngrecho "deb https://dl.bintray.com/tvheadend/deb DISTRO REPO-COMPONENT" | sudo tee /etc/apt/sources.list.d/tvheadend.listsudo apt-get update
sudo apt-get install tvheadendFor more info on installing a binary version of Tvheadend see
To access the tvheadend server and configure the app
http://localhost:9981or
http://hostname-of-raspi.local:9981For 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/rtl8812auThe README in the repo contains instructions to build for both a Raspberry Pi 3b and 3b+
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=20The 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/ext4To list the available ext filesystems on macOS
diskutil listTo unmount the previously mounted filesystem
umount /Users/capin/mnt/ext4echo "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 firefoxIf apt-get update errors out
rm /var/lib/apt/lists/* -vf
apt-get updateTo 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 autoremovesudo 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-keyboardThe 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 WORKGROUPThe 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 = yesThe 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 256To 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.0If 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
