This commit is contained in:
Your Name 2024-02-17 07:57:45 -07:00
parent cf6cf5e79a
commit 82e3878931

View File

@ -306,17 +306,41 @@ installPackages() {
/usr/sbin/etc-update -q --automode -5
/usr/bin/emerge -uDN $PACKAGES
}
snapshots() {
set-devices
echo
echo "Creating Snapshots....."
echo
DATE=$(echo $(date +%Y-%m-%d-%H-%M-%S))
btrfs sub snapshot / /.snapshots/root-${DATE}
btrfs sub snapshot / /.snapshots/snapshot-root-${DATE}
echo
MACHINE_ID=$(cat /etc/machine-id)
KERNEL=$(eselect kernel list | cut -d ']' -f2 | cut -d "*" -f1 | cut -d "-" -f2 | tail -1)
KERNEL_VERSION=$(uname -r)
ROOT_NAME=$HARD_DISK
BTRFS=$BTRFS
LOADER_FILE="/efi/loader/entries/snapshot-$MACHINE_ID-$KERNEL_VERSION.conf"
echo "MachineID=$MACHINE_ID"
echo "KERNEL IS $KERNEL"
echo "Root_Name=$ROOT_NAME"
echo "BTRFS=$BTRFS"
echo "UEFI Kernel: $KERNEL_VERSION"
echo "title Gentoo snapshot-root-${DATE}" >$LOADER_FILE
echo "version $KERNEL_VERSION" >>$LOADER_FILE
echo "options root=UUID=$(/sbin/blkid -s UUID -o value $BTRFS) rootflags=subvol=/.snapshots/snapshot-root-${DATE} rw " >>$LOADER_FILE
echo "machine-id $MACHINE_ID" >>$LOADER_FILE
echo "linux /$MACHINE_ID/$KERNEL_VERSION/linux" >>$LOADER_FILE
echo "initrd /$MACHINE_ID/$KERNEL_VERSION/initrd" >>$LOADER_FILE
}
remove-snapshots() {
btrfs sub delete /.snapshots/*
rm -f /efi/loader/entries/root-*
rm -f /efi/loader/entries/snapshot-*
}
btrfs_filesytem() {
btrfs sub create $TARGET/@$ROOT_NAME
btrfs sub create $TARGET/@.snapshots