mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-04 21:15:02 +08:00
Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8142691be1 | ||
|
|
bab78d4ed8 | ||
|
|
544d2e84ac | ||
|
|
b346727219 | ||
|
|
f1ca0db36d | ||
|
|
c4d0df3a97 | ||
|
|
c1cadccd1f | ||
|
|
8cc214fd0e | ||
|
|
81bde02b03 | ||
|
|
14bf041ba6 | ||
|
|
863107588c | ||
|
|
2851ecd72b | ||
|
|
679d000446 | ||
|
|
981777d745 | ||
|
|
3433754c69 | ||
|
|
db753a9ac8 | ||
|
|
83bf1da01e | ||
|
|
2f22fd8630 | ||
|
|
88a0320d62 | ||
|
|
87b816345b | ||
|
|
d68fdf5fff | ||
|
|
87168d2d50 | ||
|
|
a437b80a35 | ||
|
|
9408231ecc | ||
|
|
9722f6732c | ||
|
|
0ed5adaf32 | ||
|
|
d4b97415b0 | ||
|
|
da36aa8847 | ||
|
|
d8df766554 | ||
|
|
9adce629f7 | ||
|
|
3c5e741641 | ||
|
|
fa65c3d6d9 | ||
|
|
4493bdc6e4 | ||
|
|
a7289b182a | ||
|
|
0fe512776a | ||
|
|
6af193c47a | ||
|
|
9a771d9842 | ||
|
|
64c08a0807 | ||
|
|
c9b605153b | ||
|
|
7e922abefb | ||
|
|
d20439554e | ||
|
|
ce8261395f | ||
|
|
133c8ebfdb | ||
|
|
2349282df5 | ||
|
|
041a9c6606 | ||
|
|
7e5bfa597f | ||
|
|
f0382536fb | ||
|
|
b50ad439d4 | ||
|
|
5f40f30985 | ||
|
|
d2c15acd72 | ||
|
|
77d69aaa81 | ||
|
|
44ee10f5ef | ||
|
|
9cb57dab40 |
File diff suppressed because it is too large
Load Diff
59
Makefile
59
Makefile
@@ -1,14 +1,71 @@
|
||||
PKGNAME ?= grub-btrfs
|
||||
PREFIX ?= /usr
|
||||
|
||||
INITCPIO ?= false
|
||||
|
||||
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
|
||||
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
|
||||
|
||||
.PHONY: install
|
||||
.PHONY: install uninstall help
|
||||
|
||||
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 -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.path
|
||||
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
||||
@# Arch Linux like distros only :
|
||||
@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-hook" "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"; \
|
||||
fi
|
||||
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
||||
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
|
||||
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")"; \
|
||||
rm -f "$${grub_dirname:-/boot/grub}/grub-btrfs.cfg"
|
||||
@rm -f "$(DESTDIR)/etc/default/grub-btrfs/config"
|
||||
@rm -f "$(DESTDIR)/etc/grub.d/41_snapshots-btrfs"
|
||||
@rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.service"
|
||||
@rm -f "$(LIB_DIR)/systemd/system/grub-btrfs.path"
|
||||
@rm -f "$(LIB_DIR)/initcpio/install/grub-btrfs-overlayfs"
|
||||
@rm -f "$(LIB_DIR)/initcpio/hooks/grub-btrfs-overlayfs"
|
||||
@# Arch Linux UNlike distros only :
|
||||
@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/hooks" || :; \
|
||||
rmdir --ignore-fail-on-non-empty "$(LIB_DIR)/initcpio" || :; \
|
||||
fi
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/README.md"
|
||||
@rm -f "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||
@rm -f "$(SHARE_DIR)/licenses/$(PKGNAME)/LICENSE"
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/doc/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(SHARE_DIR)/licenses/$(PKGNAME)/" || :
|
||||
@rmdir --ignore-fail-on-non-empty "$(DESTDIR)/etc/default/grub-btrfs" || :
|
||||
|
||||
help:
|
||||
@echo
|
||||
@echo "Usage: $(MAKE) [ <parameter>=<value> ... ] [ <action> ]"
|
||||
@echo
|
||||
@echo " actions: install"
|
||||
@echo " uninstall"
|
||||
@echo " help"
|
||||
@echo
|
||||
@echo " parameter | type | description | defaults"
|
||||
@echo " ----------+------+--------------------------------+----------------------------"
|
||||
@echo " DESTDIR | path | install destination | <unset>"
|
||||
@echo " PREFIX | path | system tree prefix | '/usr'"
|
||||
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
||||
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
||||
@echo " PKGNAME | name | name of the ditributed package | 'grub-btrfs'"
|
||||
@echo " INITCPIO | bool | include mkinitcpio hook | false"
|
||||
@echo
|
||||
|
||||
192
README.md
192
README.md
@@ -6,164 +6,100 @@
|
||||
This is a version 4.xx of grub-btrfs
|
||||
##### BTC donation address: `1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt`
|
||||
##
|
||||
### Description
|
||||
### 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 boot 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/master/initramfs/readme.md).
|
||||
|
||||
##
|
||||
### What does grub-btrfs v4.xx do :
|
||||
* Automatically List snapshots existing on root partition (btrfs).
|
||||
* 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 detect snapper and use snapper's snapshot description if available.
|
||||
* Automatically generate `grub.cfg` if you use the provided systemd service.
|
||||
|
||||
##
|
||||
### Installation :
|
||||
#### Arch Linux
|
||||
|
||||
The package is available in the community repository [grub-btrfs](https://archlinux.org/packages/community/any/grub-btrfs/)
|
||||
```
|
||||
pacman -S grub-btrfs
|
||||
```
|
||||
|
||||
### Manual
|
||||
#### Manual
|
||||
|
||||
* Run `make install` or look into Makefile for instructions on where to put each file.
|
||||
* Dependencies:
|
||||
* [btrfs-progs](https://archlinux.org/packages/core/x86_64/btrfs-progs/)
|
||||
* [grub](https://archlinux.org/packages/core/x86_64/grub/)
|
||||
|
||||
NOTE: Generate your Grub menu after installation for the changes to take effect.
|
||||
|
||||
On Arch Linux use `grub-mkconfig -o /boot/grub/grub.cfg`.
|
||||
|
||||
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 Debian-like distribution `update-grub` is an alias to `grub-mkconfig ...`
|
||||
##
|
||||
### Customization:
|
||||
### Customization :
|
||||
|
||||
You have the possibility to modify many parameters in `/etc/default/grub-btrfs/config`.
|
||||
|
||||
* GRUB_BTRFS_SUBMENUNAME="Arch Linux Snapshots"
|
||||
|
||||
Name appearing in the Grub menu. Use distribution information from /etc/os-release by default.
|
||||
|
||||
* GRUB_BTRFS_PREFIXENTRY="Snapshot:"
|
||||
|
||||
Add a name ahead your snapshots entries in the Grub menu.
|
||||
|
||||
* GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="true"
|
||||
|
||||
Show full path snapshot or only name in the Grub menu, weird reaction with snapper.
|
||||
|
||||
* GRUB_BTRFS_TITLE_FORMAT="p/d/n"
|
||||
|
||||
Custom title, shows/hides p"prefix" d"date" n"name" in the Grub menu, separator "/", custom order available.
|
||||
|
||||
* GRUB_BTRFS_LIMIT="50"
|
||||
|
||||
Limit the number of snapshots populated in the GRUB menu.
|
||||
|
||||
* GRUB_BTRFS_SUBVOLUME_SORT="descending"
|
||||
|
||||
Sort the found subvolumes by newest first ("descending") or oldest first ("ascending").
|
||||
|
||||
If "ascending" is chosen then
|
||||
|
||||
the $GRUB_BTRFS_LIMIT oldest subvolumes will populate the menu.
|
||||
|
||||
* GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="true"
|
||||
|
||||
Show snapshots found during run "grub-mkconfig".
|
||||
|
||||
* GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND="true"
|
||||
|
||||
Show Total number of snapshots found during run "grub-mkconfig".
|
||||
|
||||
* GRUB_BTRFS_NKERNEL=("kernel-custom")
|
||||
|
||||
Use it only if you have a custom kernel name
|
||||
|
||||
* GRUB_BTRFS_NINIT=("initramfs-custom.img" "initrd.img-custom")
|
||||
|
||||
Use it only if you have a custom initramfs name.
|
||||
|
||||
* GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img")
|
||||
|
||||
Use it only if you have custom intel-ucode.
|
||||
|
||||
* GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker")
|
||||
|
||||
Ignore specific path during run "grub-mkconfig".
|
||||
|
||||
For example:
|
||||
|
||||
If path is a directory `# Found Snapshot: 2016-03-31 10:24:41` **var/lib/docker/btrfs/subvolumes/...**
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker")`
|
||||
|
||||
If path is a subvolume : `# Found Snapshot: 2016-03-31 10:24:41` **@var/lib/docker/btrfs/subvolumes/...**
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker")`
|
||||
|
||||
You can combine them
|
||||
|
||||
use : `GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker" "var/lib/docker")`
|
||||
|
||||
|
||||
* GRUB_BTRFS_SNAPPER_CONFIG="root"
|
||||
|
||||
Snapper's config name to use.
|
||||
|
||||
* GRUB_BTRFS_DISABLE="false"
|
||||
|
||||
Disable grub-btrfs.
|
||||
|
||||
* GRUB_BTRFS_DIRNAME="grub"
|
||||
|
||||
Name of the grub folder in `/boot/`, might be grub2 on some distributions.
|
||||
|
||||
* GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="false"
|
||||
|
||||
Change to "true" if you have a boot partition in a different subvolume.
|
||||
|
||||
* GRUB_BTRFS_MKCONFIG=grub-mkconfig
|
||||
|
||||
Name or path of the 'grub-mkconfig' executable; might be 'grub2-mkconfig' on some distributions.
|
||||
|
||||
- Password protection management for submenu (refer to the [Grub documentation](https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation))
|
||||
|
||||
- GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS=""
|
||||
|
||||
Add authorized usernames separate by comma (foo,bar)
|
||||
|
||||
When Grub's password protection is enabled, the superuser is authorized by default, it isn't necessary to add it
|
||||
|
||||
- GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="false"
|
||||
|
||||
Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
|
||||
doesn't work if `GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS` isn't empty
|
||||
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.
|
||||
|
||||
##
|
||||
### Automatically update grub
|
||||
If you would like Grub to automatically update when a snapshot is made or deleted:
|
||||
* Mount your subvolume which contains snapshots to `/.snapshots`
|
||||
* Use `systemctl start/enable grub-btrfs.path`
|
||||
* `grub-btrfs.path` automatically (re)generates `grub.cfg` when a modification appears in `/.snapshots`
|
||||
1- If you would like grub-btrfs menu to automatically update when a snapshot is created or deleted:
|
||||
* Use `systemctl enable grub-btrfs.path`.
|
||||
* `grub-btrfs.path` automatically (re)generates `grub-btrfs.cfg` when a modification appears in `/.snapshots` mount point (by default).
|
||||
* If the `/.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.
|
||||
* 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 --full grub-btrfs.path`.
|
||||
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]
|
||||
PathModified=/run/timeshift/backup/timeshift-btrfs/snapshots
|
||||
|
||||
[Install]
|
||||
WantedBy=run-timeshift-backup.mount
|
||||
```
|
||||
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`.
|
||||
* To revert change use `systemctl revert grub-btrfs.path`.
|
||||
|
||||
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.
|
||||
Might be `grub2-mkconfig` on some systems (Fedora ...).
|
||||
Edit `GRUB_BTRFS_MKCONFIG` variable in `/etc/default/grub-btrfs/config` file to reflect this.
|
||||
##
|
||||
### 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)
|
||||
##
|
||||
|
||||
144
config
144
config
@@ -1,87 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Name appearing in the Grub menu
|
||||
# Default: Use distribution information from /etc/os-release
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE="true"
|
||||
|
||||
# Name appearing in the Grub menu.
|
||||
# Default: "Use distribution information from /etc/os-release."
|
||||
#GRUB_BTRFS_SUBMENUNAME="Arch Linux snapshots"
|
||||
|
||||
# Add a name ahead your snapshots entries in the Grub menu
|
||||
# Add a name ahead your snapshots entries in the Grub menu.
|
||||
# Default: "Snapshot:"
|
||||
#GRUB_BTRFS_PREFIXENTRY="Snapshot:"
|
||||
|
||||
# Show full path snapshot or only name in the Grub menu
|
||||
# Show full path snapshot or only name in the Grub menu, weird reaction with snapper.
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="true"
|
||||
#GRUB_BTRFS_DISPLAY_PATH_SNAPSHOT="false"
|
||||
|
||||
# Custom title
|
||||
# shows/hides p"prefix" d"date" n"name" in the Grub menu, separator "/", custom order available
|
||||
# Custom title.
|
||||
# shows/hides p"prefix" d"date" n"name" in the Grub menu, separator "/", custom order available.
|
||||
# Default: "p/d/n"
|
||||
#GRUB_BTRFS_TITLE_FORMAT="p/d/n"
|
||||
|
||||
# Limit the number of snapshots populated in the GRUB menu
|
||||
# Limit the number of snapshots populated in the GRUB menu.
|
||||
# Default: "50"
|
||||
#GRUB_BTRFS_LIMIT="50"
|
||||
|
||||
# Sort the found subvolumes by newest first ("descending") or oldest first ("ascending") and show $GRUB_BTRFS_LIMIT first entries.
|
||||
# Default: "descending"
|
||||
#GRUB_BTRFS_SUBVOLUME_SORT="descending"
|
||||
# Sort the found subvolumes by "ogeneration" or "generation" or "path" or "rootid".
|
||||
# # See Sorting section to https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-subvolume#SUBCOMMAND
|
||||
# "-rootid" means list snapshot by new ones first.
|
||||
# Default: "-rootid"
|
||||
#GRUB_BTRFS_SUBVOLUME_SORT="+ogen,-gen,path,rootid"
|
||||
|
||||
# Show snapshots found during run "grub-mkconfig"
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="true"
|
||||
#GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND="false"
|
||||
|
||||
# Show Total of snapshots found during run "grub-mkconfig"
|
||||
# Default: "true"
|
||||
#GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND="true"
|
||||
|
||||
# Use only if you have custom kernel name
|
||||
# Default:
|
||||
#GRUB_BTRFS_NKERNEL=("vmlinuz-linux")
|
||||
# By default, "grub-btrfs" automatically detects most existing kernels.
|
||||
# If you have one or more custom kernels, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_NKERNEL=("kernel-custom" "vmlinux-custom")
|
||||
|
||||
# Use only if you have custom initramfs name
|
||||
# Default:
|
||||
#GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img")
|
||||
# By default, "grub-btrfs" automatically detects most existing initramfs.
|
||||
# If you have one or more custom initramfs, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_NINIT=("initramfs-custom.img" "initrd-custom.img" "otherinit-custom.gz")
|
||||
|
||||
# Use only if you have custom intel-ucode
|
||||
# Default:
|
||||
#GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img")
|
||||
# By default, "grub-btrfs" automatically detects most existing microcodes.
|
||||
# If you have one or more custom microcodes, you can add them here.
|
||||
# Default: ("")
|
||||
#GRUB_BTRFS_CUSTOM_MICROCODE=("custom-ucode.img" "custom-uc.img "custom_ucode.cpio")
|
||||
|
||||
# Comma seperated mount options to be used when booting a snapshot.
|
||||
# They can be defined here as well as in the "/" line inside the respective snapshots'
|
||||
# "/etc/fstab" files. Mount options found in both places are combined, and this variable
|
||||
# takes priority over `fstab` entries.
|
||||
# NB: Do NOT include "subvol=..." or "subvolid=..." here.
|
||||
# Default: ""
|
||||
#GRUB_BTRFS_ROOTFLAGS="space_cache,commit=10,norecovery"
|
||||
|
||||
# Ignore specific path during run "grub-mkconfig".
|
||||
# If path is a directory, # Found Snapshot: 2016-03-31 10:24:41 var/lib/docker/btrfs/subvolumes/...
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker");
|
||||
# If path is a subvolume, # Found Snapshot: 2016-03-31 10:24:41 @var/lib/docker/btrfs/subvolumes/...
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker");
|
||||
# You can combine them
|
||||
# use : GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@var/lib/docker" "var/lib/docker")
|
||||
# Default:
|
||||
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@" "var/lib/docker" "@var/lib/docker")
|
||||
# Only exact paths are ignored.
|
||||
# e.g : if `specific path` = @, only `@` snapshot will be ignored.
|
||||
# Default: ("@")
|
||||
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@")
|
||||
|
||||
# Ignore prefix path during run "grub-mkconfig".
|
||||
# Any path starting with the specified string will be ignored.
|
||||
# e.g : if `prefix path` = @, all snapshots beginning with "@/..." will be ignored.
|
||||
# Default: ("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
|
||||
GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker")
|
||||
|
||||
# Ignore specific type of snapper's snapshot during run "grub-mkconfig".
|
||||
# Type = single, pre, post.
|
||||
# Default: ("")
|
||||
GRUB_BTRFS_IGNORE_SNAPPER_TYPE=("")
|
||||
|
||||
# Ignore specific description of snapper's snapshot during run "grub-mkconfig".
|
||||
# Default: ("")
|
||||
GRUB_BTRFS_IGNORE_SNAPPER_DESCRIPTION=("")
|
||||
|
||||
# By default "grub-btrfs" automatically detects your boot partition,
|
||||
# either located at the system root or on a separate partition,
|
||||
# but cannot detect if it is in a subvolume.
|
||||
# Change to "true" if you have a boot partition in a different subvolume.
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="true"
|
||||
|
||||
# Location of the folder containing the "grub.cfg" file.
|
||||
# Use by grub-btrfs to save the file "grub-btrfs.cfg".
|
||||
# Might be grub2 on some systems.
|
||||
# For example, on Fedora with EFI : "/boot/efi/EFI/fedora"
|
||||
# Default: "/boot/grub"
|
||||
#GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"
|
||||
|
||||
# Location of kernels/initramfs/microcode.
|
||||
# Use by "grub-btrfs" to detect the boot partition and the location of kernels/initrafms/microcodes.
|
||||
# Default: "/boot"
|
||||
#GRUB_BTRFS_BOOT_DIRNAME="/boot"
|
||||
|
||||
# Name/path of grub-mkconfig command, use by "grub-btrfs.service"
|
||||
# Might be 'grub2-mkconfig' on some systems (Fedora ...)
|
||||
# Default paths are /sbin:/bin:/usr/sbin:/usr/bin,
|
||||
# if your path is missing, report it on the upstream project.
|
||||
# For example, on Fedora : "/sbin/grub2-mkconfig"
|
||||
# You can use only name or full path.
|
||||
# Default: grub-mkconfig
|
||||
#GRUB_BTRFS_MKCONFIG=/usr/bin/grub2-mkconfig
|
||||
|
||||
# Snapper
|
||||
# Snapper's config name to use
|
||||
# Default: "root"
|
||||
#GRUB_BTRFS_SNAPPER_CONFIG="root"
|
||||
|
||||
# Disable Grub-btrfs
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE="false"
|
||||
|
||||
# Change to "true" if you have a boot partition in a different subvolume
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_OVERRIDE_BOOT_PARTITION_DETECTION="false"
|
||||
|
||||
# Might be grub2 on some systems ex. /boot/grub2/...
|
||||
# Default: "grub"
|
||||
#GRUB_BTRFS_DIRNAME="grub"
|
||||
|
||||
# Might be 'grub2-mkconfig' on some systems
|
||||
# Default: /usr/bin/grub-mkconfig
|
||||
#GRUB_BTRFS_MKCONFIG=/usr/bin/grub2-mkconfig
|
||||
|
||||
## Password protection management for submenu,snapshots
|
||||
# Password protection management for submenu,snapshots
|
||||
# Refer to the Grub documentation https://www.gnu.org/software/grub/manual/grub/grub.html#Authentication-and-authorisation
|
||||
# and this comment https://github.com/Antynea/grub-btrfs/issues/95#issuecomment-682295660
|
||||
#
|
||||
# Add authorized usernames separate by comma (foo,bar)
|
||||
# When Grub's password protection is enabled, the superuser is authorized by default, it isn't necessary to add it
|
||||
# Default:
|
||||
# GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS=""
|
||||
# Default: ""
|
||||
#GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS="foo,bar"
|
||||
#
|
||||
# Disable authentication support for submenu of Grub-btrfs only (--unrestricted)
|
||||
# doesn't work if GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS isn't empty
|
||||
# Default: false
|
||||
# GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="false"
|
||||
# Default: "false"
|
||||
#GRUB_BTRFS_DISABLE_PROTECTION_SUBMENU="true"
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
[Unit]
|
||||
Description=Monitors for new snapshots
|
||||
DefaultDependencies=no
|
||||
Requires=\x2esnapshots.mount
|
||||
After=\x2esnapshots.mount
|
||||
BindsTo=\x2esnapshots.mount
|
||||
|
||||
[Path]
|
||||
PathModified=/.snapshots
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=\x2esnapshots.mount
|
||||
|
||||
@@ -8,4 +8,4 @@ Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
# Load environment variables from the configuration
|
||||
EnvironmentFile=/etc/default/grub-btrfs/config
|
||||
# Regenerate just '/boot/grub/grub-btrfs.cfg' if it exists and is not empty, else regenerate the whole grub menu
|
||||
ExecStart=/bin/bash -c 'if [ -s "/boot/${GRUB_BTRFS_DIRNAME:-grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-/usr/bin/grub-mkconfig} -o /boot/${GRUB_BTRFS_DIRNAME:-grub}/grub.cfg; fi'
|
||||
ExecStart=bash -c 'if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi'
|
||||
|
||||
15
initramfs/Arch Linux/overlay_snap_ro-hook
Normal file
15
initramfs/Arch Linux/overlay_snap_ro-hook
Normal file
@@ -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
|
||||
}
|
||||
18
initramfs/Arch Linux/overlay_snap_ro-install
Normal file
18
initramfs/Arch Linux/overlay_snap_ro-install
Normal file
@@ -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 <<HELPEOF
|
||||
This hook uses overlayfs to boot on a read only snapshot.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
45
initramfs/readme.md
Normal file
45
initramfs/readme.md
Normal file
@@ -0,0 +1,45 @@
|
||||
### Description :
|
||||
|
||||
Booting on a snapshot in read-only mode can be tricky.
|
||||
An elegant way is to boot this snapshot using overlayfs (included in the kernel ≥ 3.18).
|
||||
|
||||
Using overlayfs, the booted snapshot will behave like a live-cd in non-persistent mode.
|
||||
The snapshot will not be modified, the system will be able to boot correctly, because a writeable folder will be included in the ram.
|
||||
(no more problems due to `/var` not open for writing)
|
||||
|
||||
Any changes in this system thus started will be lost when the system is rebooted/shutdown.
|
||||
|
||||
To do this, it is necessary to modify the initramfs.
|
||||
This means that any snapshot that does not include this modified initramfs will not be able to benefit from it.
|
||||
(except for separate boot partitions)
|
||||
#
|
||||
### Installation :
|
||||
#### Arch Linux
|
||||
1.
|
||||
`Pacman -S grub-btrfs`
|
||||
Or if you use git
|
||||
copy the `overlay_snap_ro-install` file to `/etc/initcpio/install/grub-btrfs-overlayfs`
|
||||
copy the `overlay_snap_ro-hook` file to `/etc/initcpio/hooks/grub-btrfs-overlayfs`
|
||||
You must rename the files. (I did it above)
|
||||
|
||||
For example :
|
||||
`overlay_snap_ro-install` to `grub-btrfs-overlayfs`
|
||||
`overlay_snap_ro-hook` to `grub-btrfs-overlayfs`
|
||||
Keep in mind that the files must have exactly the same name to ensure a match.
|
||||
|
||||
2.
|
||||
Edit the file `/etc/mkinitcpio.conf`
|
||||
Added hook `grub-btrfs-overlayfs` at the end of the line `HOOKS`.
|
||||
|
||||
For example :
|
||||
`HOOKS=(base udev autodetect modconf block filesystems keyboard fsck grub-btrfs-overlayfs)`
|
||||
You notice that the name of the `hook` must match the name of the 2 installed files. (don't forget it)
|
||||
|
||||
3.
|
||||
Re-generate your initramfs
|
||||
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
|
||||
|
||||
#### Other distribution
|
||||
Refer to your distribution's documentation
|
||||
or contribute to this project to add a paragraph.
|
||||
#
|
||||
Reference in New Issue
Block a user