mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-07 14:54:33 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8325cf134 | ||
|
|
c5da4014ae |
@@ -4,18 +4,19 @@
|
||||
#########################################################################################################################################################################
|
||||
# Written by: Antynea #
|
||||
# BTC donation address: 1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt #
|
||||
# #
|
||||
# Github: https://github.com/Antynea/grub-btrfs #
|
||||
# #
|
||||
# Purpose: Include btrfs snapshots at boot options (grub-menu). #
|
||||
# #
|
||||
# What this script does: #
|
||||
# Simple rollback using snapshots you made previously. #
|
||||
# - 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. (For custon name, see below.) #
|
||||
# - Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots. #
|
||||
# - Automatically Create corresponding "menuentry" in grub.cfg , which ensures a very easy rollback. #
|
||||
# - Automatically detect snapper and use snapper's snapshot description if available. #
|
||||
# #
|
||||
# How to use it: #
|
||||
# How to customize it: #
|
||||
# - Add this lines to /etc/default/grub: #
|
||||
# #
|
||||
# * GRUB_BTRFS_SUBMENUNAME="Arch Linux snapshots" #
|
||||
@@ -36,12 +37,12 @@
|
||||
# * GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND="true" #
|
||||
# (Show Total of snapshots found during run "grub-mkconfig") #
|
||||
# * GRUB_BTRFS_NKERNEL=("vmlinuz-linux") #
|
||||
# (Use only if you have custom kernel name or auto-detect failed.) #
|
||||
# (Use only if you have custom kernel name.) #
|
||||
# * GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") #
|
||||
# (Use only if you have custom initramfs name or auto-detect failed.) #
|
||||
# (Use only if you have custom initramfs name.) #
|
||||
# * GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") #
|
||||
# (Use only if you have custom intel-ucode or auto-detect failed.) #
|
||||
# * GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "nosnapshot") #
|
||||
# (Use only if you have custom intel-ucode.) #
|
||||
# * GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker") #
|
||||
# (Ignore specific path during run "grub-mkconfig") #
|
||||
# * GRUB_BTRFS_SNAPPER_CONFIG="root" #
|
||||
# (Snapper's config name to use) #
|
||||
@@ -73,8 +74,7 @@ datarootdir="/usr/share"
|
||||
sysconfdir="/etc"
|
||||
|
||||
. "${sysconfdir}/default/grub"
|
||||
. "$pkgdatadir/grub-mkconfig_lib"
|
||||
# . "$datarootdir/grub/grub-mkconfig_lib" # Uncomment if you run "bash -x"
|
||||
. "$datarootdir/grub/grub-mkconfig_lib"
|
||||
|
||||
######################################
|
||||
### Variables in /etc/default/grub ###
|
||||
@@ -182,16 +182,17 @@ make_menu_entries()
|
||||
[[ ! -f "${boot_dir}"/"${k}" ]] && continue;
|
||||
kversion=${k#*"-"}
|
||||
for i in "${name_initramfs[@]}"; do
|
||||
prefix_i=${i[@]%%"-"*}
|
||||
suffix_i=${i[@]##*"-"}
|
||||
if [ -f "${boot_dir}"/"${prefix_i}-${kversion}-${suffix_i}" ]; then i="${i}";
|
||||
elif [ -f "${boot_dir}"/"${prefix_i}-${kversion}" ]; then i="${i}";
|
||||
elif [ -f "${boot_dir}"/"${prefix_i}-${kversion}.img" ]; then i="${i}";
|
||||
elif [ -f "${boot_dir}"/"${prefix_i}-${kversion}.gz" ]; then i="${i}";
|
||||
prefix_i=${i%%"-"*}
|
||||
suffix_i=${i#*"-"}
|
||||
alt_suffix_i=${i##*"-"}
|
||||
if [ "${kversion}" = "${suffix_i}" ]; then i="${i}";
|
||||
elif [ "${kversion}.img" = "${suffix_i}" ]; then i="${i}";
|
||||
elif [ "${kversion}-fallback.img" = "${suffix_i}" ]; then i="${i}";
|
||||
elif [ "${kversion}.gz" = "${suffix_i}" ]; then i="${i}";
|
||||
else continue ;
|
||||
fi
|
||||
for u in "${name_microcode[@]}"; do
|
||||
if [[ -f "${boot_dir}"/"${u}" && "${i}" != initramfs-linux-fallback.img ]] ; then
|
||||
if [[ -f "${boot_dir}"/"${u}" && "${i}" != "${prefix_i}-${kversion}-${alt_suffix_i}" ]] ; then
|
||||
entry "
|
||||
menuentry '"${k}" & "${i}" & "${u}"' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{"
|
||||
else
|
||||
@@ -212,7 +213,7 @@ make_menu_entries()
|
||||
echo 'Loading Snapshot: "${snap_date_time}" "${snap_dir_name}"'
|
||||
echo 'Loading Kernel: "${k}" ...'
|
||||
linux \"${boot_dir_root_grub}/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=\""${snap_dir_name}"\" ${kernel_parameters}"
|
||||
if [[ -f "${boot_dir}"/"${u}" && "${i}" != initramfs-linux-fallback.img ]] ; then
|
||||
if [[ -f "${boot_dir}"/"${u}" && "${i}" != "${prefix_i}-${kversion}-${alt_suffix_i}" ]] ; then
|
||||
entry "\
|
||||
echo 'Loading Microcode & Initramfs: "${u}" "${i}" ...'
|
||||
initrd \"${boot_dir_root_grub}/"${u}"\" \"${boot_dir_root_grub}/"${i}"\""
|
||||
@@ -394,16 +395,15 @@ path_snapshot()
|
||||
title_format()
|
||||
{
|
||||
case "${title_format}" in
|
||||
p/d/n) title_menu="${prefixentry} ${snap_date_time} ${name_snapshot}";;
|
||||
p/n/d) title_menu="${prefixentry} ${name_snapshot} ${snap_date_time}";;
|
||||
p/d) title_menu="${prefixentry} ${snap_date_time}";;
|
||||
p/n) title_menu="${prefixentry} ${name_snapshot}";;
|
||||
d/n) title_menu="${snap_date_time} ${name_snapshot}";;
|
||||
n/d) title_menu="${name_snapshot} ${snap_date_time}";;
|
||||
p) title_menu="${prefixentry}";;
|
||||
d) title_menu="${snap_date_time}";;
|
||||
n) title_menu="${name_snapshot}";;
|
||||
*) printf $"# Warning: GRUB_BTRFS_TITLE_FORMAT=${title_format}, syntax error \n" >&2
|
||||
p) title_menu="${prefixentry}";;
|
||||
d) title_menu="${snap_date_time}";;
|
||||
n) title_menu="${name_snapshot}";;
|
||||
*) title_menu="${prefixentry} ${snap_date_time} ${name_snapshot}"
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
29
README.md
29
README.md
@@ -2,14 +2,14 @@
|
||||
|
||||
## grub-btrfs
|
||||
|
||||
This is a version 2.xx of grub-btrfs
|
||||
This is a version 3.xx of grub-btrfs
|
||||
##### BTC donation address: 1Lbvz244WA8xbpHek9W2Y12cakM6rDe5Rt
|
||||
##
|
||||
### Description
|
||||
|
||||
grub-btrfs, Include btrfs snapshots at boot options. (grub menu)
|
||||
##
|
||||
### What does grub-btrfs v2.xx do :
|
||||
### What does grub-btrfs v3.xx do :
|
||||
|
||||
Simple rollback using snapshots you made previously.
|
||||
|
||||
@@ -17,14 +17,15 @@ Simple rollback using snapshots you made previously.
|
||||
|
||||
* Automatically Detect if "/boot" is in separate partition.
|
||||
|
||||
* Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots. (For custom name, see below.)
|
||||
* Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots.
|
||||
|
||||
* Automatically Create corresponding "menuentry" in grub.cfg , which ensures a very easy rollback.
|
||||
|
||||
* Automatically detect snapper and use snapper's snapshot description if available.
|
||||
##
|
||||
### How to use it:
|
||||
### How to customize it:
|
||||
|
||||
You have the possibility to modify many parameters.
|
||||
Add this lines to /etc/default/grub:
|
||||
|
||||
* GRUB_BTRFS_SUBMENUNAME="Arch Linux Snapshots"
|
||||
@@ -43,17 +44,17 @@ Add this lines to /etc/default/grub:
|
||||
|
||||
(Custom title, shows/hides p"prefix" d"date" n"name" in grub-menu, separator "/", custom order available)
|
||||
|
||||
* GRUB_BTRFS_NKERNEL=("vmlinuz-linux")
|
||||
* GRUB_BTRFS_NKERNEL=("kernel-custom")
|
||||
|
||||
(Use only if you have a custom kernel name or auto-detect failed.)
|
||||
(Use it only if you have a custom kernel name)
|
||||
|
||||
* GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img")
|
||||
* GRUB_BTRFS_NINIT=("initramfs-custom.img" "initrd.img-custom")
|
||||
|
||||
(Use only if you have a custom initramfs name or auto-detect failed.)
|
||||
(Use it only if you have a custom initramfs name)
|
||||
|
||||
* GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img")
|
||||
|
||||
(Use only if you have custom intel-ucode or auto-detect failed.)
|
||||
(Use it only if you have custom intel-ucode)
|
||||
|
||||
* GRUB_BTRFS_LIMIT="50"
|
||||
|
||||
@@ -73,18 +74,18 @@ Add this lines to /etc/default/grub:
|
||||
|
||||
(Show Total number of snapshots found during run "grub-mkconfig")
|
||||
|
||||
* GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "nosnapshot")
|
||||
* GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker")
|
||||
|
||||
(Ignore specific path during run "grub-mkconfig")
|
||||
|
||||
* GRUB_BTRFS_CREATE_ONLY_HARMONIZED_ENTRIES="true"
|
||||
|
||||
(Create entries with matching version number instead of all possible combinations of kernel and initramfs, very useful with debian-like distributions)
|
||||
|
||||
* GRUB_BTRFS_SNAPPER_CONFIG="root"
|
||||
|
||||
(Snapper's config name to use)
|
||||
|
||||
* GRUB_BTRFS_DISABLE="true"
|
||||
|
||||
(Disable grub-btrfs)
|
||||
|
||||
|
||||
Generate grub.cfg (on Arch linux use grub-mkconfig -o /boot/grub/grub.cfg )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user