40
40
# (Use only if you have custom intel-ucode or auto-detect failed.) #
41
41
# * GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("var/lib/docker" "nosapshot") #
42
42
# (Ignore specific path during run "grub-mkconfig") #
43
+ # * GRUB_BTRFS_CREATE_ONLY_HARMONIZED_ENTRIES="false" #
44
+ # (Create entries with matching version number instead of all possible combinations of kernel and initramfs) #
43
45
# #
44
46
# - Generate grub.cfg (on Archlinux use grub-mkconfig -o /boot/grub/grub.cfg) #
45
47
# #
@@ -95,6 +97,8 @@ show_snap_found=${GRUB_BTRFS_SHOW_SNAPSHOTS_FOUND:-"true"}
95
97
show_total_snap_found=${GRUB_BTRFS_SHOW_TOTAL_SNAPSHOTS_FOUND:- " true" }
96
98
# # Ignore specific path during run "grub-mkconfig"
97
99
ignore_specific_path=(" ${GRUB_BTRFS_IGNORE_SPECIFIC_PATH[@]} " )
100
+ # # create only entries with harmonized version numbers
101
+ harmonized_entries=${GRUB_BTRFS_CREATE_ONLY_HARMONIZED_ENTRIES:- " false" }
98
102
99
103
100
104
# #######################
@@ -114,7 +118,7 @@ root_uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null)
114
118
# # Parameters passed to the kernel
115
119
kernel_parameters=" $GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT "
116
120
# # Mount point location
117
- gbgmp=" /tmp/gbgmp "
121
+ gbgmp=$( mktemp -d )
118
122
# # Class for theme
119
123
CLASS=" --class snapshots --class gnu-linux --class gnu --class os"
120
124
# # save IFS
@@ -177,6 +181,63 @@ snapshots_entry()
177
181
echo " }"
178
182
}
179
183
184
+ harmonized_snapshots_entry ()
185
+ {
186
+ # # \" required for snap,kernels,init,microcode with space in their name
187
+ echo " submenu '" ${title_menu[*]} " ' {
188
+ submenu '---> " ${title_menu[*]} " <---' { echo }
189
+ "
190
+ for k in " ${name_kernel[@]} " ; do
191
+ version=${k# vmlinuz-}
192
+
193
+ i=" "
194
+ if [[ -e " $( boot_dir) " /initramfs-${version} ]]; then
195
+ i=initramfs-${version}
196
+ else
197
+ if [[ -e " $( boot_dir) " /initrd.img-${version} ]]; then
198
+ i=initrd.img-${version}
199
+ fi
200
+ fi
201
+
202
+ u=" "
203
+ if [ -f " $( boot_dir) " /intel-ucode.img ]; then
204
+ u=intel-ucode.img
205
+ fi
206
+
207
+
208
+ echo " \
209
+ menuentry '" ${k} " ' ${CLASS} " \$ menuentry_id_option" 'gnulinux-snapshots-$boot_uuid '{
210
+ $( save_default_entry)
211
+ if [ x\$ feature_all_video_module = xy ]; then
212
+ insmod all_video
213
+ fi
214
+ set gfxpayload=keep
215
+ insmod ${boot_fs}
216
+ if [ x\$ feature_platform_search_hint = xy ]; then
217
+ search --no-floppy --fs-uuid --set=root ${hs_boot} ${boot_uuid}
218
+ else
219
+ search --no-floppy --fs-uuid --set=root ${boot_uuid}
220
+ fi
221
+ echo 'Loading Snapshot: " ${snap_date_time} " " ${snap_dir_name} " '
222
+ echo 'Loading Kernel: " ${k} " ...'
223
+ linux \" ${boot_dir_real_path} /" ${k} " \" root=UUID=${root_uuid} rw rootflags=subvol=\" " ${snap_dir_name} " \" ${kernel_parameters} \
224
+ "
225
+ if [[ ! -z ${i} ]]; then
226
+ if [ ! -z ${u} ] ; then
227
+ echo " \
228
+ echo 'Loading Microcode & Initramfs: " ${u} " " ${i} " ...'
229
+ initrd \" ${boot_dir_real_path} /" ${u} " \" \" ${boot_dir_real_path} /" ${i} " \" "
230
+ else
231
+ echo " \
232
+ echo 'Loading Initramfs: " ${i} " ...'
233
+ initrd \" ${boot_dir_real_path} /" ${i} " \" "
234
+ fi
235
+ fi
236
+ echo " }"
237
+ done
238
+ echo " }"
239
+ }
240
+
180
241
# # List of snapshots on filesystem
181
242
snapshot_list ()
182
243
{
@@ -297,16 +358,19 @@ list_kernels_initramfs()
297
358
detect_kernel
298
359
name_kernel=(" ${list_kernel[@]##* " /" } " )
299
360
# echo "kernel = ${name_kernel[*]}"
300
- # ## Initramfs (autodetect + custom initramfs)
301
- unset list_initramfs
302
- detect_initramfs
303
- name_initramfs=(" ${list_initramfs[@]##* " /" } " )
304
- # echo "initramfs = ${name_initramfs[*]}"
305
- # ## microcode (auto-detect + custom microcode)
306
- unset list_ucode
307
- detect_microcode
308
- name_microcode=(" ${list_ucode[@]##* " /" } " )
309
- # echo "ucode = ${name_microcode[*]}"
361
+
362
+ if [[ " ${harmonized_entries} " = " false" ]]; then
363
+ # ## Initramfs (autodetect + custom initramfs)
364
+ unset list_initramfs
365
+ detect_initramfs
366
+ name_initramfs=(" ${list_initramfs[@]##* " /" } " )
367
+ # echo "initramfs = ${name_initramfs[*]}"
368
+ # ## microcode (auto-detect + custom microcode)
369
+ unset list_ucode
370
+ detect_microcode
371
+ name_microcode=(" ${list_ucode[@]##* " /" } " )
372
+ # echo "ucode = ${name_microcode[*]}"
373
+ fi
310
374
# ## real path to boot
311
375
boot_dir_real_path=" $( make_system_path_relative_to_its_root " $( boot_dir) " ) "
312
376
# ## Create menu entries
@@ -315,7 +379,11 @@ list_kernels_initramfs()
315
379
# # title menu custom
316
380
title_format
317
381
# echo "${title_menu[*]}"
318
- snapshots_entry
382
+ if [[ " ${harmonized_entries} " = " false" ]]; then
383
+ snapshots_entry
384
+ else
385
+ harmonized_snapshots_entry
386
+ fi
319
387
# ## Limit snapshots found during run "grub-mkconfig"
320
388
count_limit_snap=$(( 1 + $count_limit_snap ))
321
389
[[ $count_limit_snap -ge $limit_snap_show ]] && break ;
0 commit comments