Skip to content

sabuj66/atomic-snapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

atomic-snapper

Screenshot

screenshot

What this script does

  • Takes Btrfs snapshots of your live system.
  • Extracts the kernel and initramfs from that exact snapshot.
  • Build them into a single UKI using efibootguard similar to objcopy.
  • Signs the UKI with your Secure Boot keys using sbsigntools.
  • Automatically cleans up old snapshots, UKIs and limine entries.
  • Builds a Limine boot menu with BLAKE2B hash, similar to limine-entry-tool.
  • Support adding snapshot entries for multiple operating systems.

Configure the variables for your system by following the script instructions.

Requirements

A minimal Linux system using LUKS+Btrfs with limine Bootloader, efibootguard and basic util-linux. And Add a optionally notification sender like fyi.

Currently OpenRC, runit, S6 and systemd can boot read-only snapshots, but Dinit systems may require write access on /etc, so only writable snapshots can boot up.

Example Btrfs layout

Subvolume Mount Point
@ /
@home /home
@.snapshots /.snapshots
@var_cache /var/cache
@var_log /var/log
@var_tmp /var/tmp
@opt /opt
@tmp /tmp
@swap /swap

And ESP should be mounted under /efi.

Running

Run the script with -v or --verbose for verbosity.

atomic-snapper --verbose

Example Recovery from root snapshot

Boot into one of your snapshots from Limine

Mount the Top Level

mount -o subvolid=5 /dev/mapper/root /mnt

Moving the Broken Root

mv /mnt/@ /mnt/@_broken

Clone one of your latest origin generation Snapshot into the Writable root

btrfs subvolume snapshot /mnt/@.snapshots/@-2077 /mnt/@

After restored

umount /mnt
reboot

Once you confirm everything works, you can mount the root and then btrfs subvolume delete /mnt/@_broken.

Why

  • Its fast, portable and minimal, you can run with any service or cron job schedule, or hook into anywhere with zero maintainance.

  • It uses Btrfs immutable ogen for tagging snapshots instead of any xml db, so it never causes duplication and not affected by wrong system time/date.

  • It uses UKI, which makes it easy to Secure Boot and ensures the kernel cmdline is safe from modification from an unencrypted storage.

About

A single bash script for creating Bootable Btrfs snapshots with UKI and syncing with Limine, especially made for non-systemd systems

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages