diff --git a/41_snapshots-btrfs b/41_snapshots-btrfs index aae0b35..392f5f0 100644 --- a/41_snapshots-btrfs +++ b/41_snapshots-btrfs @@ -74,6 +74,12 @@ ninit=("${GRUB_BTRFS_NINIT[@]}") microcode=("${GRUB_BTRFS_INTEL_UCODE[@]}") ## Limit to show in menu limit=("${GRUB_BTRFS_LIMIT[@]:-100}") +## How to sort +subvolsort=${GRUB_BTRFS_SUBVOLUME_SORT:-"descending"} +case "${subvolsort}" in + ascending) btrfssubvolsort=("--sort=+rootid");; + *) btrfssubvolsort=("--sort=-rootid") +esac ######################## ### variables script ### @@ -158,7 +164,7 @@ snapshots_entry() ## List of snapshots on filesystem snapshot_list() { - for snap in $(btrfs subvolume list -sa --sort=-rootid /); do + for snap in $(btrfs subvolume list -sa "${btrfssubvolsort}" /); do IFS=$oldIFS snap=($snap) local snap_path_name=${snap[@]:13:${#snap[@]}} diff --git a/README.md b/README.md index cdc0dfa..69074e0 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,15 @@ Add this lines to /etc/default/grub: (Use only if you have custom intel-ucode or auto-detect failed.) +* GRUB_BTRFS_LIMIT=("100") + (Limit the number of snapshots populated in the GRUB menu.) + +* GRUB_BTRFS_SUBVOLUME_SORT=("descending") + + (Sort the found subvolumes by newest first ("descending") or oldest first +("ascending"). If "ascending" is chosen then the $GRUB_BTRFS_LIMIT oldest +subvolumes will populate the menu.) Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg )