Skip to content

Instantly share code, notes, and snippets.

@Robpol86
Last active July 24, 2026 09:58
Show Gist options
  • Select an option

  • Save Robpol86/3d4730818816f866452e to your computer and use it in GitHub Desktop.

Select an option

Save Robpol86/3d4730818816f866452e to your computer and use it in GitHub Desktop.
This is how I setup Debian.

Debian/Ubuntu/Raspberry Pi OS Setup

Steps written for debian-10.7.0-amd64 and 2020-08-20-raspios-buster-arm64-lite at the time of this writing.

Install: Ubuntu Btrfs

Out of the box Ubuntu installs btrfs without creating subvolumes. To fix this, on the first screen of the installer, switch to another tty and run:

sudo su -

sfdisk /dev/mmcblk0 <<EOF
label: gpt
,1G,U
,2G,L
,2G,S
,,L
EOF

mkfs.btrfs --label=ubuntu /dev/mmcblk0p4
mount /dev/mmcblk0p4 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume set-default /mnt/@
umount /mnt

Then reboot. If grub loads from the empty partition just type "exit" and the BIOS should boot to USB again. Back in the installer select "Custom storage layout", then select each partition and:

  1. Leave unselected
  2. Edit > Format: ext4; Mount: /boot
  3. Edit > Use as swap
  4. Edit > Mount > Other > / (ignore warning)

From: https://www.reddit.com/r/btrfs/comments/1dq04qx/convert_ubuntu_btrfs_installation_into_subvolumes/

Post-Install: Debian/Ubuntu

su -
apt-get update && apt-get install -y sudo
usermod -aG sudo robpol86

