mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-08-24 01:03:15 +08:00
GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img")
(Use only if you have custom initramfs name or auto-detect failed.) check, ok
This commit is contained in:
@@ -58,7 +58,7 @@ prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot:"}
|
|||||||
## Kernel(s) name(s)
|
## Kernel(s) name(s)
|
||||||
nkernel=("${GRUB_BTRFS_NKERNEL[@]}")
|
nkernel=("${GRUB_BTRFS_NKERNEL[@]}")
|
||||||
## Initramfs name(s)
|
## Initramfs name(s)
|
||||||
#ninit=("${GRUB_BTRFS_NINIT[@]}")
|
ninit=("${GRUB_BTRFS_NINIT[@]}")
|
||||||
## Microcode(s) name(s)
|
## Microcode(s) name(s)
|
||||||
microcode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")
|
microcode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")
|
||||||
|
|
||||||
@@ -95,39 +95,39 @@ oldIFS=$IFS
|
|||||||
## menu entries
|
## menu entries
|
||||||
snapshots_entry()
|
snapshots_entry()
|
||||||
{
|
{
|
||||||
echo " submenu '${1} ${2} ${3}' {"
|
echo " submenu '${1} ${2} ${3}' {"
|
||||||
for k in "${name_kernel[@]}"; do
|
for k in "${name_kernel[@]}"; do
|
||||||
for i in $(detect_initramfs); 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}" ...'"
|
|
||||||
if [ -f "/${snap_dir_name}/boot/${microcode}" ] ; then
|
|
||||||
echo "\
|
echo "\
|
||||||
initrd \"/${snap_dir_name}/boot/${microcode}\" initrd \"/${snap_dir_name}/boot/${i}\"
|
menuentry '${2} with "${k}" & ${i}' ${CLASS} "\$menuentry_id_option" 'gnulinux-snapshots-$boot_uuid'{
|
||||||
"
|
$(save_default_entry)
|
||||||
else
|
if [ x\$feature_all_video_module = xy ]; then
|
||||||
echo "\
|
insmod all_video
|
||||||
initrd \"/${snap_dir_name}/boot/${i}\"
|
fi
|
||||||
"
|
set gfxpayload=keep
|
||||||
fi
|
insmod ${boot_fs}
|
||||||
echo "}"
|
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
|
||||||
done
|
echo " }"
|
||||||
echo "}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## List of snapshots on filesystem
|
## List of snapshots on filesystem
|
||||||
@@ -148,7 +148,7 @@ detect_kernel()
|
|||||||
{
|
{
|
||||||
## Arch original kernel (auto-detect)
|
## Arch original kernel (auto-detect)
|
||||||
for akernel in $snap_dir_boot/vmlinuz-* ; do
|
for akernel in $snap_dir_boot/vmlinuz-* ; do
|
||||||
list_kernel+=("$akernel")
|
list_kernel+=("$akernel")
|
||||||
done
|
done
|
||||||
|
|
||||||
## Custom name kernel in GRUB_BTRFS_NKERNEL
|
## Custom name kernel in GRUB_BTRFS_NKERNEL
|
||||||
@@ -162,11 +162,18 @@ detect_kernel()
|
|||||||
|
|
||||||
detect_initramfs()
|
detect_initramfs()
|
||||||
{
|
{
|
||||||
for init in "${version_kernel[@]}" ; do
|
## Arch original kernel (auto-detect)
|
||||||
if [ -e "$snap_dir_boot/initramfs-$init.img" ] ; then echo "initramfs-$init.img" ; fi ;
|
for ainitramfs in $snap_dir_boot/initramfs-* ; do
|
||||||
if [ -e "$snap_dir_boot/initramfs-$init-fallback.img" ] ; then echo "initramfs-$init-fallback.img" ; fi ;
|
list_initramfs+=("$ainitramfs")
|
||||||
done
|
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
|
## List of kernels and initramfs in snapshots
|
||||||
@@ -174,7 +181,6 @@ list_kernels_initramfs()
|
|||||||
{
|
{
|
||||||
[[ ! -d $gbgmp ]] && mkdir -p $gbgmp
|
[[ ! -d $gbgmp ]] && mkdir -p $gbgmp
|
||||||
mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/
|
mount -o subvolid=0 /dev/disk/by-uuid/$root_uuid $gbgmp/
|
||||||
|
|
||||||
echo "submenu '${submenuname}' {"
|
echo "submenu '${submenuname}' {"
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for item in $(snapshot_list); do
|
for item in $(snapshot_list); do
|
||||||
@@ -188,10 +194,11 @@ list_kernels_initramfs()
|
|||||||
unset list_kernel
|
unset list_kernel
|
||||||
detect_kernel
|
detect_kernel
|
||||||
name_kernel=("${list_kernel[@]##*"/"}")
|
name_kernel=("${list_kernel[@]##*"/"}")
|
||||||
#echo "kernel = ${#name_kernel[*]}"
|
# echo "kernel = ${name_kernel[*]}"
|
||||||
version_kernel=(${name_kernel[@]#*"-"})
|
unset list_initramfs
|
||||||
#echo "version = ${version_kernel[*]}"
|
detect_initramfs
|
||||||
#echo "###" ;
|
name_initramfs=("${list_initramfs[@]##*"/"}")
|
||||||
|
# echo "initramfs = ${name_initramfs[*]}"
|
||||||
fi
|
fi
|
||||||
# Create menu entries
|
# Create menu entries
|
||||||
snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}"
|
snapshots_entry "${prefixentry}" "${snap_dir_name}" "${snap_date_time}"
|
||||||
@@ -203,5 +210,8 @@ list_kernels_initramfs()
|
|||||||
### END auto detect ###
|
### END auto detect ###
|
||||||
|
|
||||||
### Choice of method ###
|
### Choice of method ###
|
||||||
if [ ${choise_of_method} = "1" ] ; then list_kernels_initramfs ; fi
|
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 ###
|
### End choice of method ###
|
||||||
Reference in New Issue
Block a user