Stage 4: Calamares installer and Btrfs snapshots (0.2.0)
- Package Calamares 3.4.3 (Qt6, widgets UI) with xbps-src. - das-installer: Calamares setup for Void/runit with Das OS branding and slides. It copies the clean live image (live-base), builds locales and the host-only initramfs, rewrites kernels without sparse tails (GRUB 2.12 cannot read Btrfs holes at the end of a file), then removes itself. - das-snapshots: flat Btrfs layout (@, @home, @snapshots, @var_log, @var_cache_xbps), snapper with hourly snapshots via cronie, grub-btrfs menu, snapper-rollback, and a dracut module that boots read-only snapshots with a RAM overlay. - das-settings 0.2.0: start LightDM with the system locale. - Live image: GRUB, efibootmgr and the new packages; Das OS /etc/issue. - Build: wipe stale destdirs before building packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
../../../LICENSE
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# Set up snapper for a Das OS root file system on Btrfs.
|
||||
#
|
||||
# Expects the layout created by the installer: the root in subvolume @ and
|
||||
# snapshots in subvolume @snapshots mounted at /.snapshots, which is what
|
||||
# snapper-rollback needs. Safe to run again.
|
||||
set -eu
|
||||
|
||||
msg() { echo "das-snapper-setup: $*"; }
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
msg "must be run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(findmnt -no FSTYPE /)" != btrfs ]; then
|
||||
msg "the root file system is not Btrfs, nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
if [ "$(findmnt -no FSTYPE /.snapshots 2>/dev/null)" != btrfs ]; then
|
||||
msg "/.snapshots is not a mounted Btrfs subvolume" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e /etc/snapper/configs/root ]; then
|
||||
install -m 640 /usr/share/das/snapper/root /etc/snapper/configs/root
|
||||
msg "created /etc/snapper/configs/root"
|
||||
fi
|
||||
if ! grep -q '^SNAPPER_CONFIGS=".*\broot\b' /etc/conf.d/snapper; then
|
||||
sed -i 's/^SNAPPER_CONFIGS=.*/SNAPPER_CONFIGS="root"/' /etc/conf.d/snapper
|
||||
fi
|
||||
chmod 750 /.snapshots
|
||||
chgrp wheel /.snapshots
|
||||
|
||||
# snapper-rollback mounts the top-level subvolume from this device.
|
||||
dev=$(findmnt -no SOURCE / | sed 's/\[.*\]$//')
|
||||
uuid=$(blkid -s UUID -o value "$dev")
|
||||
sed -i "s|^#\?\s*dev = .*|dev = /dev/disk/by-uuid/$uuid|" /etc/snapper-rollback.conf
|
||||
|
||||
# Name the GRUB submenu that grub-btrfs adds
|
||||
cfg=/etc/default/grub-btrfs/config
|
||||
if [ -f "$cfg" ] && ! grep -q '^GRUB_BTRFS_SUBMENUNAME=' "$cfg"; then
|
||||
echo 'GRUB_BTRFS_SUBMENUNAME="Das OS snapshots"' >>"$cfg"
|
||||
fi
|
||||
|
||||
# Hourly snapshots come from cron, and grub-btrfs adds them to the boot menu.
|
||||
for sv in cronie grub-btrfs; do
|
||||
ln -sfn "/etc/sv/$sv" "/etc/runit/runsvdir/default/$sv"
|
||||
done
|
||||
msg "snapshots are enabled"
|
||||
@@ -0,0 +1,2 @@
|
||||
# Lets a read-only snapper snapshot boot from the GRUB menu (see das-snapshot-overlay).
|
||||
add_dracutmodules+=" das-snapshot-overlay "
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Snapper snapshots are read-only, and the system can't start from a read-only
|
||||
# root. When GRUB boots a snapshot, mount it under an overlay whose writable
|
||||
# layer lives in RAM. Changes made in that session are lost at shutdown.
|
||||
|
||||
[ "$(btrfs property get -ts "$NEWROOT" ro 2>/dev/null)" = "ro=true" ] || return 0
|
||||
|
||||
info "das-snapshot-overlay: read-only snapshot, adding a writable overlay"
|
||||
lower=$(mktemp -d -p /)
|
||||
ram=$(mktemp -d -p /)
|
||||
mount --move "$NEWROOT" "$lower"
|
||||
mount -t tmpfs -o mode=0755 das-overlay "$ram"
|
||||
mkdir -p "$ram/upper" "$ram/work"
|
||||
mount -t overlay -o "lowerdir=$lower,upperdir=$ram/upper,workdir=$ram/work" das-overlay "$NEWROOT"
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Dracut module: boot read-only Btrfs snapshots with a writable overlay in RAM.
|
||||
|
||||
check() {
|
||||
require_binaries btrfs || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo btrfs
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
hostonly='' instmods overlay
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_multiple btrfs mktemp
|
||||
inst_hook pre-pivot 10 "$moddir/das-snapshot-overlay.sh"
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Snapper configuration for the Das OS root file system.
|
||||
# das-snapper-setup copies it to /etc/snapper/configs/root.
|
||||
|
||||
SUBVOLUME="/"
|
||||
FSTYPE="btrfs"
|
||||
QGROUP=""
|
||||
|
||||
# Snapshots may use at most half of the file system and must leave 20% free.
|
||||
SPACE_LIMIT="0.5"
|
||||
FREE_LIMIT="0.2"
|
||||
|
||||
# Members of wheel can list and compare snapshots without sudo.
|
||||
ALLOW_USERS=""
|
||||
ALLOW_GROUPS="wheel"
|
||||
SYNC_ACL="yes"
|
||||
|
||||
BACKGROUND_COMPARISON="yes"
|
||||
|
||||
# Snapshots made by das-update and by hand.
|
||||
NUMBER_CLEANUP="yes"
|
||||
NUMBER_MIN_AGE="3600"
|
||||
NUMBER_LIMIT="20"
|
||||
NUMBER_LIMIT_IMPORTANT="10"
|
||||
|
||||
# Hourly snapshots made by cron.
|
||||
TIMELINE_CREATE="yes"
|
||||
TIMELINE_CLEANUP="yes"
|
||||
TIMELINE_MIN_AGE="3600"
|
||||
TIMELINE_LIMIT_HOURLY="5"
|
||||
TIMELINE_LIMIT_DAILY="7"
|
||||
TIMELINE_LIMIT_WEEKLY="2"
|
||||
TIMELINE_LIMIT_MONTHLY="0"
|
||||
TIMELINE_LIMIT_QUARTERLY="0"
|
||||
TIMELINE_LIMIT_YEARLY="0"
|
||||
|
||||
EMPTY_PRE_POST_CLEANUP="yes"
|
||||
EMPTY_PRE_POST_MIN_AGE="3600"
|
||||
Reference in New Issue
Block a user