Restore man pages in minimized install (from: https://askubuntu.com/questions/1417294/missing-manpages-on-a-ubuntu-lts-22-04-server-minimal-install):

sudo sed -i '/path-exclude/s/^/#/' /etc/dpkg/dpkg.cfg.d/excludes
sudo apt-get --reinstall install -y man-db manpages manpages-dev
sudo apt-get install -y manpages-posix manpages-posix-dev
dpkg -l |grep -i manpages  # confirm
sudo mv /usr/bin/man.REAL /usr/bin/man
sudo mandb -c
man man
man ls
man cd

If running in Hyper-V and you wish to SSH from WSL 2 (make sure address/netmask are within WSL's subnet):

cat >> /etc/network/interfaces <<EOF

allow-hotplug eth1
iface eth1 inet static
    address 172.18.202.200
    netmask 255.255.240.0
EOF

Set Grub timeout to 3 seconds to make editing the cmdline easier over IPMI.

sudo sed -i.bak -e '/GRUB_TIMEOUT/s/=[0-9]\+/=3/' -e '/GRUB_TIMEOUT_STYLE/s/=[a-z]\+/=menu/' /etc/default/grub
sudo update-grub

Post-Install: RasPiOS

This is for a Raspberry Pi 4 connected to a NexDock Touch.

sudo raspi-config

# System Options
    # Password: Change "pi" password
# Localisation Options
    # Locale: en_US.UTF-8 UTF-8 > en_US.UTF-8
    # Time Zone: US > Pacific Ocean
    # Keyboard Layout: Generic 104-key PC > English (US) > No AltGr/compose key
    # WLAN Country: US
# Interfacing Options
    # SSH: Yes
# Advanced Options
    # Overscan: No

Install/Update Software

# Packages
sudo apt-get -y update && \
    sudo apt-get -y install curl git i2c-tools jq libxml2-utils lsof make moreutils nmap psmisc pv python3-venv \
        socat telnet unzip vim xsel zsh dos2unix && \
    sudo apt-get -y upgrade && \
    sudo apt-get -y autoremove

# ffmpeg
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz
sudo tar --wildcards --strip-components=2 -C /usr/local/bin -xf ffmpeg-master-latest-linux64-gpl.tar.xz \
    '*/ffmpeg' '*/ffprobe'
rm -v ffmpeg-master-latest-linux64-gpl.tar.xz
ffmpeg -h

# youtube dl (fork)
curl -sSL https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp |
    sudo install -m0755 /dev/stdin /usr/local/bin/yt-dlp

Shell/Git

sudo update-alternatives --set editor /usr/bin/vim.basic
sudo select-editor
select-editor

# Below command prompts for input
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

git -C "$ZSH_CUSTOM/plugins" clone https://github.com/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com/so-fancy/diff-so-fancy.git "$HOME/workspace/diff-so-fancy"

git clone https://github.com/Robpol86/dotfiles.git "$HOME/workspace/dotfiles" && cd "$_" && \
    install -m0700 -d ~/.ssh && \
    ln -s "$PWD/ssh_config" ~/.ssh/config && \
    ln -fs "$PWD/vimrc" ~/.vimrc && \
    ln -fs "$PWD/themes/robpol86.zsh-theme" "$ZSH/custom/themes/" && \
    ln -fs "$PWD/zshrc.sh" ~/.zshrc && \
    ln -fs "$PWD/zprofile.sh" ~/.zprofile && \
    zsh -lc _robpol86_run_once

Golang

version="$(curl -sSL "https://go.dev/VERSION?m=text" |head -1)"
wget "https://dl.google.com/go/$version.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "$version.linux-amd64.tar.gz" && rm -v "$_"

Node.js

sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
URL="https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key"
curl -fsSL "$URL" |sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
URL="https://deb.nodesource.com/node_$NODE_MAJOR.x"
LINE="deb [signed-by=/etc/apt/keyrings/nodesource.gpg] $URL nodistro main"
sudo tee /etc/apt/sources.list.d/nodesource.list <<< "$LINE"
sudo apt-get update && sudo apt-get install -y nodejs

RTC

These instructions are for the PCF8563 chip in the Juice4halt RTC-485 hat. Instructions are based off of https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time and https://www.raspberrypi.org/forums/viewtopic.php?t=209700.

sudo sed -i "/^#dtparam=i2c_arm=on$/s/#//g" /boot/config.txt
sudo tee -a /boot/config.txt <<< dtoverlay=i2c-rtc,pcf8563
sudo tee /etc/udev/rules.d/85-hwclock.rules <<< \
    'KERNEL=="rtc0", RUN+="/sbin/hwclock --rtc=$root/$name --hctosys"'
sudo apt-get -y purge fake-hwclock
sudo reboot

Python

  • sudo apt-get install python-pip libssl-dev
  • sudo pip install tox
for v in 3.3.6 3.4.3; do
    cd; wget https://www.python.org/ftp/python/$v/Python-$v.tgz
    tar -xzf Python-$v.tgz; cd Python-$v
    ./configure --prefix=/usr/local && make && sudo make altinstall
    sudo ln -s /usr/local/bin/python${v::3} /usr/bin/python${v::3}
    wget https://bootstrap.pypa.io/get-pip.py -O - |sudo python${v::3}
    sudo ln -s /usr/local/bin/pip${v::3} /usr/bin/pip${v::3}
    sudo pip${v::3} install virtualenv
done
sudo rm /usr/local/bin/pip
p=pypy3-2.4.0
cd; wget https://bitbucket.org/pypy/pypy/downloads/$p-linux-armhf-raspbian.tar.bz2
sudo mkdir /opt/$p
sudo tar -xjf $p-linux-armhf-raspbian.tar.bz2 -C /opt/$p --strip 1
sudo ln -s /opt/$p/bin/pypy3 /usr/bin/pypy3

Simple Git "Server"

Here I'll use terminaltables as an example.

mkdir -p ~/workspace/terminaltables/.git
cd !$ && git init --bare
cat << EOF > hooks/post-receive
#!/bin/bash
while read oldrev newrev ref; do
    branch=\$(echo \$ref |cut -d/ -f3)
    export GIT_WORK_TREE=../\$branch
    [ ! -e \$GIT_WORK_TREE ] && mkdir -p \$GIT_WORK_TREE
    git clean -f -d
    git checkout -f \$branch
done
EOF
chmod +x hooks/post-receive

Run this command on the "client":

  • git remote add rpi ssh://pi@raspberrypi/home/pi/workspace/terminaltables/.git

Btrfs Root Snapshots

To take snapshots of the root filesystem, a la virtual machine on bare metal, do this first:

sudo mkdir /snapshots

To create a snapshot:

sudo btrfs subvolume snapshot -r / "/snapshots/root-$(date +%s)"
@n8henrie

Copy link
Copy Markdown

Is this with Jessie or Wheezy? I'm not having any luck installing pypy3 this way on Jessie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment