Created
January 18, 2017 18:27
-
-
Save SiKing/70259411d40330bb7260bfdce32dc02e to your computer and use it in GitHub Desktop.
The boot partition cannot be RAIDed on an rPi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
SECOND_SD_CARD=/dev/sda | |
SECOND_BOOT_PARTITION=${SECOND_SD_CARD}1 | |
#SECOND_ROOT_PARTITION=${SECOND_SD_CARD}2 | |
#SECOND_APP_PARTITION=${SECOND_SD_CARD}3 | |
echo "Are we superuser?" | |
[[ $EUID -eq 0 ]] | |
echo "OK" | |
# assume FIRST_BOOT_PARTITION is already mounted | |
echo "Is partition $SECOND_BOOT_PARTITION not mounted?" | |
if df | grep --quiet "$SECOND_BOOT_PARTITION" | |
then | |
umount "$SECOND_BOOT_PARTITION" | |
fi | |
echo "OK" | |
echo "Copy files over." | |
BOOT_MOUNT=/tmp/boot | |
mkdir --parents "$BOOT_MOUNT" | |
mount "$SECOND_BOOT_PARTITION" "$BOOT_MOUNT" | |
rsync --archive --exclude="/lost+found" /boot/ "$BOOT_MOUNT" | |
umount "$BOOT_MOUNT" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment