Skip to content

Instantly share code, notes, and snippets.

adduser
apparmor
ca-certificates
conntrack
cpio
curl
dbus
dbus-bin
dbus-daemon
dbus-session-bus-common
waste_collection_schedule:
sources:
- name: seattle_gov
args:
street_address: "ADDRESS HERE"
customize:
- type: "Garbage"
icon: "mdi:delete"
- type: "Food/Yard Waste"
alias: "Compost"
@sdwilsh
sdwilsh / update-partition-PARTUUID.sh
Last active May 30, 2020 18:27
Updating TFTP Root Partion's PARTUUID for Network Booting a Pi 4
# Mount the NFS Folder
NFS_DIR="$(mktemp -d)"
sudo mount ${NFS_IP}:${NFS_ROOT_PATH} ${NFS_DIR}
# Update the PARTUUID
sudo sed -i -r -E \
"s@(.*root=PARTUUID=)[A-Za-z0-9-]+(.*)@\1${ISCSI_ROOT_PARTUUID}\2@" \
${NFS_DIR}/cmdline.txt
# Unmount the NFS Folder
@sdwilsh
sdwilsh / update-fstab.sh
Last active May 30, 2020 18:22
Updating /etc/fstab for Network Booting a Pi 4
PI_MAC="dc-a6-32-7a-b4-02"
TFTP_ROOT="/mnt/rust0/tftp/"
# Update /boot to point to the NFS mount of the TFTP folder for the Pi.
NFS_IP=$(cat ${ISCSI_ROOT_DIR}/etc/iscsi/iscsi.initramfs | grep 'ISCSI_TARGET_IP=' | cut -d '=' -f 2)
NFS_ROOT_PATH="${TFTP_ROOT}${PI_MAC}"
sudo sed -i -r -E \
"s@.*/boot +.*@${NFS_IP}:${NFS_ROOT_PATH} /boot nfs defaults,vers=4.1,proto=tcp 0 0@" \
${ISCSI_ROOT_DIR}/etc/fstab
@sdwilsh
sdwilsh / copy-root-contents.sh
Last active May 30, 2020 22:48
Mount and Copy Root Contents for Network Booting a Pi 4
ISCSI_ROOT_PARTITION="/dev/sdb1"
# Create the ext4 Filesystem
sudo mkfs.ext4 /${ISCSI_ROOT_PARTITION}
ISCSI_ROOT_DIR="$(mktemp -d)"
sudo mount "${ISCSI_ROOT_PARTITION}" ${ISCSI_ROOT_DIR}
# Mount the Root Partion in the Generated Image
CREATION_OUTPUT=$(sudo partx --add -v output-arm-image/image)
@sdwilsh
sdwilsh / partition-iscsi.sh
Last active May 30, 2020 22:47
Create Root Partition for Network Booting a Pi 4
ISCSI_DEVICE="/dev/sdb"
sudo parted ${ISCSI_DEVICE} mklabel gpt
sudo parted --align optimal ${ISCSI_DEVICE} mkpart primary ext4 0% 100%
@sdwilsh
sdwilsh / iscsi-connect.sh
Created May 30, 2020 17:57
Connect to iSCSI Device for Network Booting a Pi 4
sudo iscsiadm \
--mode discovery \
--type sendtargets \
--portal ${ISCSI_TARGET_IP}
sudo iscsiadm \
--mode node \
--targetname ${ISCSI_TARGET_IQN} \
--portal ${ISCSI_TARGET_IP} \
--login
@sdwilsh
sdwilsh / initramfs-and-tftp-setup.sh
Last active May 30, 2020 23:08
Setting up the TFTP Environment for Network Booting a Pi 4
TFTP_ROOT="/mnt/rust0/tftp/"
PI_HOSTNAME=$(hostname)
PI_IP=$(ifconfig eth0 | awk '/inet /{ print $2;}')
PI_MAC=$(ifconfig eth0 | awk '/ether/{ print $2;}' | tr ':' '-')
PI_NETMASK=$(ifconfig eth0 | awk '/netmask/{ print $4;}')
ISCSI_INITIATOR_IQN=$(cat /etc/iscsi/iscsi.initramfs | grep 'ISCSI_INITIATOR=' | cut -d '=' -f 2)
ISCSI_TARGET_IP=$(cat /etc/iscsi/iscsi.initramfs | grep 'ISCSI_TARGET_IP=' | cut -d '=' -f 2)
ISCSI_TARGET_IQN=$(cat /etc/iscsi/iscsi.initramfs | grep 'ISCSI_TARGET=' | cut -d '=' -f 2)
@sdwilsh
sdwilsh / configure-bootloader.sh
Last active May 30, 2020 17:30
Configure Bootloader for Network Booting a Pi 4
cp /lib/firmware/raspberrypi/bootloader/stable/pieeprom-2020-04-16.bin pieeprom.bin
rpi-eeprom-config pieeprom.bin > bootconf.txt
# Enable pxe booting, and copy over additions.
sed -i -r -e 's/BOOT_ORDER.*?$/BOOT_ORDER=0x21/g' bootconf.txt
# Set prefix to be the mac address, like normal PXE things.
TFTP_IP=$(cat /etc/iscsi/iscsi.initramfs | grep 'ISCSI_TARGET_IP=' | cut -d '=' -f 2)
sed -i -r -e 's/TFTP_PREFIX.*?$/TFTP_PREFIX=2/g' bootconf.txt
@sdwilsh
sdwilsh / bootloader-config.sh
Created May 30, 2020 17:23
Get the Current Bootloader Config from a Pi 4
vcgencmd bootloader_config