fix: remove default snapper config and incorrect snapshots (#1939)

* fix: remove btrfs assistant configs, snapshots

* chore: reword

* chore: bump hw ver

* chore: add check for file to prevent calling snapper every time

* fix: force workaround to run once

* chore: add fixme for eventual removal

* fix: create fixup touch always to avoid having it primed
This commit is contained in:
Antheas Kapenekakis 2024-12-06 20:35:51 +01:00 committed by GitHub
parent c5eaedb7b2
commit 651c5bd378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 79 deletions

View File

@ -767,7 +767,6 @@ RUN rm -f /etc/profile.d/toolbox.sh && \
systemctl enable bazzite-hardware-setup.service && \ systemctl enable bazzite-hardware-setup.service && \
systemctl disable tailscaled.service && \ systemctl disable tailscaled.service && \
systemctl enable dev-hugepages1G.mount && \ systemctl enable dev-hugepages1G.mount && \
systemctl enable bazzite-snapper-setup && \
systemctl --global enable bazzite-user-setup.service && \ systemctl --global enable bazzite-user-setup.service && \
systemctl --global enable podman.socket && \ systemctl --global enable podman.socket && \
systemctl --global enable systemd-tmpfiles-setup.service && \ systemctl --global enable systemd-tmpfiles-setup.service && \

View File

@ -1,10 +0,0 @@
[Unit]
Description=Create a default snapper config if snapper is unconfigured
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/libexec/bazzite-snapper-setup
[Install]
WantedBy=multi-user.target

View File

@ -7,7 +7,7 @@ IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)
FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO) FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO)
# SCRIPT VERSION # SCRIPT VERSION
HWS_VER=50 HWS_VER=51
HWS_VER_FILE="/etc/bazzite/hws_version" HWS_VER_FILE="/etc/bazzite/hws_version"
HWS_VER_RAN=$(cat $HWS_VER_FILE) HWS_VER_RAN=$(cat $HWS_VER_FILE)
@ -31,6 +31,9 @@ CURRENT_FREE_ZRAM=$(sysctl vm.min_free_kbytes | awk '{print $3}')
KARGS=$(rpm-ostree kargs) KARGS=$(rpm-ostree kargs)
NEEDED_KARGS=() NEEDED_KARGS=()
# Add directory for fixups
mkdir -p /etc/bazzite/fixups
# UPDATES # UPDATES
if [[ -f /var/ublue-update/branch ]]; then if [[ -f /var/ublue-update/branch ]]; then
echo "Removing previously used branch selection file" echo "Removing previously used branch selection file"
@ -274,6 +277,25 @@ if grep -qv "graphical.target" <<< "$(systemctl get-default)"; then
systemctl set-default graphical.target systemctl set-default graphical.target
fi fi
# Cleanup btrfs oopsie
# default config has a 10 year limit, which is rediculous
# FIXME: This fix was added in 12/2024, remove it in a few months
if [ ! -f /etc/bazzite/fixups/snapper_cleanup ] &&
[ -f /etc/snapper/configs/root ] &&
[ $(snapper --no-headers --csvout -c root get-config --columns key,value | grep "TIMELINE_LIMIT_YEARLY,10" ) ] &&
[ $(snapper --no-headers --csvout -c root get-config --columns key,value | grep "SUBVOLUME,/var/home" ) ]; then
echo "DELETING SNAPPER SNAPSHOTS CREATED BY A PREVIOUS UPDATE"
echo "THIS IS FOR /var/home. IF YOU INTENDED THIS CHANGE, "
echo "RECREATE YOUR CONFIG AND MAKE SURE TIMELINE_LIMIT_YEARLY=\"10\""
echo "IS SET TO SOMETHING DIFFERENT."
SNAPSHOTS=$(snapper --no-headers --csvout --config root list --columns number,description | grep timeline | awk -F, '{print $1}')
if [ -n "$SNAPSHOTS" ]; then
snapper -c root delete $SNAPSHOTS
fi
snapper -c root delete-config
fi
touch /etc/bazzite/fixups/snapper_cleanup
mkdir -p /etc/bazzite mkdir -p /etc/bazzite
echo $HWS_VER > $HWS_VER_FILE echo $HWS_VER > $HWS_VER_FILE
echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE

View File

@ -1,4 +0,0 @@
#!/bin/bash
if ! snapper get-config >/dev/null 2>&1; then
snapper create-config /var/home
fi

View File

@ -1,63 +0,0 @@
# subvolume to snapshot
# With ostree it is pointless to snapshot /,
# so we set the root config to snapshot /var/home instead
SUBVOLUME="/var/home"
# filesystem type
FSTYPE="btrfs"
# btrfs qgroup for space aware cleanup algorithms
QGROUP=""
# fraction or absolute size of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"
# fraction or absolute size of the filesystems space that should be free
FREE_LIMIT="0.2"
# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""
# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="no"
# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"
# run daily number cleanup
NUMBER_CLEANUP="yes"
# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="50"
NUMBER_LIMIT_IMPORTANT="10"
# create hourly snapshots
TIMELINE_CREATE="yes"
# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"
# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="8"
TIMELINE_LIMIT_DAILY="4"
TIMELINE_LIMIT_WEEKLY="4"
TIMELINE_LIMIT_MONTHLY="3"
TIMELINE_LIMIT_YEARLY="0"
# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"
# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="90"