Add GRUB_BTRFS_LIMIT

Allow user to limit the number of snapshots listed in GRUB. This also reverses
the order of the snapshots such that the more recent ones come first. That is,
if a user specifies GRUB_BTRFS_LIMIT=10, then only the 10 most recent snapshots
will be shown. The default limit is 100, which seems very large. The more
snapshots in the GRUB menu, the longer the system takes to boot.
This commit is contained in:
James Barnett
2016-03-18 16:46:11 -05:00
parent 52ab9dbe95
commit f256338074
+12 -2
View File
@@ -72,6 +72,11 @@ nkernel=("${GRUB_BTRFS_NKERNEL[@]}")
ninit=("${GRUB_BTRFS_NINIT[@]}") ninit=("${GRUB_BTRFS_NINIT[@]}")
## Microcode(s) name(s) ## Microcode(s) name(s)
microcode=("${GRUB_BTRFS_INTEL_UCODE[@]}") microcode=("${GRUB_BTRFS_INTEL_UCODE[@]}")
## Limit to show in menu
limit=("${GRUB_BTRFS_LIMIT[@]}")
if [ -z "$limit" ]; then
limit=100
fi
######################## ########################
### variables script ### ### variables script ###
@@ -156,7 +161,7 @@ snapshots_entry()
## List of snapshots on filesystem ## List of snapshots on filesystem
snapshot_list() snapshot_list()
{ {
for snap in $(btrfs subvolume list -sa /); do for snap in $(btrfs subvolume list -sa / | tac); do
IFS=$oldIFS IFS=$oldIFS
snap=($snap) snap=($snap)
local snap_path_name=${snap[@]:13:${#snap[@]}} local snap_path_name=${snap[@]:13:${#snap[@]}}
@@ -249,6 +254,7 @@ title_format()
list_kernels_initramfs() list_kernels_initramfs()
{ {
IFS=$'\n' IFS=$'\n'
c=0
for item in $(snapshot_list); do for item in $(snapshot_list); do
IFS=$oldIFS IFS=$oldIFS
item=($item) item=($item)
@@ -276,6 +282,10 @@ list_kernels_initramfs()
title_format title_format
# echo "${title_menu[*]}" # echo "${title_menu[*]}"
snapshots_entry snapshots_entry
c=$((1+$c))
if [[ $c -gt $limit ]]; then
break;
fi
done done
IFS=$oldIFS IFS=$oldIFS
} }
@@ -292,4 +302,4 @@ if [ ${choise_of_method} = "1" ] ; then
umount $gbgmp umount $gbgmp
gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ; gettext_printf "###### - Grub-btrfs: Auto-detect - ######\n" >&2 ;
fi fi
### End choice of method ### ### End choice of method ###