From 205f7edf00887df626a6278ad3dc96499fd5257d Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 22 Jul 2015 01:28:59 +0200 Subject: [PATCH 01/35] Update README.md --- README.md | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 699361a..80ef40c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### grub-btrfs -This is a version 0.xx of grub-btrfs +This is a version 1.xx of grub-btrfs #### Description @@ -13,29 +13,9 @@ Simple rollback using snapshots you made previous. Makes a list of all snapshots, kernels, initramfs present on the filesystem and then creates a corresponding entered with name and date of snapshots in grub.cfg, which ensures a very easy rollback. -#### How to use it : +#### TO DO -1. Add lines to /etc/default/grub as needed, defaults listed as examples: -2. - * submenuname = name menu appear in grub ( e.g: GRUB_BTRFS_SUBMENUNAME="ArchLinux Snapshots" ) - - * prefixentry = add a name ahead your snapshots entries ( e.g: GRUB_BTRFS_PREFIXENTRY="Snapshot" ) - - * nkernel= name kernel you use it ( e.g: GRUB_BTRFS_NKERNEL=("vmlinuz-linux") ) - - * ninit= name initramfs (ramdisk) you use it ( e.g: GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") ) - - * intel_ucode= name intel microcode you use it ( e.g: GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") ) - -2. Generate grub.cfg (on Archlinux is grub-mkconfig -o /boot/grub/grub.cfg ) - -grub-btrfs automatically generates snapshots entries. - -You will see it appear different entries, e.g : Prefixentry name of snapshot [2013-02-11 04:00:00] - -#### Warning - -Version 0.xx detect kernels,initramfs,intel microcode only in boot partition, not in snapshot. -If kernels,initramfs,intel microcode, are present in boot partition but not in snapshot, entry will be created but not fonctional, you don't boot it. - -Version 1.xx will do it, release soon. +in progress ... +fix bug +improve perfomance +auto-detect kernel,initramfs,intel-ucode From 91f0a98a60e98851a9c680d64b2ade3256d069c8 Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 22 Jul 2015 01:30:37 +0200 Subject: [PATCH 02/35] Update README.md --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 80ef40c..0942ad0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and #### TO DO -in progress ... -fix bug -improve perfomance -auto-detect kernel,initramfs,intel-ucode +* in progress ... + +* fix bug + +* improve perfomance + +* auto-detect kernel,initramfs,intel-ucode From fcdc5dea87143ceba8cc6e161a5e3352e8146977 Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 22 Jul 2015 02:00:22 +0200 Subject: [PATCH 03/35] in progress in progress --- 41_snapshots-btrfs | 140 +-------------------------------------------- 1 file changed, 1 insertion(+), 139 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index ab22278..6e92175 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -1,139 +1 @@ -#! /usr/bin/bash -set -e - -. /usr/share/grub/grub-mkconfig_lib -. /etc/default/grub - -###################################### -### variables in /etc/default/grub ### -###################################### -## Submenu name -submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"} -## Prefix entry -prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot"} -## Kernel(s) name(s) -nkernel=("${GRUB_BTRFS_NKERNEL[@]:-vmlinuz-linux}") -## Initramfs name(s) -ninit=("${GRUB_BTRFS_NINIT[@]:-initramfs-linux.img initramfs-linux-fallback.img}") -## Intel-ucode name(s) -intel_ucode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}") - -######################## -### variables script ### -######################## -## Internationalization (default : english) -export TEXTDOMAIN=grub-btrfs-git -export TEXTDOMAINDIR="/usr/share/locale" -## fr: paramêtre des chaînes --hint -## en: Parameter of the chains --hint (Translation unclear) -pboot=$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null) -## UUID of the root partition -uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null) -## UUID of the boot partition -buuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null) -## Parameters passed to the kernel -params="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT" - -############## -### Script ### -############## - -typeset -A date_time -unset snapshots - -# Create list of filesystem snapshots -oldIFS=$IFS -IFS=$'\n' - -for snap in $($bindir/btrfs subvolume list -sa / --sort=-ogen | $bindir/awk '{gsub(/^.*\//,"",$NF);print $11" "$12"?"$NF}'); do - snap_name="${snap#*"?"}" - # Discard deleted snapshots - if [ $snap_name = "DELETED" ]; then continue; fi - snapshots+=("$snap_name") - date_time[$snap_name]="${snap%"?"*}" -done -IFS=$oldIFS - -# fr: on affiche le menu -# en: Display the menu -echo "submenu '$submenuname' {" - -# fr: on traite la variable kernel -# en: Treat the kernel variables (Translation unclear) -for kernel in ${nkernel[@]}; do - # fr: on test si le(s) nom(s) du(des) kernel existe(nt), autrement on affiche une erreur et on sort - # en: Check the specified kernel(s) exist, if it/they don't, display an error and exit - if [ ! -f /boot/$kernel ]; then gettext_printf $"Error: /boot/$kernel, kernel does not exist" >&2; exit 1; fi - # fr: on vérifie le nombre de kernel présent, si >1 on crée un menu - # en: If there are >1 kernels, create a menu - if [ ${#nkernel[*]} != 1 ]; then echo " submenu '$kernel' { - submenu '---> Kernel: $kernel <---' { echo }"; fi - # fr: On traite la variable snapshots - # en: Treat the snapshots variable - for item in ${snapshots[@]}; do - # fr: affiche la liste des snapshots trouvés - # en: Output name of snapshot - gettext_printf $"Found Snapshot: %s\n" "$item ${date_time[$item]}" >&2 - # fr: on crée un menu pour chaque snapshot présent (nom + date de création) - # en: Create a menu for remaining snapshots (name + creation date) - echo " submenu '$prefixentry $item [${date_time[$item]}]' {" - # fr: si plusieurs kernel on été trouvé, on affiche un titre indicatif - # en: if more than one kernel is found, create a menu - if [ ${#nkernel[*]} != 1 ]; then echo " submenu '---> Kernel: $kernel <---' { echo }"; fi - # fr: on traite la variable de l'initramfs - # en: Treat the initramfs variables (Translation unclear) - for init in ${ninit[@]}; do - # fr: on test si le(s) nom(s) du(des) initramfs existe(nt), autrement on affiche une erreur et on sort - # en: Check the specified initramfs(es) exist, if it/they don't, display an error and exit - if [ ! -f /boot/$init ]; then gettext_printf $"Error: /boot/$init, initramfs does not exist" >&2; exit 1; fi - # fr: on traite chaque entrée des snapshots avec leurs kernel et initramfs respectifs - # en: Specify a kernel and initramfs for every snapshot - echo "\ - menuentry '$item $init' --class arch --class gnu-linux --class gnu --class os "\$menuentry_id_option" 'gnulinux-snapshots-$uuid'{ - load_video - set gfxpayload=$GRUB_GFXPAYLOAD_LINUX - if [ x"\$feature_platform_search_hint" = xy ]; then - search --no-floppy --fs-uuid --set=root $pboot $buuid - else - search --no-floppy --fs-uuid --set=root $buuid - fi - echo 'Loading Linux snapshot ...'" - # fr: on vérifie l'emplacement de la partition /boot - # en: Check the location of the /boot partition - if [ $uuid = $buuid ]; then - echo "\ - linux /$item/boot/$kernel root=UUID=$uuid rw rootflags=subvol=$item $params - echo 'Loading initial ramdisk ...'" - # fr: on vérifie la présence du microcode intel - # en: Check intel microcode exist - if [ -f /boot/$intel_ucode ]; then - echo "\ - initrd /$item/boot/$intel_ucode /$item/boot/$init" - else - echo "\ - initrd /$item/boot/$init" - fi - else - echo "\ - linux /$kernel root=UUID=$uuid rw rootflags=subvol=$item $params - echo 'Loading initial ramdisk ...'" - # fr: on vérifie la présence du microcode intel - # en: Check intel microcode exist - if [ -f /boot/$intel_ucode ]; then - echo "\ - initrd /$intel_ucode /$init" - else - echo "\ - initrd /$init" - fi - fi - echo "\ - }" - done - echo " }" - done - # fr: on oubli pas de fermer le menu si plusieurs kernels ont été trouvé - # en: Don't forget to close menus if more than one kernel is found - if [ ${#nkernel[*]} != 1 ]; then echo " }"; fi -done -echo "}" \ No newline at end of file +in progress ... From 422d46cc84e3761e303bdee20b9ff655c5a7d23d Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 26 Jul 2015 18:06:37 +0200 Subject: [PATCH 04/35] in progress --- 41_snapshots-btrfs | 184 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 183 insertions(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 6e92175..e85521e 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -1 +1,183 @@ -in progress ... +#! /usr/bin/bash +# +# +######################################################################################################################################################### +# Written by: Antynea # +# # +# Purpose: Include btrfs snapshots at boot options. # +# # +# What this script does: # +# - Automatically List snapshots existing on root partition (btrfs). # +# - Automatically detect kernel, initramfs and intel microcode in "/boot" directory on snapshots. (For custon name, see below.) # +# - Automatically Create corresponding menuentry in grub.cfg , which ensures a very easy rollback. # +# # +# How to use it: # +# - Add this lines to /etc/default/grub: # +# # +# * GRUB_BTRFS_SUBMENUNAME="ArchLinux Snapshots" (Name menu appearing in grub.) # +# * GRUB_BTRFS_PREFIXENTRY="Snapshot:" (Add a name ahead your snapshots entries.) # +# * GRUB_BTRFS_NKERNEL=("vmlinuz-linux") (Use only if you have custom kernel name or auto-detect failed.) # +# * GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") (Use only if you have custom initramfs name or auto-detect failed.) # +# * GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") (Use only if you have custom intel-ucode or auto-detect failed.) # +# # +# - Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg ) # +# # +# - grub-btrfs automatically generates snapshots entries. # +# - You will see it appear different entries (e.g : Snapshot: my snapshot name overkill [2014-02-12 11:24:37]) # +# # +# Warning: # +# # +# # +# # +######################################################################################################################################################### + +set -e + +prefix="/usr" +exec_prefix="${prefix}" +datarootdir="/usr/share" +datadir="${datarootdir}" +sysconfdir="/etc" + +. "${datarootdir}/grub/grub-mkconfig_lib" +. "${sysconfdir}/default/grub" + +###################################### +### variables in /etc/default/grub ### +###################################### +## Choice of method +choise_of_method=${GRUB_BTRFS_SUBMENUNAME:-"1"} +## Submenu name +submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"} +## Prefix entry +prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot:"} +## Kernel(s) name(s) +#nkernel=("${GRUB_BTRFS_NKERNEL[@]}") +## Initramfs name(s) +#ninit=("${GRUB_BTRFS_NINIT[@]}") +## Microcode(s) name(s) +microcode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}") + +######################## +### variables script ### +######################## +## Internationalization (default : english) +export TEXTDOMAIN=grub-btrfs-git +export TEXTDOMAINDIR="/usr/share/locale" +## hints string +hs_boot=$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null) +## UUID of the boot partition +boot_uuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null) +## Type filesystem of boot partition +boot_fs=$(${grub_probe} --target="fs" "/boot" 2>/dev/null) +## UUID of the root partition +root_uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null) +## Parameters passed to the kernel +kernel_parameters="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT" +## Mount point location +gbgmp="/tmp/gbgmp" +## Class for theme +CLASS="--class snapshots --class gnu-linux --class gnu --class os" +## save IFS +oldIFS=$IFS + + +############## +### Script ### +############## + +### BEGIN auto detect ### + +## menu entries +snapshots_entry() +{ +echo " submenu '${1} ${2} ${3}' {" + for k in ${name_kernel[@]}; do + for i in ${initramfs[@]}; do + echo "\ + menuentry '${2} with ${k} & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ + $(save_default_entry) + if [ x\$feature_all_video_module = xy ]; then + insmod all_video + fi + set gfxpayload=keep + insmod ${boot_fs} + if [ x\$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid} + else + search --no-floppy --fs-uuid --set=root ${boot_uuid} + fi + echo 'Loading Snapshot: ${snap_dir_name}' + echo 'Loading Kernel: ${k} ...' + linux /${snap_dir_name}/boot/${k} root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} + echo 'Loading Initramfs: ${i} ...'" + if [ -f /${snap_dir_name}/boot/intel-ucode.img ] ; then + echo "\ + initrd /${snap_dir_name}/boot/intel-ucode.img initrd /${snap_dir_name}/boot/${i} + " + else + echo "\ + initrd /${snap_dir_name}/boot/${i} + " + fi + echo "}" + done + done +echo "}" +} + +## List of snapshots on filesystem +snapshot_list() +{ + for snap in $(btrfs subvolume list -sa /); do + IFS=$oldIFS + snap=($snap) + local snap_path_name=${snap[@]:13:${#snap[@]}} + # Discard deleted snapshots + if [ $snap_path_name = "DELETED" ]; then continue; fi + [[ ${snap_path_name%%"/"*} == "" ]] && snap_path_name=${snap_path_name#*"/"} + echo ${snap[@]:10:2} ${snap_path_name} + done +} + +## List of kernels and initramfs in snapshots +list_kernels_initramfs() +{ +[[ ! -d $gbgmp ]] && mkdir -p $gbgmp +mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ + +echo "submenu '${submenuname}' {" + IFS=$'\n' + for item in $(snapshot_list); do + IFS=$oldIFS + item=($item) + snap_dir_name=${item[@]:2:${#item[@]}} + if [ -f $gbgmp/$snap_dir_name/boot/grub/grub.cfg ]; then + snap_date_time=${item[@]:0:2} + gettext_printf $"Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; + snap_dir_boot=$gbgmp/$snap_dir_name/boot + list_kernel=($(for kernel in $snap_dir_boot/vmlinuz-*; do echo $kernel ; done)) + #echo "list kernel = ${list_kernel[*]}" ; + name_kernel=(${list_kernel[@]##*"/"}) + #echo "kernel = ${name_kernel[*]}" ; + version_kernel=(${name_kernel[@]#*"-"}) + #echo "version = ${version_kernel[*]}" ; + initramfs=($( + for init in ${version_kernel[@]} ; do + if [ -e $snap_dir_boot/initramfs-$init.img ] ; then echo "initramfs-$init.img" ; fi ; + if [ -e $snap_dir_boot/initramfs-$init-fallback.img ] ; then echo "initramfs-$init-fallback.img" ; fi ; + done)) + #echo "init = ${initramfs[@]}" ; + #echo "###" ; + fi + # Create menu entries + snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + done + echo "}" + IFS=$oldIFS + umount $gbgmp +} +### END auto detect ### + +### Choice of method ### +if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; fi \ No newline at end of file From cbe547de772cff5ccd647ad5dd516a49aca1dc59 Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 26 Jul 2015 18:11:33 +0200 Subject: [PATCH 05/35] in progress --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0942ad0..0c56f66 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a version 1.xx of grub-btrfs grub-btrfs, add support for btrfs snapshots into grub menu -#### What does grub-btrfs v0.xx do : +#### What does grub-btrfs v1.xx do : Simple rollback using snapshots you made previous. @@ -22,3 +22,7 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and * improve perfomance * auto-detect kernel,initramfs,intel-ucode + +* detect partition boot separate + + From 974b798f530321d827684db1ed9bd711ed3e7aae Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 26 Jul 2015 18:13:24 +0200 Subject: [PATCH 06/35] in progress --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c56f66..17373bb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ grub-btrfs, add support for btrfs snapshots into grub menu Simple rollback using snapshots you made previous. -Makes a list of all snapshots, kernels, initramfs present on the filesystem and then creates a corresponding entered with name and date of snapshots in grub.cfg, which ensures a very easy rollback. +Makes a list of all snapshots, kernels, initramfs present on the filesystem and then creates a corresponding input with name and date of snapshots in grub.cfg, which ensures a very easy rollback. #### TO DO From 6b3cf842b0043cfd16b293e07e75d3076ec5bbab Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 2 Aug 2015 17:28:39 +0200 Subject: [PATCH 07/35] GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") (Use only if you have custom intel-ucode or auto-detect failed.) check , ok --- 41_snapshots-btrfs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index e85521e..ecc41d0 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -111,9 +111,9 @@ echo " submenu '${1} ${2} ${3}' {" echo 'Loading Kernel: ${k} ...' linux /${snap_dir_name}/boot/${k} root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} echo 'Loading Initramfs: ${i} ...'" - if [ -f /${snap_dir_name}/boot/intel-ucode.img ] ; then + if [ -f /${snap_dir_name}/boot/${microcode} ] ; then echo "\ - initrd /${snap_dir_name}/boot/intel-ucode.img initrd /${snap_dir_name}/boot/${i} + initrd /${snap_dir_name}/boot/${microcode} initrd /${snap_dir_name}/boot/${i} " else echo "\ From 63a96dfcfb651ab2b71045bc0a4dd83fffb5f6d7 Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 2 Aug 2015 17:29:35 +0200 Subject: [PATCH 08/35] GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") (Use only if you have custom intel-ucode or auto-detect failed.) check , ok --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17373bb..7cc3df7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and * improve perfomance -* auto-detect kernel,initramfs,intel-ucode +* auto-detect kernel,initramfs * detect partition boot separate From 79f0ac6b0db6c2bd37a62f0f0508191f7335ac5c Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 5 Aug 2015 15:30:42 +0200 Subject: [PATCH 09/35] GRUB_BTRFS_NKERNEL=("vmlinuz-linux") (Use only if you have custom kernel name or auto-detect failed.) check , ok --- 41_snapshots-btrfs | 112 +++++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 44 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index ecc41d0..e701804 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -27,16 +27,20 @@ # # # Warning: # # # +# Script in progress # +# to do : # # # +# * auto-detect initramfs, custom Initramfs # +# * detect partition boot separate # # # ######################################################################################################################################################### set -e -prefix="/usr" -exec_prefix="${prefix}" +#prefix="/usr" +#exec_prefix="${prefix}" datarootdir="/usr/share" -datadir="${datarootdir}" +#datadir="${datarootdir}" sysconfdir="/etc" . "${datarootdir}/grub/grub-mkconfig_lib" @@ -52,7 +56,7 @@ submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"} ## Prefix entry prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot:"} ## Kernel(s) name(s) -#nkernel=("${GRUB_BTRFS_NKERNEL[@]}") +nkernel=("${GRUB_BTRFS_NKERNEL[@]}") ## Initramfs name(s) #ninit=("${GRUB_BTRFS_NINIT[@]}") ## Microcode(s) name(s) @@ -92,10 +96,10 @@ oldIFS=$IFS snapshots_entry() { echo " submenu '${1} ${2} ${3}' {" - for k in ${name_kernel[@]}; do - for i in ${initramfs[@]}; do + for k in "${name_kernel[@]}"; do + for i in $(detect_initramfs); do echo "\ - menuentry '${2} with ${k} & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ + menuentry '${2} with "${k}" & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ $(save_default_entry) if [ x\$feature_all_video_module = xy ]; then insmod all_video @@ -108,16 +112,16 @@ echo " submenu '${1} ${2} ${3}' {" search --no-floppy --fs-uuid --set=root ${boot_uuid} fi echo 'Loading Snapshot: ${snap_dir_name}' - echo 'Loading Kernel: ${k} ...' - linux /${snap_dir_name}/boot/${k} root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} - echo 'Loading Initramfs: ${i} ...'" - if [ -f /${snap_dir_name}/boot/${microcode} ] ; then + echo 'Loading Kernel: "${k}" ...' + linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} + echo 'Loading Initramfs: "${i}" ...'" + if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then echo "\ - initrd /${snap_dir_name}/boot/${microcode} initrd /${snap_dir_name}/boot/${i} + initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\" " else echo "\ - initrd /${snap_dir_name}/boot/${i} + initrd \"/${snap_dir_name}/boot/${i}\" " fi echo "}" @@ -140,44 +144,64 @@ snapshot_list() done } +detect_kernel() +{ + ## Arch original kernel (auto-detect) + for akernel in $snap_dir_boot/vmlinuz-* ; do + list_kernel+=("$akernel") + done + + ## Custom name kernel in GRUB_BTRFS_NKERNEL + if [ ! -z ${nkernel} ] ; then + for ckernel in "${nkernel[@]}" ; do + [[ ! -f /${snap_dir_boot}/${ckernel} ]] && continue; + list_kernel+=("$ckernel") + done + fi +} + +detect_initramfs() +{ + for init in "${version_kernel[@]}" ; do + if [ -e "$snap_dir_boot/initramfs-$init.img" ] ; then echo "initramfs-$init.img" ; fi ; + if [ -e "$snap_dir_boot/initramfs-$init-fallback.img" ] ; then echo "initramfs-$init-fallback.img" ; fi ; + done + +} + ## List of kernels and initramfs in snapshots list_kernels_initramfs() { -[[ ! -d $gbgmp ]] && mkdir -p $gbgmp -mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ + [[ ! -d $gbgmp ]] && mkdir -p $gbgmp + mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ -echo "submenu '${submenuname}' {" - IFS=$'\n' - for item in $(snapshot_list); do - IFS=$oldIFS - item=($item) - snap_dir_name=${item[@]:2:${#item[@]}} - if [ -f $gbgmp/$snap_dir_name/boot/grub/grub.cfg ]; then - snap_date_time=${item[@]:0:2} - gettext_printf $"Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; - snap_dir_boot=$gbgmp/$snap_dir_name/boot - list_kernel=($(for kernel in $snap_dir_boot/vmlinuz-*; do echo $kernel ; done)) - #echo "list kernel = ${list_kernel[*]}" ; - name_kernel=(${list_kernel[@]##*"/"}) - #echo "kernel = ${name_kernel[*]}" ; - version_kernel=(${name_kernel[@]#*"-"}) - #echo "version = ${version_kernel[*]}" ; - initramfs=($( - for init in ${version_kernel[@]} ; do - if [ -e $snap_dir_boot/initramfs-$init.img ] ; then echo "initramfs-$init.img" ; fi ; - if [ -e $snap_dir_boot/initramfs-$init-fallback.img ] ; then echo "initramfs-$init-fallback.img" ; fi ; - done)) - #echo "init = ${initramfs[@]}" ; - #echo "###" ; - fi - # Create menu entries - snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" - done + echo "submenu '${submenuname}' {" + IFS=$'\n' + for item in $(snapshot_list); do + IFS=$oldIFS + item=($item) + snap_dir_name=${item[@]:2:${#item[@]}} + if [ -f $gbgmp/$snap_dir_name/boot/grub/grub.cfg ]; then + snap_date_time=${item[@]:0:2} + gettext_printf $"Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; + snap_dir_boot=$gbgmp/$snap_dir_name/boot + unset list_kernel + detect_kernel + name_kernel=("${list_kernel[@]##*"/"}") + #echo "kernel = ${#name_kernel[*]}" + version_kernel=(${name_kernel[@]#*"-"}) + #echo "version = ${version_kernel[*]}" + #echo "###" ; + fi + # Create menu entries + snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + done echo "}" IFS=$oldIFS - umount $gbgmp + umount $gbgmp } ### END auto detect ### ### Choice of method ### -if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; fi \ No newline at end of file +if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; fi +### End choice of method ### \ No newline at end of file From 7cf432f359abf1d0f7c352cf0d8f3b5372e8a90d Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 5 Aug 2015 15:32:05 +0200 Subject: [PATCH 10/35] auto-detect kernel and custom kernel check , ok --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7cc3df7..9997147 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and * improve perfomance -* auto-detect kernel,initramfs +* auto-detect initramfs * detect partition boot separate From 6afa8f03cd6fd8f61fd52ca5d5a2eaf689d9ff08 Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 00:50:55 +0200 Subject: [PATCH 11/35] GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") (Use only if you have custom initramfs name or auto-detect failed.) check, ok --- 41_snapshots-btrfs | 98 +++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index e701804..23ca92f 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -58,7 +58,7 @@ prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot:"} ## Kernel(s) name(s) nkernel=("${GRUB_BTRFS_NKERNEL[@]}") ## Initramfs name(s) -#ninit=("${GRUB_BTRFS_NINIT[@]}") +ninit=("${GRUB_BTRFS_NINIT[@]}") ## Microcode(s) name(s) microcode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}") @@ -95,39 +95,39 @@ oldIFS=$IFS ## menu entries snapshots_entry() { -echo " submenu '${1} ${2} ${3}' {" - for k in "${name_kernel[@]}"; do - for i in $(detect_initramfs); do - echo "\ - menuentry '${2} with "${k}" & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ - $(save_default_entry) - if [ x\$feature_all_video_module = xy ]; then - insmod all_video - fi - set gfxpayload=keep - insmod ${boot_fs} - if [ x\$feature_platform_search_hint = xy ]; then - search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid} - else - search --no-floppy --fs-uuid --set=root ${boot_uuid} - fi - echo 'Loading Snapshot: ${snap_dir_name}' - echo 'Loading Kernel: "${k}" ...' - linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} - echo 'Loading Initramfs: "${i}" ...'" - if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then + echo " submenu '${1} ${2} ${3}' {" + for k in "${name_kernel[@]}"; do + for i in "${name_initramfs[@]}"; do echo "\ - initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\" - " - else - echo "\ - initrd \"/${snap_dir_name}/boot/${i}\" - " - fi - echo "}" + menuentry '${2} with "${k}" & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ + $(save_default_entry) + if [ x\$feature_all_video_module = xy ]; then + insmod all_video + fi + set gfxpayload=keep + insmod ${boot_fs} + if [ x\$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid} + else + search --no-floppy --fs-uuid --set=root ${boot_uuid} + fi + echo 'Loading Snapshot: ${snap_dir_name}' + echo 'Loading Kernel: "${k}" ...' + linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} + echo 'Loading Initramfs: "${i}" ...'" + if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then + echo "\ + initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\" + " + else + echo "\ + initrd \"/${snap_dir_name}/boot/${i}\" + " + fi + echo " }" + done done - done -echo "}" + echo " }" } ## List of snapshots on filesystem @@ -148,7 +148,7 @@ detect_kernel() { ## Arch original kernel (auto-detect) for akernel in $snap_dir_boot/vmlinuz-* ; do - list_kernel+=("$akernel") + list_kernel+=("$akernel") done ## Custom name kernel in GRUB_BTRFS_NKERNEL @@ -162,11 +162,18 @@ detect_kernel() detect_initramfs() { - for init in "${version_kernel[@]}" ; do - if [ -e "$snap_dir_boot/initramfs-$init.img" ] ; then echo "initramfs-$init.img" ; fi ; - if [ -e "$snap_dir_boot/initramfs-$init-fallback.img" ] ; then echo "initramfs-$init-fallback.img" ; fi ; + ## Arch original kernel (auto-detect) + for ainitramfs in $snap_dir_boot/initramfs-* ; do + list_initramfs+=("$ainitramfs") done + ## Custom name initramfs in GRUB_BTRFS_NINIT + if [ ! -z ${ninit} ] ; then + for cinitramfs in "${ninit[@]}" ; do + [[ ! -f /${snap_dir_boot}/${ninit} ]] && continue; + list_initramfs+=("$ninit") + done + fi } ## List of kernels and initramfs in snapshots @@ -174,7 +181,6 @@ list_kernels_initramfs() { [[ ! -d $gbgmp ]] && mkdir -p $gbgmp mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ - echo "submenu '${submenuname}' {" IFS=$'\n' for item in $(snapshot_list); do @@ -188,20 +194,24 @@ list_kernels_initramfs() unset list_kernel detect_kernel name_kernel=("${list_kernel[@]##*"/"}") - #echo "kernel = ${#name_kernel[*]}" - version_kernel=(${name_kernel[@]#*"-"}) - #echo "version = ${version_kernel[*]}" - #echo "###" ; + # echo "kernel = ${name_kernel[*]}" + unset list_initramfs + detect_initramfs + name_initramfs=("${list_initramfs[@]##*"/"}") + # echo "initramfs = ${name_initramfs[*]}" fi # Create menu entries snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done echo "}" IFS=$oldIFS - umount $gbgmp + umount $gbgmp } ### END auto detect ### ### Choice of method ### -if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; fi -### End choice of method ### \ No newline at end of file +if [ ${choise_of_method} = "1" ] ; then + gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; + list_kernels_initramfs ; fi + gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; +### End choice of method ### From b199e29262279bb36c327931859d7d620b82efa8 Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 00:53:39 +0200 Subject: [PATCH 12/35] GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") (Use only if you have custom initramfs name or auto-detect failed.) check , ok --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 9997147..61fe873 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,6 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and * in progress ... -* fix bug - -* improve perfomance - -* auto-detect initramfs - * detect partition boot separate From 3a7ea84dda6d133af034bd0d21a58cb21bd6ea39 Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 00:56:50 +0200 Subject: [PATCH 13/35] oops :) --- 41_snapshots-btrfs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 23ca92f..db1824b 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -212,6 +212,7 @@ list_kernels_initramfs() ### Choice of method ### if [ ${choise_of_method} = "1" ] ; then gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; - list_kernels_initramfs ; fi + list_kernels_initramfs ; gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; +fi ### End choice of method ### From adc4fd66874bfdf7396f08c62518ac24fd68057b Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 04:35:46 +0200 Subject: [PATCH 14/35] improve layout for entries in grub --- 41_snapshots-btrfs | 49 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index db1824b..c6bb6c4 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -29,8 +29,7 @@ # # # Script in progress # # to do : # -# # -# * auto-detect initramfs, custom Initramfs # +# # # # * detect partition boot separate # # # ######################################################################################################################################################### @@ -99,32 +98,30 @@ snapshots_entry() for k in "${name_kernel[@]}"; do for i in "${name_initramfs[@]}"; do echo "\ - menuentry '${2} with "${k}" & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ - $(save_default_entry) - if [ x\$feature_all_video_module = xy ]; then - insmod all_video - fi - set gfxpayload=keep - insmod ${boot_fs} - if [ x\$feature_platform_search_hint = xy ]; then - search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid} - else - search --no-floppy --fs-uuid --set=root ${boot_uuid} - fi - echo 'Loading Snapshot: ${snap_dir_name}' - echo 'Loading Kernel: "${k}" ...' - linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} - echo 'Loading Initramfs: "${i}" ...'" + menuentry '${2} with "${k}" & "${i}"' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{ + $(save_default_entry) + if [ x\$feature_all_video_module = xy ]; then + insmod all_video + fi + set gfxpayload=keep + insmod ${boot_fs} + if [ x\$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid} + else + search --no-floppy --fs-uuid --set=root ${boot_uuid} + fi + echo 'Loading Snapshot: ${snap_dir_name}' + echo 'Loading Kernel: "${k}" ...' + linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} + echo 'Loading Initramfs: "${i}" ...'" if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then - echo "\ - initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\" - " + echo "\ + initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\"" else - echo "\ - initrd \"/${snap_dir_name}/boot/${i}\" - " + echo "\ + initrd \"/${snap_dir_name}/boot/${i}\"" fi - echo " }" + echo " }" done done echo " }" @@ -215,4 +212,4 @@ if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; fi -### End choice of method ### +### End choice of method ### \ No newline at end of file From 94c9fedef3132abce81c18a02c74420ca858004a Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 23:56:38 +0200 Subject: [PATCH 15/35] detect partition boot separate check, ok --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 61fe873..3e6e7f9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Makes a list of all snapshots, kernels, initramfs present on the filesystem and #### TO DO * in progress ... - -* detect partition boot separate +* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) From 87bc0f6358f2f4f31f39af23e8472ae82eaec0e9 Mon Sep 17 00:00:00 2001 From: Antynea Date: Thu, 6 Aug 2015 23:57:29 +0200 Subject: [PATCH 16/35] detect partition boot separate check, ok --- 41_snapshots-btrfs | 83 +++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index c6bb6c4..be057a4 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -8,7 +8,7 @@ # # # What this script does: # # - Automatically List snapshots existing on root partition (btrfs). # -# - 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. (For custon name, see below.) # # - Automatically Create corresponding menuentry in grub.cfg , which ensures a very easy rollback. # # # # How to use it: # @@ -30,7 +30,7 @@ # Script in progress # # to do : # # # # -# * detect partition boot separate # +# * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) # # # ######################################################################################################################################################### @@ -83,6 +83,13 @@ gbgmp="/tmp/gbgmp" CLASS="--class snapshots --class gnu-linux --class gnu --class os" ## save IFS oldIFS=$IFS +## grub path (auto-detect if /boot is separate partition or not) +grub_path() +{ + grub_path="$gbgmp/$snap_dir_name/boot" + [[ root_uuid != boot_uuid ]] && grub_path="/boot" + echo "$grub_path" +} ############## @@ -94,6 +101,7 @@ oldIFS=$IFS ## menu entries snapshots_entry() { +## \" required for snap,kernels,init,microcode with space in their name echo " submenu '${1} ${2} ${3}' {" for k in "${name_kernel[@]}"; do for i in "${name_initramfs[@]}"; do @@ -110,16 +118,16 @@ snapshots_entry() else search --no-floppy --fs-uuid --set=root ${boot_uuid} fi - echo 'Loading Snapshot: ${snap_dir_name}' + echo 'Loading Snapshot: "${snap_dir_name}" "${snap_date_time}"' echo 'Loading Kernel: "${k}" ...' - linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=${snap_dir_name} ${kernel_parameters} + linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=\""${snap_dir_name}"\" ${kernel_parameters} echo 'Loading Initramfs: "${i}" ...'" - if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then + if [ -f "/${snap_dir_name}/boot/"${microcode}"" ] ; then echo "\ - initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\"" + initrd \"/${snap_dir_name}/boot/"${microcode}"\" initrd \"/${snap_dir_name}/boot/"${i}"\"" else echo "\ - initrd \"/${snap_dir_name}/boot/${i}\"" + initrd \"/${snap_dir_name}/boot/"${i}"\"" fi echo " }" done @@ -144,14 +152,14 @@ snapshot_list() detect_kernel() { ## Arch original kernel (auto-detect) - for akernel in $snap_dir_boot/vmlinuz-* ; do + for akernel in $(grub_path)/vmlinuz-* ; do list_kernel+=("$akernel") done ## Custom name kernel in GRUB_BTRFS_NKERNEL if [ ! -z ${nkernel} ] ; then for ckernel in "${nkernel[@]}" ; do - [[ ! -f /${snap_dir_boot}/${ckernel} ]] && continue; + [[ ! -f /$(grub_path)/${ckernel} ]] && continue; list_kernel+=("$ckernel") done fi @@ -160,14 +168,14 @@ detect_kernel() detect_initramfs() { ## Arch original kernel (auto-detect) - for ainitramfs in $snap_dir_boot/initramfs-* ; do + for ainitramfs in $(grub_path)/initramfs-* ; do list_initramfs+=("$ainitramfs") done ## Custom name initramfs in GRUB_BTRFS_NINIT if [ ! -z ${ninit} ] ; then for cinitramfs in "${ninit[@]}" ; do - [[ ! -f /${snap_dir_boot}/${ninit} ]] && continue; + [[ ! -f /$(grub_path)/${ninit} ]] && continue; list_initramfs+=("$ninit") done fi @@ -176,40 +184,41 @@ detect_initramfs() ## List of kernels and initramfs in snapshots list_kernels_initramfs() { - [[ ! -d $gbgmp ]] && mkdir -p $gbgmp - mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ - echo "submenu '${submenuname}' {" - IFS=$'\n' - for item in $(snapshot_list); do - IFS=$oldIFS - item=($item) - snap_dir_name=${item[@]:2:${#item[@]}} - if [ -f $gbgmp/$snap_dir_name/boot/grub/grub.cfg ]; then - snap_date_time=${item[@]:0:2} - gettext_printf $"Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; - snap_dir_boot=$gbgmp/$snap_dir_name/boot - unset list_kernel - detect_kernel - name_kernel=("${list_kernel[@]##*"/"}") - # echo "kernel = ${name_kernel[*]}" - unset list_initramfs - detect_initramfs - name_initramfs=("${list_initramfs[@]##*"/"}") - # echo "initramfs = ${name_initramfs[*]}" - fi - # Create menu entries - snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" - done - echo "}" + if [ $root_uuid = $boot_uuid ] ; then + [[ ! -d $gbgmp ]] && mkdir -p $gbgmp + mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ + fi + IFS=$'\n' + for item in $(snapshot_list); do + IFS=$oldIFS + item=($item) + snap_dir_name=${item[@]:2:${#item[@]}} + if [ -f $(grub_path)/grub/grub.cfg ]; then + snap_date_time=${item[@]:0:2} + gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; + unset list_kernel + detect_kernel + name_kernel=("${list_kernel[@]##*"/"}") + # echo "kernel = ${name_kernel[*]}" + unset list_initramfs + detect_initramfs + name_initramfs=("${list_initramfs[@]##*"/"}") + # echo "initramfs = ${name_initramfs[*]}" + fi + # Create menu entries + snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + done IFS=$oldIFS - umount $gbgmp + if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi } ### END auto detect ### ### Choice of method ### if [ ${choise_of_method} = "1" ] ; then gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; + echo "submenu '${submenuname}' {" list_kernels_initramfs ; + echo "}" gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; fi ### End choice of method ### \ No newline at end of file From 52dd3760477e5954d1d732442e0df19094fbbc1f Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 00:12:23 +0200 Subject: [PATCH 17/35] enhanced readme --- README.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3e6e7f9..1df4136 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,33 @@ This is a version 1.xx of grub-btrfs #### Description -grub-btrfs, add support for btrfs snapshots into grub menu +grub-btrfs, Include btrfs snapshots at boot options. (grub menu) #### What does grub-btrfs v1.xx do : -Simple rollback using snapshots you made previous. +Simple rollback using snapshots you made previously. + +- Automatically List snapshots existing on root partition (btrfs). +- Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots. (For custon name, see below.) +- Automatically Create corresponding menuentry in grub.cfg , which ensures a very easy rollback. + + +#### How to use it: + +- Add this lines to /etc/default/grub: + +* GRUB_BTRFS_SUBMENUNAME="ArchLinux Snapshots" (Name menu appearing in grub.) +* GRUB_BTRFS_PREFIXENTRY="Snapshot:" (Add a name ahead your snapshots entries.) +* GRUB_BTRFS_NKERNEL=("vmlinuz-linux") (Use only if you have custom kernel name or auto-detect failed.) +* GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") (Use only if you have custom initramfs name or auto-detect failed.) +* GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") (Use only if you have custom intel-ucode or auto-detect failed.) + +- Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg ) +- grub-btrfs automatically generates snapshots entries. +- You will see it appear differents entries (e.g : Snapshot: my snapshot name overkill [2014-02-12 11:24:37]) -Makes a list of all snapshots, kernels, initramfs present on the filesystem and then creates a corresponding input with name and date of snapshots in grub.cfg, which ensures a very easy rollback. #### TO DO * in progress ... -* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) - - +* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) \ No newline at end of file From bc650f2caff8a466838c4f711f87cb74b7c0a220 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 00:14:48 +0200 Subject: [PATCH 18/35] Update README.md enhanced readme --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1df4136..9e907bc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Simple rollback using snapshots you made previously. #### How to use it: -- Add this lines to /etc/default/grub: +Add this lines to /etc/default/grub: * GRUB_BTRFS_SUBMENUNAME="ArchLinux Snapshots" (Name menu appearing in grub.) * GRUB_BTRFS_PREFIXENTRY="Snapshot:" (Add a name ahead your snapshots entries.) @@ -26,12 +26,14 @@ Simple rollback using snapshots you made previously. * GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") (Use only if you have custom initramfs name or auto-detect failed.) * GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") (Use only if you have custom intel-ucode or auto-detect failed.) -- Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg ) -- grub-btrfs automatically generates snapshots entries. -- You will see it appear differents entries (e.g : Snapshot: my snapshot name overkill [2014-02-12 11:24:37]) +Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg ) + +grub-btrfs automatically generates snapshots entries. + +You will see it appear differents entries (e.g : Snapshot: my snapshot name overkill [2014-02-12 11:24:37]) #### TO DO * in progress ... -* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) \ No newline at end of file +* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) From 9d21a629d89ff55eeb25d87a9167460fa921e12e Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 00:40:56 +0200 Subject: [PATCH 19/35] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9e907bc..e81ec51 100644 --- a/README.md +++ b/README.md @@ -35,5 +35,4 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO -* in progress ... * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) From 81bb76fbc38b73b1ef36344e2b81281bf4016d21 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 01:12:11 +0200 Subject: [PATCH 20/35] translation for grub-btrfs-git version 1.xx --- localisation/fr/grub-btrfs-git.mo | Bin 318 -> 104 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/localisation/fr/grub-btrfs-git.mo b/localisation/fr/grub-btrfs-git.mo index 3902c81cb63af55386d51ba98916a51c77e15661..8ed56e56597e7b18c2a036cb75f96ad74525ec0b 100644 GIT binary patch literal 104 zcmca7#4?ou2pEA_28dOFm>Gz5fLIKOEr3`8i2Z>W20&_+72NVm^HLOo^AZb+GxAHU X6jY02@_@oH0fmyH{L-?+E1?nqefJYK literal 318 zcmca7#4?ou2$+Fb28d07m=%b9fLI5J6M$G7hAa*S($}h4~&`-+GFVR=Y%*!m%Q2>!eiMeUT3Mu)i#R_@(B?_q(nZ+e& zinCLT@=|kj6d*LZTDSbtycC7tyu^ayjQkQS1=Zr1JTwE)ZOc;!Ta&6#kcg=m%{DZ( RFnbhAitRXqRz From be28f3657eb36fdb5d091c9f6c9035d01fc0e5fd Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 01:45:11 +0200 Subject: [PATCH 21/35] * correct menuentry when /boot in separate partition --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e81ec51..6362d26 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,5 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO +* correct menuentry when /boot in separate partition * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) From 0ab7aa02bb935b7f6d60d461112f6e75e282c253 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 12:54:03 +0200 Subject: [PATCH 22/35] Correct menuentry add /boot separate partition --- 41_snapshots-btrfs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index be057a4..f65ddf9 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -9,7 +9,7 @@ # What this script does: # # - Automatically List snapshots existing on root partition (btrfs). # # - Automatically Detect kernel, initramfs and intel microcode in "/boot" directory on snapshots. (For custon name, see below.) # -# - Automatically Create corresponding menuentry in grub.cfg , which ensures a very easy rollback. # +# - Automatically Create corresponding "menuentry" in grub.cfg , which ensures a very easy rollback. # # # # How to use it: # # - Add this lines to /etc/default/grub: # @@ -84,11 +84,11 @@ CLASS="--class snapshots --class gnu-linux --class gnu --class os" ## save IFS oldIFS=$IFS ## grub path (auto-detect if /boot is separate partition or not) -grub_path() +boot_dir() { - grub_path="$gbgmp/$snap_dir_name/boot" - [[ root_uuid != boot_uuid ]] && grub_path="/boot" - echo "$grub_path" + boot_dir="$gbgmp/$snap_dir_name/boot" + [[ "$root_uuid" != "$boot_uuid" ]] && boot_dir="/boot" + echo "$boot_dir" } @@ -120,14 +120,14 @@ snapshots_entry() fi echo 'Loading Snapshot: "${snap_dir_name}" "${snap_date_time}"' echo 'Loading Kernel: "${k}" ...' - linux \"/${snap_dir_name}/boot/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=\""${snap_dir_name}"\" ${kernel_parameters} + linux \"${boot_dir_real_path}/"${k}"\" root=UUID=${root_uuid} rw rootflags=subvol=\""${snap_dir_name}"\" ${kernel_parameters} echo 'Loading Initramfs: "${i}" ...'" - if [ -f "/${snap_dir_name}/boot/"${microcode}"" ] ; then + if [ -f "/${boot_dir_real_path}/"${microcode}"" ] ; then echo "\ - initrd \"/${snap_dir_name}/boot/"${microcode}"\" initrd \"/${snap_dir_name}/boot/"${i}"\"" + initrd \"${boot_dir_real_path}/"${microcode}"\" initrd \"/${snap_dir_name}/boot/"${i}"\"" else echo "\ - initrd \"/${snap_dir_name}/boot/"${i}"\"" + initrd \"${boot_dir_real_path}/"${i}"\"" fi echo " }" done @@ -152,14 +152,14 @@ snapshot_list() detect_kernel() { ## Arch original kernel (auto-detect) - for akernel in $(grub_path)/vmlinuz-* ; do + for akernel in $(boot_dir)/vmlinuz-* ; do list_kernel+=("$akernel") done ## Custom name kernel in GRUB_BTRFS_NKERNEL if [ ! -z ${nkernel} ] ; then for ckernel in "${nkernel[@]}" ; do - [[ ! -f /$(grub_path)/${ckernel} ]] && continue; + [[ ! -f /$(boot_dir)/${ckernel} ]] && continue; list_kernel+=("$ckernel") done fi @@ -168,14 +168,14 @@ detect_kernel() detect_initramfs() { ## Arch original kernel (auto-detect) - for ainitramfs in $(grub_path)/initramfs-* ; do + for ainitramfs in $(boot_dir)/initramfs-* ; do list_initramfs+=("$ainitramfs") done ## Custom name initramfs in GRUB_BTRFS_NINIT if [ ! -z ${ninit} ] ; then for cinitramfs in "${ninit[@]}" ; do - [[ ! -f /$(grub_path)/${ninit} ]] && continue; + [[ ! -f /$(boot_dir)/${ninit} ]] && continue; list_initramfs+=("$ninit") done fi @@ -193,7 +193,8 @@ list_kernels_initramfs() IFS=$oldIFS item=($item) snap_dir_name=${item[@]:2:${#item[@]}} - if [ -f $(grub_path)/grub/grub.cfg ]; then + boot_dir_real_path="$(make_system_path_relative_to_its_root "$(boot_dir)")" + if [ -f $(boot_dir)/grub/grub.cfg ]; then snap_date_time=${item[@]:0:2} gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; unset list_kernel From f46c38d141381dbd552ef030cc913551a3151085 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 12:55:02 +0200 Subject: [PATCH 23/35] typo --- 41_snapshots-btrfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index f65ddf9..ac71015 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -83,7 +83,7 @@ gbgmp="/tmp/gbgmp" CLASS="--class snapshots --class gnu-linux --class gnu --class os" ## save IFS oldIFS=$IFS -## grub path (auto-detect if /boot is separate partition or not) +## boot_dir (auto-detect if /boot is separate partition or not) boot_dir() { boot_dir="$gbgmp/$snap_dir_name/boot" From 178cdb163c3a9692bbefc0f7d1a0157f228f2fd4 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 13:01:00 +0200 Subject: [PATCH 24/35] correct menuentry when /boot is separate partition --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6362d26..e81ec51 100644 --- a/README.md +++ b/README.md @@ -35,5 +35,4 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO -* correct menuentry when /boot in separate partition * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) From 26d8e83c8cde4f0dffc78e15621684cbf53fb310 Mon Sep 17 00:00:00 2001 From: Antynea Date: Fri, 7 Aug 2015 14:16:03 +0200 Subject: [PATCH 25/35] structuring --- 41_snapshots-btrfs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index ac71015..008f655 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -89,6 +89,7 @@ boot_dir() boot_dir="$gbgmp/$snap_dir_name/boot" [[ "$root_uuid" != "$boot_uuid" ]] && boot_dir="/boot" echo "$boot_dir" + boot_dir_real_path="$(make_system_path_relative_to_its_root "$boot_dir")" } @@ -193,7 +194,6 @@ list_kernels_initramfs() IFS=$oldIFS item=($item) snap_dir_name=${item[@]:2:${#item[@]}} - boot_dir_real_path="$(make_system_path_relative_to_its_root "$(boot_dir)")" if [ -f $(boot_dir)/grub/grub.cfg ]; then snap_date_time=${item[@]:0:2} gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; @@ -204,10 +204,10 @@ list_kernels_initramfs() unset list_initramfs detect_initramfs name_initramfs=("${list_initramfs[@]##*"/"}") - # echo "initramfs = ${name_initramfs[*]}" + echo "initramfs = ${name_initramfs[*]}" fi # Create menu entries - snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + # snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done IFS=$oldIFS if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi From 00b8f4106d3ab8ef88cb219253cc2c2076779027 Mon Sep 17 00:00:00 2001 From: Antynea Date: Sat, 8 Aug 2015 03:45:08 +0200 Subject: [PATCH 26/35] Update README.md To do Uefi compatibility --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e81ec51..9260aa9 100644 --- a/README.md +++ b/README.md @@ -35,4 +35,4 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO -* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) +* verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) From f379832df36bbeada5ef56abb8f24b9d85dce284 Mon Sep 17 00:00:00 2001 From: Antynea Date: Sat, 8 Aug 2015 03:50:00 +0200 Subject: [PATCH 27/35] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9260aa9..89b41c6 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,7 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO * verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) + + +## discussion +Pour les francophones : https://forums.archlinux.fr/viewtopic.php?f=18&t=17177 From c9d47b78547d8234837166a857fae97dc906e33c Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 9 Aug 2015 16:36:48 +0200 Subject: [PATCH 28/35] error when /grub is not in /boot --- 41_snapshots-btrfs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 008f655..d41b364 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -30,7 +30,7 @@ # Script in progress # # to do : # # # # -# * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) # +# * verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) # # # ######################################################################################################################################################### @@ -168,7 +168,7 @@ detect_kernel() detect_initramfs() { - ## Arch original kernel (auto-detect) + ## Arch original initramfs (auto-detect) for ainitramfs in $(boot_dir)/initramfs-* ; do list_initramfs+=("$ainitramfs") done @@ -194,20 +194,19 @@ list_kernels_initramfs() IFS=$oldIFS item=($item) snap_dir_name=${item[@]:2:${#item[@]}} - if [ -f $(boot_dir)/grub/grub.cfg ]; then - snap_date_time=${item[@]:0:2} - gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; - unset list_kernel - detect_kernel - name_kernel=("${list_kernel[@]##*"/"}") - # echo "kernel = ${name_kernel[*]}" - unset list_initramfs - detect_initramfs - name_initramfs=("${list_initramfs[@]##*"/"}") - echo "initramfs = ${name_initramfs[*]}" - fi + [[ ! -d $(boot_dir) ]] && continue; + snap_date_time=${item[@]:0:2} + gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; + unset list_kernel + detect_kernel + name_kernel=("${list_kernel[@]##*"/"}") + # echo "kernel = ${name_kernel[*]}" + unset list_initramfs + detect_initramfs + name_initramfs=("${list_initramfs[@]##*"/"}") + # echo "initramfs = ${name_initramfs[*]}" # Create menu entries - # snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done IFS=$oldIFS if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi From 34c8fbd9cb22b730c4a618f688136e2e9358c93e Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 9 Aug 2015 16:43:56 +0200 Subject: [PATCH 29/35] error if /grub is in /boot/EFI --- 41_snapshots-btrfs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index d41b364..ac4d659 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -46,7 +46,7 @@ sysconfdir="/etc" . "${sysconfdir}/default/grub" ###################################### -### variables in /etc/default/grub ### +### Variables in /etc/default/grub ### ###################################### ## Choice of method choise_of_method=${GRUB_BTRFS_SUBMENUNAME:-"1"} From 2773382eb5e3611e5710deb2ca23f4cc993cc211 Mon Sep 17 00:00:00 2001 From: Antynea Date: Sun, 9 Aug 2015 17:42:56 +0200 Subject: [PATCH 30/35] error if /grub is in /boot/EFI --- 41_snapshots-btrfs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index ac4d659..343b38b 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -89,7 +89,7 @@ boot_dir() boot_dir="$gbgmp/$snap_dir_name/boot" [[ "$root_uuid" != "$boot_uuid" ]] && boot_dir="/boot" echo "$boot_dir" - boot_dir_real_path="$(make_system_path_relative_to_its_root "$boot_dir")" + if [ -d ${boot_dir} ]; then boot_dir_real_path="$(make_system_path_relative_to_its_root "$boot_dir")"; fi } @@ -206,7 +206,7 @@ list_kernels_initramfs() name_initramfs=("${list_initramfs[@]##*"/"}") # echo "initramfs = ${name_initramfs[*]}" # Create menu entries - snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + # snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done IFS=$oldIFS if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi From 2b33b88bea71fb25d67b5cdf38b9230dd01e2f2d Mon Sep 17 00:00:00 2001 From: Antynea Date: Tue, 11 Aug 2015 02:57:09 +0200 Subject: [PATCH 31/35] don't create menu if snapshot is not bootable with /boot partition separate --- 41_snapshots-btrfs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 343b38b..037caa0 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -30,7 +30,8 @@ # Script in progress # # to do : # # # # -# * verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) # +# * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) # +# * don't create menu if snapshot is not bootable with /boot partition separate # # # ######################################################################################################################################################### @@ -206,7 +207,7 @@ list_kernels_initramfs() name_initramfs=("${list_initramfs[@]##*"/"}") # echo "initramfs = ${name_initramfs[*]}" # Create menu entries - # snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" + snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done IFS=$oldIFS if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi From 1f3575efd167a30dacf17f10203d24bc21ae58d9 Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 12 Aug 2015 06:01:49 +0200 Subject: [PATCH 32/35] Update README.md To do : don't create menu if snapshot is not bootable with /boot partition separate --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 89b41c6..517f7e7 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over * verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) +don't create menu if snapshot is not bootable with /boot partition separate + ## discussion Pour les francophones : https://forums.archlinux.fr/viewtopic.php?f=18&t=17177 From 619686990e7bb06917cff9d2e41ba2cdba3f1d9d Mon Sep 17 00:00:00 2001 From: Antynea Date: Wed, 12 Aug 2015 06:02:45 +0200 Subject: [PATCH 33/35] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 517f7e7..d61c317 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over #### TO DO -* verify compatibility with UEFI,manjaro and snapper (but I don't use them, so it will take some time) +* verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) -don't create menu if snapshot is not bootable with /boot partition separate +* don't create menu if snapshot is not bootable with /boot partition separate ## discussion From 05fea226f9b3dc1fa84305e546690ce0b944f3d3 Mon Sep 17 00:00:00 2001 From: Antynea Date: Mon, 17 Aug 2015 23:33:05 +0200 Subject: [PATCH 34/35] don't create menu if snapshot is not bootable with /boot partition separate --- 41_snapshots-btrfs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index 037caa0..5943cc2 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -31,7 +31,7 @@ # to do : # # # # # * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) # -# * don't create menu if snapshot is not bootable with /boot partition separate # +# # # # ######################################################################################################################################################### @@ -186,16 +186,12 @@ detect_initramfs() ## List of kernels and initramfs in snapshots list_kernels_initramfs() { - if [ $root_uuid = $boot_uuid ] ; then - [[ ! -d $gbgmp ]] && mkdir -p $gbgmp - mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ - fi IFS=$'\n' for item in $(snapshot_list); do IFS=$oldIFS item=($item) snap_dir_name=${item[@]:2:${#item[@]}} - [[ ! -d $(boot_dir) ]] && continue; + [[ ! -d "$gbgmp/$snap_dir_name/boot" ]] && continue; snap_date_time=${item[@]:0:2} gettext_printf $"# Found Snapshot: %s\n" "$snap_dir_name $snap_date_time" >&2 ; unset list_kernel @@ -210,16 +206,18 @@ list_kernels_initramfs() snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}" done IFS=$oldIFS - if [ $root_uuid = $boot_uuid ] ; then umount $gbgmp ; fi } ### END auto detect ### ### Choice of method ### if [ ${choise_of_method} = "1" ] ; then gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; + [[ ! -d $gbgmp ]] && mkdir -p $gbgmp + mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/ echo "submenu '${submenuname}' {" list_kernels_initramfs ; echo "}" + umount $gbgmp gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; fi ### End choice of method ### \ No newline at end of file From 8102850627a74677531a6fc3c649166f70f7a175 Mon Sep 17 00:00:00 2001 From: Antynea Date: Mon, 17 Aug 2015 23:51:50 +0200 Subject: [PATCH 35/35] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d61c317..81d8ed6 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ You will see it appear differents entries (e.g : Snapshot: my snapshot name over * verify compatibility with manjaro and snapper (but I don't use them, so it will take some time) -* don't create menu if snapshot is not bootable with /boot partition separate ## discussion