zbm-dev / zfsbootmenu

ZFS Bootloader for root-on-ZFS systems with support for snapshots and native full disk encryption
https://zfsbootmenu.org
MIT License
857 stars 65 forks source link

Sort the BEs by creation time in the boot menu #137

Closed vozhyk- closed 3 years ago

vozhyk- commented 3 years ago

Currently, the BEs seem to be sorted by name, except the default one, which is put at the beginning of the list.

Having the BEs sorted by creation and the default one highlighted in its place seems more natural to me - it helps make sense of a long list of BEs and see whether the default one is the newest.

# beadm list
BE                       Active Mountpoint Space Policy Created
gentoo-92                -      -          7.64M static 2020-03-14 21:32
gentoo-waybar            -      -          42.1M static 2020-06-06 12:55
gentoo-95                -      -          6.53M static 2020-06-13 22:27
gentoo-gnome-3.36        -      -          19.1M static 2020-06-15 12:51
gentoo-gnome-3.36-2      -      -          8.15M static 2020-06-18 09:58
gentoo-sway-1.5_rc1      -      -          24.3M static 2020-07-12 11:43
gentoo-iris              -      -          6.14M static 2020-07-12 20:15
gentoo-96                -      -          11.2M static 2020-07-12 21:04
gentoo-hplip             -      -          21.3M static 2020-08-11 18:59
gentoo-guitar            -      -          27.0M static 2020-08-24 17:12
gentoo-rt                -      -          621M  static 2020-10-02 17:51
gentoo-low-latency-2     -      -          2.06M static 2020-10-10 19:01
gentoo-rt-2              -      -          982M  static 2020-10-24 17:09
gentoo-meson-test        -      -          57.9M static 2020-10-24 23:48
gentoo-meson-test-2      -      -          27.6M static 2020-10-25 19:54
gentoo-meson-test-3      -      -          644M  static 2020-10-25 20:02
gentoo-zfs-0.8.6-test    -      -          20.9M static 2021-01-06 15:09
gentoo-zfs-0.8.9999-test -      -          44.4M static 2021-01-06 15:43
gentoo-genkernel-test    -      -          388M  static 2021-01-06 20:01
gentoo-zfsbootmenu       NR     /          63.5G static 2021-01-13 18:11
gentoo-boot-dataset      -      -          44.4M static 2021-01-16 20:42
gentoo-zfsbootmenu-test2 -      -          88.4M static 2021-01-16 23:03

Can an option to sort the list of BEs like that be added?

zdykstra commented 3 years ago

That's a good idea! I'll see how feasible this is to integrate in the -lib function with a KCL toggle for it.

ahesford commented 3 years ago

Sorting by creation should be easy, but highlighting the default by means other than moving it to the top might be harder.

zdykstra commented 3 years ago

I re-read the request here - fzf and skim can't pre-select an item in a list as far as I know, without masking all of the other items in the list (via --query). The only solution I have is to move the default to the top of the list, so that it's the default initial selection. Sorting the list by other criteria should be doable, though.

zdykstra commented 3 years ago

@vozhyk- if you're interested, https://github.com/zbm-dev/zfsbootmenu/tree/be-sort is generally ready for testing. Set zbm.sort_key=creation on the ZBM KCL and your BE list and snapshot list should be sorted by creation date. You can press $mod-o to cycle through name, creation, used . Let me know how it works for you.