diff --git a/Makefile b/Makefile index 6d62613..200967c 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ install: @install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service @install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path @install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE + @install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" # Arch Linux only + @install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" # Arch Linux only + @install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md + @install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md" uninstall: rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs" @@ -20,4 +24,8 @@ uninstall: rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path" rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE" rm -f "$(DESTDIR)/boot/grub/grub-btrfs.cfg" + rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs" # Arch Linux only + rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs" # Arch Linux only + rm -rf "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md + rm -rf "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md" rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" diff --git a/README.md b/README.md index 98eae41..9e6a998 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,18 @@ This is a version 4.xx of grub-btrfs ### Description Improves Grub by adding "btrfs snapshots" to the Grub menu. -You can start your system on a "snapshot" from the Grub menu. - +You can start your system on a "snapshot" from the Grub menu. Supports manual snapshots, snapper, timeshift ... ##### Warning: booting on read-only snapshots can be tricky -If you choose to do it, `/var/log` must be on a separate subvolume. - -Otherwise, make sure your snapshots are writeable. - +If you choose to do it, `/var/log` or even `/var` must be on a separate subvolume. +Otherwise, make sure your snapshots are writeable. See [this ticket](https://github.com/Antynea/grub-btrfs/issues/92) for more info. +This project includes its own solution. +Refer to the [documentation](https://github.com/Antynea/grub-btrfs/blob/boot-read-only-snapshot/initramfs/readme.md). + ## ### What does grub-btrfs v4.xx do : * Automatically List snapshots existing on root partition (btrfs). @@ -38,19 +38,17 @@ See [this ticket](https://github.com/Antynea/grub-btrfs/issues/92) for more info pacman -S grub-btrfs ``` -### Manual +#### Manual * Run `make install` or look into Makefile for instructions on where to put each file. -NOTE: Generate your Grub menu after installation for the changes to take effect. - +NOTE: Generate your Grub menu after installation for the changes to take effect. On Arch Linux use `grub-mkconfig -o /boot/grub/grub.cfg`. ## ### Customization: -You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`. - +You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`. See [config file](https://github.com/Antynea/grub-btrfs/blob/master/config) for more information. ## @@ -58,8 +56,7 @@ See [config file](https://github.com/Antynea/grub-btrfs/blob/master/config) for If you would like Grub to automatically update when a snapshot is made or deleted: * Use `systemctl start/enable grub-btrfs.path`. * `grub-btrfs.path` automatically (re)generates `grub.cfg` when a modification appears in `/.snapshots` folder (by default). -* If your snapshots aren't mounted in `/.snapshots`, you must modify the watch folder using `systemctl edit grub-btrfs.path`. - +* If your snapshots aren't mounted in `/.snapshots`, you must modify the watch folder using `systemctl edit grub-btrfs.path`. * For example: Timeshift mount its snapshots in `/run/timeshift/backup/timeshift-btrfs/snapshots` folder. Use `systemctl edit grub-btrfs.path`. @@ -74,11 +71,5 @@ If you would like Grub to automatically update when a snapshot is made or delete ## ### Special thanks for assistance and contributions * [maximbaz](https://github.com/maximbaz) -* [crossroads1112](https://github.com/crossroads1112) -* [penetal](https://github.com/penetal) -* [wesbarnett](https://github.com/wesbarnett) -* [Psykar](https://github.com/Psykar) -* [anyc](https://github.com/anyc) -* [daftaupe](https://github.com/daftaupe) -* [N-Parsons](https://github.com/N-Parsons) +* [All contributors](https://github.com/Antynea/grub-btrfs/graphs/contributors) ## diff --git a/initramfs/Arch Linux/overlay_snap_ro-hook b/initramfs/Arch Linux/overlay_snap_ro-hook new file mode 100644 index 0000000..07e3b8b --- /dev/null +++ b/initramfs/Arch Linux/overlay_snap_ro-hook @@ -0,0 +1,15 @@ +#!/usr/bin/ash + +run_latehook() { + local root_mnt="/new_root" + local current_dev=$(resolve_device "$root"); # resolve devices for blkid + if [[ $(blkid "${current_dev}" -s TYPE -o value) = "btrfs" ]] && [[ $(btrfs property get ${root_mnt} ro) != "ro=false" ]]; then # run only on a read only snapshot + local lower_dir=$(mktemp -d -p /) + local ram_dir=$(mktemp -d -p /) + mount --move ${root_mnt} ${lower_dir} # move new_root to lower_dir + mount -t tmpfs cowspace ${ram_dir} #meuh!!! space, you can't test ! + mkdir -p ${ram_dir}/upper + mkdir -p ${ram_dir}/work + mount -t overlay -o lowerdir=${lower_dir},upperdir=${ram_dir}/upper,workdir=${ram_dir}/work rootfs ${root_mnt} + fi +} diff --git a/initramfs/Arch Linux/overlay_snap_ro-install b/initramfs/Arch Linux/overlay_snap_ro-install new file mode 100644 index 0000000..2c16291 --- /dev/null +++ b/initramfs/Arch Linux/overlay_snap_ro-install @@ -0,0 +1,18 @@ +#!/bin/bash + +build() { + add_module btrfs + add_module overlay + add_binary btrfs + add_binary btrfsck + add_binary blkid + add_runscript +} + +help() { + cat <