mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-10 00:05:32 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3433754c69 | ||
|
|
db753a9ac8 | ||
|
|
83bf1da01e | ||
|
|
2f22fd8630 | ||
|
|
88a0320d62 | ||
|
|
87b816345b |
@@ -7,16 +7,16 @@
|
|||||||
#
|
#
|
||||||
# Purpose:
|
# Purpose:
|
||||||
# Improves Grub by adding "btrfs snapshots" to the Grub menu.
|
# Improves Grub by adding "btrfs snapshots" to the Grub menu.
|
||||||
# You can start your system on a "snapshot" from the Grub menu.
|
# You can boot your system on a "snapshot" from the Grub menu.
|
||||||
# Supports manual snapshots, snapper ...
|
# Supports manual snapshots, snapper, timeshift ...
|
||||||
# Warning : booting on read-only snapshots can be tricky
|
# Warning : booting on read-only snapshots can be tricky.
|
||||||
# (Read about it, https://github.com/Antynea/grub-btrfs#warning-booting-on-read-only-snapshots-can-be-tricky)
|
# (Read about it, https://github.com/Antynea/grub-btrfs#warning-booting-on-read-only-snapshots-can-be-tricky)
|
||||||
#
|
#
|
||||||
# What this script does:
|
# What this script does:
|
||||||
# - Automatically List snapshots existing on root partition (btrfs).
|
# - Automatically List snapshots existing on root partition (btrfs).
|
||||||
# - Automatically Detect if "/boot" is in separate partition.
|
# - Automatically Detect if "/boot" is in separate partition.
|
||||||
# - Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots.
|
# - Automatically Detect kernel, initramfs and intel/amd microcode in "/boot" directory on snapshots.
|
||||||
# - Automatically Create corresponding "menuentry" in grub.cfg
|
# - Automatically Create corresponding "menuentry" in grub.cfg.
|
||||||
# - Automatically detect snapper and use snapper's snapshot description if available.
|
# - Automatically detect snapper and use snapper's snapshot description if available.
|
||||||
# - Automatically generate grub.cfg if you use the provided systemd service.
|
# - Automatically generate grub.cfg if you use the provided systemd service.
|
||||||
#
|
#
|
||||||
@@ -24,15 +24,11 @@
|
|||||||
# - Run `make install` or look into Makefile for instructions on where to put each file.
|
# - Run `make install` or look into Makefile for instructions on where to put each file.
|
||||||
#
|
#
|
||||||
# Customization:
|
# Customization:
|
||||||
# Refer to config for the list of available options and their default values.
|
# You have the possibility to modify many parameters in /etc/default/grub-btrfs/config.
|
||||||
# Place your configurations to /etc/default/grub-btrfs/config.
|
|
||||||
#
|
#
|
||||||
# Automatically update Grub
|
# Automatically update Grub
|
||||||
# If you would like Grub to automatically update when a snapshots is made or deleted:
|
# If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
|
||||||
# - Use systemctl start/enable grub-btrfs.path
|
# - Refer to https://github.com/Antynea/grub-btrfs#automatically-update-grub.
|
||||||
# - 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
|
|
||||||
# - See https://github.com/Antynea/grub-btrfs#automatically-update-grub
|
|
||||||
#
|
#
|
||||||
# Special thanks for assistance and contributions:
|
# Special thanks for assistance and contributions:
|
||||||
# - My friends
|
# - My friends
|
||||||
|
|||||||
31
Makefile
31
Makefile
@@ -1,19 +1,25 @@
|
|||||||
PKGNAME ?= grub-btrfs
|
PKGNAME ?= grub-btrfs
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
|
|
||||||
|
INITCPIO ?= false
|
||||||
|
|
||||||
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
|
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
|
||||||
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
|
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
|
||||||
|
|
||||||
.PHONY: install uninstall help
|
.PHONY: install uninstall help
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@if test "$(shell id -u)" != 0; then \
|
||||||
|
echo "You are not root, run this target as root please."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
@install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs
|
@install -Dm755 -t "$(DESTDIR)/etc/grub.d/" 41_snapshots-btrfs
|
||||||
@install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config
|
@install -Dm644 -t "$(DESTDIR)/etc/default/grub-btrfs/" config
|
||||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service
|
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.service
|
||||||
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path
|
@install -Dm644 -t "$(LIB_DIR)/systemd/system/" grub-btrfs.path
|
||||||
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
||||||
@# Arch Linux like distros only :
|
@# Arch Linux like distros only :
|
||||||
@if command -V mkinitcpio >/dev/null 2>&1; then \
|
@if test "$(INITCPIO)" = true; then \
|
||||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \
|
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-install" "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"; \
|
||||||
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
|
install -Dm644 "initramfs/Arch Linux/overlay_snap_ro-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
|
||||||
fi
|
fi
|
||||||
@@ -21,6 +27,10 @@ install:
|
|||||||
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
|
@if test "$(shell id -u)" != 0; then \
|
||||||
|
echo "You are not root, run this target as root please."; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
@grub_dirname="$$(grep -oP '^[[:space:]]*GRUB_BTRFS_GRUB_DIRNAME=\K.*' "$(DESTDIR)/etc/default/grub-btrfs/config" | sed "s|\s*#.*||;s|(\s*\(.\+\)\s*)|\1|;s|['\"]||g")"; \
|
@grub_dirname="$$(grep -oP '^[[:space:]]*GRUB_BTRFS_GRUB_DIRNAME=\K.*' "$(DESTDIR)/etc/default/grub-btrfs/config" | sed "s|\s*#.*||;s|(\s*\(.\+\)\s*)|\1|;s|['\"]||g")"; \
|
||||||
rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
|
rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
|
||||||
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||||
@@ -29,8 +39,8 @@ uninstall:
|
|||||||
@rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path"
|
@rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path"
|
||||||
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
|
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
|
||||||
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
|
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
|
||||||
@# Arch Linux unlike distros only :
|
@# Arch Linux UNlike distros only :
|
||||||
@if ! command -V mkinitcpio >/dev/null 2>&1; then \
|
@if test "$(INITCPIO)" != true && test -d "$(LIB_DIR)/initcpio"; then \
|
||||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \
|
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/install" || :; \
|
||||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \
|
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio/hooks" || :; \
|
||||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
|
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
|
||||||
@@ -50,11 +60,12 @@ help:
|
|||||||
@echo " uninstall"
|
@echo " uninstall"
|
||||||
@echo " help"
|
@echo " help"
|
||||||
@echo
|
@echo
|
||||||
@echo " parameters | description | defaults"
|
@echo " parameter | type | description | defaults"
|
||||||
@echo " -----------+--------------------------------+----------------------------"
|
@echo " ----------+------+--------------------------------+----------------------------"
|
||||||
@echo " DESTDIR | install destination | <unset>"
|
@echo " DESTDIR | path | install destination | <unset>"
|
||||||
@echo " PREFIX | system tree prefix | '/usr'"
|
@echo " PREFIX | path | system tree prefix | '/usr'"
|
||||||
@echo " SHARE_DIR | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
||||||
@echo " LIB_DIR | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
||||||
@echo " PKGNAME | name of the ditributed package | 'grub-btrfs'"
|
@echo " PKGNAME | name | name of the ditributed package | 'grub-btrfs'"
|
||||||
|
@echo " INITCPIO | bool | include mkinitcpio hook | false"
|
||||||
@echo
|
@echo
|
||||||
|
|||||||
47
README.md
47
README.md
@@ -6,10 +6,10 @@
|
|||||||
This is a version 4.xx of grub-btrfs
|
This is a version 4.xx of grub-btrfs
|
||||||
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
||||||
##
|
##
|
||||||
### Description
|
### Description :
|
||||||
Improves Grub by adding "btrfs snapshots" to the Grub menu.
|
Improves Grub by adding "btrfs snapshots" to the Grub menu.
|
||||||
|
|
||||||
You can start your system on a "snapshot" from the Grub menu.
|
You can boot your system on a "snapshot" from the Grub menu.
|
||||||
Supports manual snapshots, snapper, timeshift ...
|
Supports manual snapshots, snapper, timeshift ...
|
||||||
|
|
||||||
##### Warning: booting on read-only snapshots can be tricky
|
##### Warning: booting on read-only snapshots can be tricky
|
||||||
@@ -46,29 +46,52 @@ NOTE: Generate your Grub menu after installation for the changes to take effect.
|
|||||||
On Arch Linux use `grub-mkconfig -o /boot/grub/grub.cfg`.
|
On Arch Linux use `grub-mkconfig -o /boot/grub/grub.cfg`.
|
||||||
|
|
||||||
##
|
##
|
||||||
### Customization:
|
### 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.
|
See [config file](https://github.com/Antynea/grub-btrfs/blob/master/config) for more information.
|
||||||
|
|
||||||
##
|
##
|
||||||
### Automatically update grub
|
### Automatically update grub
|
||||||
If you would like Grub to automatically update when a snapshot is made or deleted:
|
1- If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
|
||||||
* Use `systemctl start/enable grub-btrfs.path`.
|
* Use `systemctl enable grub-btrfs.path`.
|
||||||
* `grub-btrfs.path` automatically (re)generates `grub.cfg` when a modification appears in `/.snapshots` folder (by default).
|
* `grub-btrfs.path` automatically (re)generates `grub-btrfs.cfg` when a modification appears in `/.snapshots` mount point (by default).
|
||||||
* If your snapshots aren't mounted in `/.snapshots`, you must modify the watch folder using `systemctl edit grub-btrfs.path`.
|
* If the `/.snapshots` mount point is already mounted, then use `systemctl start grub-btrfs.path` to start monitoring.
|
||||||
* For example: Timeshift mount its snapshots in `/run/timeshift/backup/timeshift-btrfs/snapshots` folder.
|
Otherwise, the unit will automatically start monitoring when the mount point will be available.
|
||||||
|
* If your snapshots location aren't mounted in `/.snapshots`, you must modify `grub-btrfs.path` unit using
|
||||||
|
`systemctl edit --full grub-btrfs.path` and run `systemctl reenable grub-btrfs.path` for changes take effect.
|
||||||
|
To find out the name of the `.mount` unit
|
||||||
|
use `systemctl list-units -t mount`.
|
||||||
|
* For example: Timeshift mounts its snapshot folder in `/run/timeshift/backup/timeshift-btrfs/snapshots`.
|
||||||
|
|
||||||
Use `systemctl edit grub-btrfs.path`.
|
Use `systemctl edit --full grub-btrfs.path`.
|
||||||
Then wrote:
|
Then replace the whole block by:
|
||||||
```
|
```
|
||||||
|
[Unit]
|
||||||
|
Description=Monitors for new snapshots
|
||||||
|
DefaultDependencies=no
|
||||||
|
Requires=run-timeshift-backup.mount
|
||||||
|
After=run-timeshift-backup.mount
|
||||||
|
BindsTo=run-timeshift-backup.mount
|
||||||
|
|
||||||
[Path]
|
[Path]
|
||||||
PathModified=/run/timeshift/backup/timeshift-btrfs/snapshots
|
PathModified=/run/timeshift/backup/timeshift-btrfs/snapshots
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=run-timeshift-backup.mount
|
||||||
```
|
```
|
||||||
and finally save.
|
Then save and finally run `systemctl reenable grub-btrfs.path` for changes take effect.
|
||||||
|
Optional:
|
||||||
|
If the `/run/timeshift/backup/timeshift-btrfs/snapshots` mount point is already mounted,
|
||||||
|
then use `systemctl start grub-btrfs.path` to start monitoring.
|
||||||
|
Otherwise, the unit will automatically start monitoring when the mount point will be available.
|
||||||
* You can view your change to `systemctl cat grub-btrfs.path`.
|
* You can view your change to `systemctl cat grub-btrfs.path`.
|
||||||
* To revert change use `systemctl revert grub-btrfs.path`.
|
* To revert change use `systemctl revert grub-btrfs.path`.
|
||||||
##### Warning:
|
|
||||||
|
2- If you would like grub-btrfs menu to automatically update on system restart/shutdown:
|
||||||
|
[Look at this comment](https://github.com/Antynea/grub-btrfs/issues/138#issuecomment-766918328)
|
||||||
|
Currently not implemented
|
||||||
|
##### Warning :
|
||||||
by default, `grub-mkconfig` command is used.
|
by default, `grub-mkconfig` command is used.
|
||||||
Might be `grub2-mkconfig` on some systems (Fedora ...).
|
Might be `grub2-mkconfig` on some systems (Fedora ...).
|
||||||
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this.
|
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this.
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Monitors for new snapshots
|
Description=Monitors for new snapshots
|
||||||
|
DefaultDependencies=no
|
||||||
|
Requires=\x2esnapshots.mount
|
||||||
|
After=\x2esnapshots.mount
|
||||||
|
BindsTo=\x2esnapshots.mount
|
||||||
|
|
||||||
[Path]
|
[Path]
|
||||||
PathModified=/.snapshots
|
PathModified=/.snapshots
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=\x2esnapshots.mount
|
||||||
|
|||||||
Reference in New Issue
Block a user