Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Libreboot build system
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libreboot project
Libreboot build system
Commits
da44f929
Commit
da44f929
authored
1 year ago
by
livio
Committed by
Libreboot project
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Created routines for automatic generation of boot menu items from every scanned media.
parent
05bafde3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
config/grub/config/grub.cfg
+51
-24
51 additions, 24 deletions
config/grub/config/grub.cfg
with
51 additions
and
24 deletions
config/grub/config/grub.cfg
+
51
−
24
View file @
da44f929
...
...
@@ -68,7 +68,7 @@ function list_pmedia {
done
done
done
echo
$tgt_medias
#
echo $tgt_medias
}
set
lvmnames
=
"crypt-bootvol crypt-rootvol crypt-boot crypt-root grubcrypt-bootvol grubcrypt-rootvol"
...
...
@@ -85,20 +85,42 @@ function list_lmedia {
done
done
done
echo
$tgt_medias
#
echo $tgt_medias
}
mediadetect
menuentry
"Media
detection
test"
{
cryptomount
-a
-p
assword
#list_pmedia ata
list_lmedia
lvm
# Create menuitems that boot any valid previously detected media
function
make_boot_menus
{
for
i
in
${tgt_medias}
; do
grub_create_menu
${i}
echo
-n
"."
done
echo
}
# Scan every physical media to make boot menus
function
scan_p_media_menus
{
for
i
in
ata
ahci
usb
fd
; do
echo
-n
"Scanning
${i}"
list_pmedia
${i}
make_boot_menus
done
}
# Scan every logical media to make boot menus
function
scan_l_media_menus
{
for
i
in
lvm
md
; do
echo
-n
"Scanning
${i}"
list_lmedia
${i}
make_boot_menus
done
}
menuentry
"List
all
bootable
medias"
{
mediadetect
scan_p_media_menus
scan_l_media_menus
}
# FIXME Make an automatic override for BTRFS directories instead of copypasting with a "@/" in front of every element
# Default list of GRUB possible directories. The @/... entries are for cases where the BTRFS filesystem is being used
...
...
@@ -106,25 +128,30 @@ set grub_dirs="boot grub grub2 boot/grub boot/grub2 @/boot @/grub @/grub2 @/boot
# Default list of GRUB possible config files prefixes
set
grub_conf_names
=
"'' osboot_ autoboot_ libreboot_ coreboot_"
# Creates a menuentry for GRUB. First argument is menu text without spaces then root and configfile
function
grub_menuentry
{
menuentry
${1}
${2}
${3}
{
set
root
=
"${2}"
unset
superusers
configfile
${3}
}
}
function
grub_create_menu
{
echo
"
[GRUB]
Looking
on
${1}"
set
root
=
"${1}"
# The @/... entries are for cases where the BTRFS filesystem is being used
if
[ ! -d / ]
; then # Root is invalid: maybe unknown FS or encrypted one
cryptomount
${1}
return
;
fi
for
dir
in
${grub_dirs}
; do
# In order to save time, we do not attempt anything on non existing directory.
if
[ -d / ]
; then
if
[ -d /"${dir}"/ ]
; then
for
name
in
''
${grub_conf_names}
; do
if
[ -f /"${dir}"/"${name}"grub.cfg ]
; then
menuentry
"${1}
load
GRUB"
${1}
/"${dir}"/"${name}"grub.cfg
{
set
root
=
"${2}"
unset
superusers
configfile
${3}
}
grub_menuentry
${1}:GRUB
${1}
/${dir}/${name}grub.cfg
fi
done
fi
fi
done
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment