Skip to content

Instantly share code, notes, and snippets.

View SiKing's full-sized avatar
🍻
still drinking

SiKing

🍻
still drinking
View GitHub Profile
@SiKing
SiKing / raid_check.sh
Created January 18, 2017 18:28
Check all raid arrays for errors.
#!/bin/bash -e
#
# Check all raid arrays for errors.
#
# Inspiration:
# https://wiki.archlinux.org/index.php/RAID#RAID_Maintenance
#
echo "Are we superuser?"
[[ $EUID -eq 0 ]]
@SiKing
SiKing / sync_boot_partition.sh
Created January 18, 2017 18:27
The boot partition cannot be RAIDed on an rPi.
#!/bin/bash -e
#
# The boot partition cannot be RAIDed on an rPi. We can periodically sync it, and if the primary card
# fails, we are then able to just swap the the cards around.
#
FIRST_SD_CARD=/dev/mmcblk0
FIRST_BOOT_PARTITION=${FIRST_SD_CARD}p1
#FIRST_ROOT_PARTITION=${FIRST_SD_CARD}p2
#FIRST_APP_PARTITION=${FIRST_SD_CARD}p3
@SiKing
SiKing / 07-setup_maintenance.sh
Created January 18, 2017 18:25
madadm needs some periodic maintenance scripts - each one is documented in the script.
#!/bin/bash -e
#
# Goal:
# madadm needs some periodic maintenance scripts - each one is documented in the script.
#
echo "Are we superuser?"
[[ $EUID -eq 0 ]]
echo "OK"
@SiKing
SiKing / 06-create_app_raid.sh
Created January 18, 2017 18:23
Configure two partitions to work as RAID1.
#!/bin/bash -e
#
# Goal:
# Configure two partitions to work as RAID1.
#
# Prerequisites:
# 1. Run both 05-configure_root_raid_pass*.
# 2. Set the following variables:
#
FIRST_SD_CARD=/dev/mmcblk0
@SiKing
SiKing / 05-create_root_raid_pass2.sh
Created January 18, 2017 18:22
Configure two partitions (one already done) to work as RAID1.
#!/bin/bash -e
#
# Goal:
# Configure two partitions (one already done) to work as RAID1.
#
# Inspiration:
# http://blog.drewwithers.com/2013/11/raspberry-pi-usb-raid1-root-partition.html
# https://wiki.archlinux.org/index.php/Convert_a_single_drive_system_to_RAID
#
# Prerequisites:
@SiKing
SiKing / 05-create_root_raid_pass1.sh
Created January 18, 2017 18:21
Configure two partitions (one currently in use) to work as RAID1.
#!/bin/bash -e
#
# Goal:
# Configure two partitions (one currently in use) to work as RAID1.
#
# Inspiration:
# http://blog.drewwithers.com/2013/11/raspberry-pi-usb-raid1-root-partition.html
# https://wiki.archlinux.org/index.php/Convert_a_single_drive_system_to_RAID
#
# Prerequisites:
@SiKing
SiKing / 04-configure_initramfs.sh
Created January 18, 2017 18:19
Configure initramfs to be able to use md (multi-disk) arrays.
#!/bin/bash -e
#
# Goal:
# Configure initramfs to be able to use md (multi-disk) arrays.
#
# Inspiration:
# http://blog.drewwithers.com/2013/11/raspberry-pi-usb-raid1-root-partition.html
#
# Notes:
# The initramfs is tied to the current version of the kernel. Upgrading the kernel without upgrading
@SiKing
SiKing / 03-tune_root_filesystem.sh
Created January 18, 2017 00:59
Tune the root filesystem.
#!/bin/bash -e
#
# Goal:
# Tune the root filesystem.
#
# Notes:
# Not needed if building the RAID system.
#
# Prerequisites:
# 1. Run 01-write_image_to_card.
@SiKing
SiKing / 02-create_app_partition.sh
Created January 18, 2017 00:56
Prepare empty space on the card to be used as /app partition.
#!/bin/bash -e
#
# Goal:
# Prepare empty space on the card to be used as /app partition.
#
# Notes:
# After this script, first time the Raspberry is powered on, you will see an error:
# "Could not expand filesystem, please try raspi-config or rc_gui."
# This error can be safely ignored, or it can be turned off using the sed command from line 132 in
# file: $ROOT_PARTITION/usr/lib/raspi-config/init_resize.sh
@SiKing
SiKing / 01-write_image_to_card.sh
Last active January 18, 2017 00:55
Burn the Raspbian OS image to an SD card.
#!/bin/bash -e
#
# Goal:
# Burn the Raspbian OS image to an SD card.
#
# Prerequisites:
# 1. Download image from https://www.raspberrypi.org/downloads/raspbian/.
# 2. Unzip the image.
# 3. Set the following variables:
#