mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-08-19 21:28:24 +08:00
Compare commits
24 Commits
5b567255e3
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a136a7c989 | ||
|
|
13cb7d46b0 | ||
|
|
6845af429b | ||
|
|
4a0a27bef1 | ||
|
|
474771981f | ||
|
|
e929a4b010 | ||
|
|
eb87f5101f | ||
|
|
aea2b0aa1c | ||
|
|
85589d735a | ||
|
|
141c795a1d | ||
|
|
7306aad97d | ||
|
|
3162276a22 | ||
|
|
3979c534f4 | ||
|
|
4e12747226 | ||
|
|
d785137f55 | ||
|
|
b5670caba5 | ||
|
|
4669f59d47 | ||
|
|
531f3676b7 | ||
|
|
efece5eeb2 | ||
|
|
fe2028b623 | ||
|
|
aeda46c2a0 | ||
|
|
8fb00c532a | ||
|
|
97ae2976f9 | ||
|
|
86345e0d38 |
8
.github/workflows/bump-version-on-merge.yml
vendored
8
.github/workflows/bump-version-on-merge.yml
vendored
@@ -15,20 +15,20 @@ jobs:
|
||||
if: github.actor != 'github-actions[bot]'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-tags: true
|
||||
|
||||
- name: Update version in config
|
||||
run: |
|
||||
version="$(git describe --tags --abbrev=0)-$(git rev-parse --abbrev-ref HEAD)-$(date -u -Iseconds)"
|
||||
version="master-$(date -u -Iseconds)"
|
||||
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${version}/" config
|
||||
echo "VERSION=${version}" >> $GITHUB_ENV
|
||||
|
||||
- name: Commit updated config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add config
|
||||
git commit -m "chore: bump version to ${version}"
|
||||
git commit -m "chore: bump version to ${{ env.VERSION }}"
|
||||
git push origin master
|
||||
|
||||
8
.github/workflows/bump-version.yml
vendored
8
.github/workflows/bump-version.yml
vendored
@@ -14,20 +14,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-tags: true
|
||||
|
||||
- name: Update version in config
|
||||
run: |
|
||||
version="$(git describe --tags --abbrev=0)"
|
||||
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${version}/" config
|
||||
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${{ github.ref_name }}/" config
|
||||
|
||||
- name: Commit updated config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add config
|
||||
git commit -m "chore: bump version to ${version}"
|
||||
git commit -m "chore: bump version to ${{ github.ref_name }}"
|
||||
git push origin master
|
||||
|
||||
3
.github/workflows/codespell.yml
vendored
3
.github/workflows/codespell.yml
vendored
@@ -14,9 +14,8 @@ jobs:
|
||||
codespell:
|
||||
name: Check for spelling errors
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Codespell
|
||||
uses: codespell-project/actions-codespell@v2
|
||||
|
||||
@@ -44,12 +44,21 @@ grub_btrfs_config="${sysconfdir}/default/grub-btrfs/config"
|
||||
[ -f "$grub_btrfs_config" ] && . "$grub_btrfs_config"
|
||||
[ -f "${sysconfdir}/default/grub" ] && . "${sysconfdir}/default/grub"
|
||||
|
||||
## Error Handling
|
||||
## Logging
|
||||
print_info()
|
||||
{
|
||||
printf "grub-btrfs: %s\n" "$*" >&2
|
||||
}
|
||||
|
||||
print_warning()
|
||||
{
|
||||
printf "grub-btrfs: Warning: %s\n" "$*" >&2
|
||||
}
|
||||
|
||||
print_error()
|
||||
{
|
||||
local err_msg="$*"
|
||||
local bug_report="If you think an error has occurred, please file a bug report at \"https://github.com/Antynea/grub-btrfs\""
|
||||
printf "%s\n" "${err_msg}" "${bug_report}" >&2 ;
|
||||
printf "grub-btrfs: Error: %s\n" "$*" "${bug_report}" >&2
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -75,12 +84,12 @@ while getopts :V-: opt; do
|
||||
done
|
||||
|
||||
## Exit the script, if:
|
||||
[ "$(echo "$GRUB_BTRFS_DISABLE" | tr '[:upper:]' '[:lower:]')" = 'true' ] && print_error "GRUB_BTRFS_DISABLE is set to true (default=false)"
|
||||
if ! type btrfs >/dev/null 2>&1; then print_error "btrfs-progs isn't installed"; fi
|
||||
[ "$(echo "$GRUB_BTRFS_DISABLE" | tr '[:upper:]' '[:lower:]')" = 'true' ] && { print_info "GRUB_BTRFS_DISABLE is set to true (default=false)"; exit 0; }
|
||||
if ! type btrfs >/dev/null 2>&1; then print_info "btrfs-progs isn't installed"; exit 0; fi
|
||||
[ -f "${GRUB_BTRFS_MKCONFIG_LIB:-/usr/share/grub/grub-mkconfig_lib}" ] && . "${GRUB_BTRFS_MKCONFIG_LIB:-/usr/share/grub/grub-mkconfig_lib}" || print_error "grub-mkconfig_lib couldn't be found"
|
||||
[[ "$(btrfs filesystem df / 2>&1)" == *"not a btrfs filesystem"* ]] && print_error "Root filesystem isn't btrfs"
|
||||
[[ "$(btrfs filesystem df / 2>&1)" == *"not a btrfs filesystem"* ]] && { print_info "Root filesystem isn't btrfs"; exit 0; }
|
||||
|
||||
printf "Detecting snapshots ...\n" >&2 ;
|
||||
print_info "Detecting snapshots ..."
|
||||
|
||||
## Submenu name
|
||||
distro=$(awk -F "=" '/^NAME=/ {gsub(/"/, "", $2); print $2}' /etc/os-release) # escape '
|
||||
@@ -686,7 +695,7 @@ fi
|
||||
# if no snapshot found, delete the "$grub_btrfs_directory/grub-btrfs.new" file and the "$grub_btrfs_directory/grub-btrfs.cfg.bkp" file and exit
|
||||
if [ "${count_limit_snap}" = "0" ] || [ -z "${count_limit_snap}" ]; then
|
||||
rm -f "$grub_btrfs_directory/grub-btrfs.new" "$grub_btrfs_directory/grub-btrfs.cfg.bkp"
|
||||
print_error "No snapshots found."
|
||||
print_info "No snapshots found."; exit 0
|
||||
fi
|
||||
# Move "grub-btrfs.new" to "grub-btrfs.cfg"
|
||||
header_menu
|
||||
|
||||
@@ -240,7 +240,7 @@ sudo rc-service grub-btrfsd start
|
||||
|
||||
To activate it during system startup, run:
|
||||
```bash
|
||||
sudo rc-config add grub-btrfsd default
|
||||
sudo rc-update add grub-btrfsd default
|
||||
```
|
||||
|
||||
##### 💼 Snapshots not in `/.snapshots` for OpenRC
|
||||
|
||||
10
config
10
config
@@ -1,15 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
GRUB_BTRFS_VERSION=-master-2026-05-10T10:13:56+00:00
|
||||
|
||||
# Distribution specific auto-detection (e.g. Fedora)
|
||||
if [ -f /etc/fedora-release ]; then
|
||||
GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"
|
||||
GRUB_BTRFS_GBTRFS_DIRNAME="/boot/grub2"
|
||||
GRUB_BTRFS_MKCONFIG="grub2-mkconfig"
|
||||
GRUB_BTRFS_SCRIPT_CHECK="grub2-script-check"
|
||||
fi
|
||||
GRUB_BTRFS_VERSION=master-2026-08-05T07:40:52+00:00
|
||||
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
name="grub-btrfs daemon"
|
||||
command="/usr/bin/grub-btrfsd"
|
||||
command_args="$optional_args ${snapshots}"
|
||||
pidfile="/run/{RC_SVCNAME}.pid"
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
command_background=true
|
||||
|
||||
depend() {
|
||||
|
||||
@@ -40,8 +40,39 @@ Re-generate your initramfs
|
||||
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
|
||||
|
||||
#### Dracut based distros
|
||||
Distributions that use Dracut to make their initramfs (many of the Fedora based Distros) simply have to pass either `rd.live.overlay.readonly=1` (to boot into the snapshot read only) or `rd.live.overlay.overlayfs=1` (to act like a livedisk, that is files can be changed but changes will be lost on the next boot) to their kernel command line in grub.
|
||||
Grub-btrfs provides the variable `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS` to add any command to the kernel command line. Set it to `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"` to make snapshots immutable when booted into.
|
||||
Distributions that use Dracut to make their initramfs (many of the Fedora based Distros) have to include the `overlayfs` module into the initramfs and pass either `rd.live.overlay.readonly=1` (to boot into the snapshot read only) or `rd.live.overlay.overlayfs=1` (to act like a livedisk, that is files can be changed but changes will be lost on the next boot) to their kernel command line in grub.
|
||||
|
||||
1. Include `overlayfs` module into dracut
|
||||
|
||||
```bash
|
||||
echo 'add_dracutmodules+=" overlayfs "' | sudo tee /etc/dracut.conf.d/overlayfs.conf
|
||||
```
|
||||
|
||||
2. Fix for dracut <109
|
||||
|
||||
Unfortunately, dracut version <109 has a bug that prevents overlayfs mount from properly working. [A fix has been committed into dracut version 109](https://github.com/dracut-ng/dracut-ng/commit/deeb670c28d12a478bbea95e29677e436d1912fb). If you are still on version < 109, instead of editing `/usr/lib/dracut/modules.d/70overlayfs/mount-overlayfs.sh` directly on your system, which will get overwritten on updates to the dracut package, we can duplicate the whole module with a lower priority number and carry out the patch there. As explained in this [very old notes about dracut](https://wwoods.fedorapeople.org/doc/dracut-notes.html):
|
||||
|
||||
> dracut refuses to overwrite files when installing things into the initramfs, so things installed by the the lower numbered modules have priority over the higher ones.
|
||||
|
||||
```bash
|
||||
sudo cp -r /usr/lib/dracut/modules.d/70overlayfs /usr/lib/dracut/modules.d/69overlayfs
|
||||
sudoedit /usr/lib/dracut/modules.d/69overlayfs/mount-overlayfs.sh
|
||||
```
|
||||
|
||||
Edit the file as per [the commit](https://github.com/dracut-ng/dracut/commit/deeb670c28d12a478bbea95e29677e436d1912fb)
|
||||
|
||||
3. Regenerate the initramfs
|
||||
|
||||
```
|
||||
# for current kernel's initramfs
|
||||
sudo dracut -f
|
||||
# for all kernels
|
||||
sudo dracut -f --regenerate-all
|
||||
```
|
||||
|
||||
4. Add kernel parameter and regenerate grub snapshot-submenu
|
||||
|
||||
Grub-btrfs provides the variable `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS` in `/etc/default/grub-btrfs/config` to add any command to the kernel command line. Set it to `GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1"` to make snapshots immutable when booted into.
|
||||
After changing this run `sudo /etc/grub.d/41_snapshots-btrfs` to generate a new snapshot-submenu with the parameter added.
|
||||
|
||||
#### Other distribution
|
||||
|
||||
Reference in New Issue
Block a user