2023-07-11 22:41:18 +05:30
|
|
|
_: {
|
2023-04-26 22:57:32 +05:30
|
|
|
boot.initrd.systemd.services.rollback = {
|
|
|
|
description = "Rollback root subvolume to blank state";
|
2023-11-04 16:12:45 +05:30
|
|
|
wantedBy = [ "initrd.target" ];
|
|
|
|
after = [ "dev-vg0-system.device" ];
|
|
|
|
before = [ "sysroot.mount" ];
|
2023-04-26 22:57:32 +05:30
|
|
|
unitConfig.DefaultDependencies = "no";
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
script = ''
|
|
|
|
mkdir -p /mnt
|
|
|
|
mount -o subvol=/ /dev/vg0/system /mnt
|
2023-04-26 22:56:43 +05:30
|
|
|
|
2023-04-26 22:57:32 +05:30
|
|
|
btrfs subvolume list -o /mnt/@root | cut -f9 -d' ' | while read subvolume; do
|
2023-04-26 22:56:43 +05:30
|
|
|
echo "deleting /$subvolume subvolume..."
|
|
|
|
btrfs subvolume delete "/mnt/$subvolume"
|
|
|
|
done &&
|
2023-04-26 22:57:32 +05:30
|
|
|
echo "deleting /root subvolume..." &&
|
|
|
|
btrfs subvolume delete "/mnt/@root"
|
2023-04-26 22:56:43 +05:30
|
|
|
|
2023-04-26 22:57:32 +05:30
|
|
|
echo "restoring blank /root subvolume..."
|
|
|
|
btrfs subvolume snapshot "/mnt/@root-blank" "/mnt/@root"
|
2023-04-26 22:56:43 +05:30
|
|
|
|
2023-04-26 22:57:32 +05:30
|
|
|
echo "deleting /home subvolume..."
|
|
|
|
btrfs subvolume delete "/mnt/@home"
|
2023-04-26 22:56:43 +05:30
|
|
|
|
2023-04-26 22:57:32 +05:30
|
|
|
echo "restoring blank /home subvolume..."
|
|
|
|
btrfs subvolume snapshot "/mnt/@home-blank" "/mnt/@home"
|
2023-04-26 22:56:43 +05:30
|
|
|
|
2023-04-26 22:57:32 +05:30
|
|
|
umount /mnt
|
|
|
|
'';
|
|
|
|
};
|
2023-04-26 22:56:43 +05:30
|
|
|
}
|