mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-09 16:04:32 +08:00
Compare commits
6 Commits
master
...
feature/ub
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bc0ee806f | ||
|
|
2b9c1d2730 | ||
|
|
1749789f9a | ||
|
|
695f4b06ba | ||
|
|
d5541253d3 | ||
|
|
4e4e853f2d |
28
Makefile
28
Makefile
@@ -2,6 +2,7 @@ PKGNAME ?= grub-btrfs
|
|||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
|
|
||||||
INITCPIO ?= false
|
INITCPIO ?= false
|
||||||
|
MKINITRAMFS ?= false
|
||||||
SYSTEMD ?= true
|
SYSTEMD ?= true
|
||||||
OPENRC ?= false
|
OPENRC ?= false
|
||||||
|
|
||||||
@@ -59,6 +60,11 @@ install:
|
|||||||
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
|
||||||
|
@# Ubuntu like distros only :
|
||||||
|
@if test "$(MKINITRAMFS)" = true; then \
|
||||||
|
echo "Installing mkinitramfs hook"; \
|
||||||
|
initramfs/ubuntu/setup install; \
|
||||||
|
fi
|
||||||
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
@install -Dm644 -t "$(SHARE_DIR)/licenses/$(PKGNAME)/" LICENSE
|
||||||
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
@install -Dm644 -t "$(SHARE_DIR)/doc/$(PKGNAME)/" README.md
|
||||||
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
@install -Dm644 "initramfs/readme.md" "$(SHARE_DIR)/doc/$(PKGNAME)/initramfs-overlayfs.md"
|
||||||
@@ -80,6 +86,7 @@ uninstall:
|
|||||||
@rm -f "$(DESTDIR)/etc/conf.d/grub-btrfsd;"
|
@rm -f "$(DESTDIR)/etc/conf.d/grub-btrfsd;"
|
||||||
@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"
|
||||||
|
@initramfs/ubuntu/setup uninstall || true
|
||||||
@rm -f "$(MAN_DIR)/man8/grub-btrfs.8.bz2"
|
@rm -f "$(MAN_DIR)/man8/grub-btrfs.8.bz2"
|
||||||
@rm -f "$(MAN_DIR)/man8/grub-btrfsd.8.bz2"
|
@rm -f "$(MAN_DIR)/man8/grub-btrfsd.8.bz2"
|
||||||
@# Arch Linux UNlike distros only :
|
@# Arch Linux UNlike distros only :
|
||||||
@@ -108,14 +115,15 @@ help:
|
|||||||
@echo " uninstall"
|
@echo " uninstall"
|
||||||
@echo " help"
|
@echo " help"
|
||||||
@echo
|
@echo
|
||||||
@echo " parameter | type | description | defaults"
|
@echo " parameter | type | description | defaults"
|
||||||
@echo " ----------+------+--------------------------------+----------------------------"
|
@echo " ------------+------+--------------------------------+----------------------------"
|
||||||
@echo " DESTDIR | path | install destination | <unset>"
|
@echo " DESTDIR | path | install destination | <unset>"
|
||||||
@echo " PREFIX | path | system tree prefix | '/usr'"
|
@echo " PREFIX | path | system tree prefix | '/usr'"
|
||||||
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
@echo " SHARE_DIR | path | shared data location | '\$$(DESTDIR)\$$(PREFIX)/share'"
|
||||||
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
@echo " LIB_DIR | path | system libraries location | '\$$(DESTDIR)\$$(PREFIX)/lib'"
|
||||||
@echo " PKGNAME | name | 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 " INITCPIO | bool | include mkinitcpio hook | false"
|
||||||
@echo " SYSTEMD | bool | include unit files | true"
|
@echo " MKINITRAMFS | bool | include mkinitramfs hook | false"
|
||||||
@echo " OPENRC | bool | include OpenRc daemon | false"
|
@echo " SYSTEMD | bool | include unit files | true"
|
||||||
|
@echo " OPENRC | bool | include OpenRc daemon | false"
|
||||||
@echo
|
@echo
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ You notice that the name of the `hook` must match the name of the 2 installed fi
|
|||||||
Re-generate your initramfs
|
Re-generate your initramfs
|
||||||
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
|
`mkinitcpio -P` (option -P means, all preset present in `/etc/mkinitcpio.d`)
|
||||||
|
|
||||||
|
#### Ubuntu
|
||||||
|
Install initramfs scripts & re-generate initramfs.
|
||||||
|
|
||||||
|
``` shell
|
||||||
|
sudo initramfs/ubuntu/setup install
|
||||||
|
```
|
||||||
|
|
||||||
#### Other distribution
|
#### Other distribution
|
||||||
Refer to your distribution's documentation
|
Refer to your distribution's documentation
|
||||||
or contribute to this project to add a paragraph.
|
or contribute to this project to add a paragraph.
|
||||||
|
|||||||
15
initramfs/ubuntu/hooks/grub-btrfs-overlay
Executable file
15
initramfs/ubuntu/hooks/grub-btrfs-overlay
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
PREREQ=
|
||||||
|
prereqs() {
|
||||||
|
echo "$PREREQ"
|
||||||
|
}
|
||||||
|
case "$1" in
|
||||||
|
prereqs)
|
||||||
|
prereqs
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
. /usr/share/initramfs-tools/hook-functions
|
||||||
|
manual_add_modules overlay
|
||||||
|
copy_exec /usr/bin/findmnt /usr/bin
|
||||||
32
initramfs/ubuntu/scripts/local-bottom/grub-btrfs-overlay
Executable file
32
initramfs/ubuntu/scripts/local-bottom/grub-btrfs-overlay
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
PREREQ=
|
||||||
|
prereqs() {
|
||||||
|
echo "$PREREQ"
|
||||||
|
}
|
||||||
|
case $1 in
|
||||||
|
prereqs)
|
||||||
|
prereqs
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
. /scripts/functions
|
||||||
|
on_err() {
|
||||||
|
log_failure_msg 'error setting up overlay'
|
||||||
|
}
|
||||||
|
trap on_err ERR
|
||||||
|
if [ -x /usr/bin/btrfs -a -x /usr/bin/findmnt ] &&
|
||||||
|
[ "$(findmnt -no FSTYPE -M "$rootmnt")" = btrfs ] &&
|
||||||
|
[ "$(btrfs property get $rootmnt ro)" != ro=false ]
|
||||||
|
then
|
||||||
|
log_begin_msg 'remount read-only subvolume as read-only layer in non-persistent, writable overlay'
|
||||||
|
trap log_end_msg EXIT
|
||||||
|
lower_dir="$(mktemp -dp /)"
|
||||||
|
ram_dir="$(mktemp -dp /)"
|
||||||
|
upper_dir="$ram_dir"/upper
|
||||||
|
work_dir="$ram_dir"/work
|
||||||
|
mount --move "$rootmnt" "$lower_dir"
|
||||||
|
mount -t tmpfs cowspace "$ram_dir"
|
||||||
|
mkdir -p "$upper_dir" "$work_dir"
|
||||||
|
mount -t overlay -o lowerdir="$lower_dir",upperdir="$upper_dir",workdir="$work_dir" rootfs "$rootmnt"
|
||||||
|
fi
|
||||||
70
initramfs/ubuntu/setup
Executable file
70
initramfs/ubuntu/setup
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
log() {
|
||||||
|
local CODE=$?
|
||||||
|
echo >&2 "$*"
|
||||||
|
return $CODE
|
||||||
|
}
|
||||||
|
print-help() {
|
||||||
|
log "\
|
||||||
|
usage: ${0##*/} [-h] [--] (install|uninstall)
|
||||||
|
Install initramfs scripts for Ubuntu.
|
||||||
|
|
||||||
|
# Options
|
||||||
|
-h display this help & exit
|
||||||
|
|
||||||
|
# Subcommands
|
||||||
|
install install initramfs scripts
|
||||||
|
uninstall remove initramfs scripts"
|
||||||
|
}
|
||||||
|
usage-error() {
|
||||||
|
print-help
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
action-install() {
|
||||||
|
local SCRIPT_DIR="$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && pwd)"
|
||||||
|
install {"$SCRIPT_DIR",/etc/initramfs-tools}/hooks/grub-btrfs-overlay
|
||||||
|
install {"$SCRIPT_DIR",/etc/initramfs-tools}/scripts/local-bottom/grub-btrfs-overlay
|
||||||
|
}
|
||||||
|
action-uninstall() {
|
||||||
|
rm -f /etc/initramfs-tools/{hooks,scripts/local-bottom}/grub-btrfs-overlay
|
||||||
|
}
|
||||||
|
set -e
|
||||||
|
while getopts h OPT
|
||||||
|
do case "$OPT" in
|
||||||
|
h)
|
||||||
|
print-help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage-error
|
||||||
|
esac done
|
||||||
|
shift $(( OPTIND - 1 ))
|
||||||
|
OPTIND=1
|
||||||
|
ACTION=
|
||||||
|
case "$#" in
|
||||||
|
0)
|
||||||
|
log event: a subcommand is required
|
||||||
|
usage-error
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
case "$1" in
|
||||||
|
install|uninstall)
|
||||||
|
ACTION="action-$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "\
|
||||||
|
event: unknown subcommand
|
||||||
|
subcommand: $1"
|
||||||
|
usage-error
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "\
|
||||||
|
event: too many arguments
|
||||||
|
arguments: $*"
|
||||||
|
usage-error
|
||||||
|
esac
|
||||||
|
"$ACTION" || log "\
|
||||||
|
event: execution failure
|
||||||
|
suggestion: rerun with sudo"
|
||||||
|
exec update-initramfs -u
|
||||||
Reference in New Issue
Block a user