Skip to content

Commit 2d6206c

Browse files
committed
Add efibootmgr and unify EFI boot entry handling
- Added efibootmgr to grub2-mkconfig package list - Enhanced boot entry creation for both attended and Kickstart-based installs - Updated boot label to Edge MicrovisorToolkit - Improved EFI entry cleanup logic for existing boot entries Signed-off-by: kinatli jayanth <jayanthx.kintali@intel.com>
1 parent 8b16100 commit 2d6206c

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"packages": [
3-
"grub2"
3+
"grub2",
4+
"efibootmgr"
45
],
56
"_comment": "grub2-mkconfig is packaged with the grub2 base package. Images that boot for the first time using the mkconfig flow must therefore have grub2 installed by the tools."
67
}

toolkit/tools/liveinstaller/liveinstaller.go

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,27 @@ func runBootEntryCreationCommand(installDetails installationDetails) (err error)
164164
const squashErrors = false
165165
program := "efibootmgr"
166166
cfg := installDetails.finalConfig
167+
168+
if cfg.DefaultSystemConfig.IsKickStartBoot {
169+
logger.Log.Info("Unattended installation: parsing Kickstart file to get disk info")
170+
171+
kickstartPartitionFile := "/tmp/part-include"
172+
disks, _, err := configuration.ParseKickStartPartitionScheme(kickstartPartitionFile)
173+
logger.PanicOnError(err, "Failed to parse partition schema")
174+
// Save disk config settings
175+
if len(disks) == 0 {
176+
return fmt.Errorf("Kickstart parsed disk list is empty")
177+
}
178+
cfg.Disks = disks
179+
}
167180
bootPartIdx, bootPart := cfg.GetBootPartition()
168181
bootDisk := cfg.GetDiskContainingPartition(bootPart)
169182
commandArgs := []string{
170183
"-c", // Create a new bootnum and place it in the beginning of the boot order
171184
"-d", bootDisk.TargetDisk.Value, // Specify which disk the boot file is on
172185
"-p", fmt.Sprintf("%d", bootPartIdx+1), // Specify which partition the boot file is on
173-
"-l", "'\\EFI\\BOOT\\bootx64.efi'", // Specify the path for where the boot file is located on the partition
174-
"-L", "Azure Linux", // Specify what label you would like to give this boot entry
186+
"-l", "\\EFI\\BOOT\\bootx64.efi", // Specify the path for where the boot file is located on the partition
187+
"-L", "Edge Microvisor Toolkit", // Specify what label you would like to give this boot entry
175188
"-v", // Be verbose
176189
}
177190
err = shell.ExecuteLive(squashErrors, program, commandArgs...)
@@ -180,15 +193,27 @@ func runBootEntryCreationCommand(installDetails installationDetails) (err error)
180193

181194
func removeOldAzureLinuxBootTargets() (err error) {
182195
const squashErrors = false
183-
logger.Log.Info("Removing pre-existing 'Azure Linux' boot targets from efibootmgr")
184-
program := "efibootmgr" // Default behavior when piped or called without options is to print current boot order in a human-readable format
185-
commandArgs := []string{
186-
"|", "grep", "\"Azure Linux\"", // Filter boot order for Azure Linux boot targets
187-
"|", "sed", "'s/* Azure Linux//g'", // Pruning for just the bootnum
188-
"|", "sed", "'s/Boot*//g'", // Pruning for just the bootnum
189-
"|", "xargs", "-t", "-i", "efibootmgr", "-b", "{}", "-B", // Calling efibootmgr --delete-bootnum (aka `-B`) on each pre-existing bootnum with an Azure Linux label
196+
logger.Log.Info("Removing pre-existing 'Edge Microvisor Toolkit' boot targets from efibootmgr")
197+
198+
// First, test if Edge Microvisor Toolkit entries exist
199+
testCmd := `efibootmgr | grep "Edge Microvisor Toolkit"`
200+
201+
// Actual deletion command
202+
deleteCmd := `efibootmgr | grep "Edge Microvisor Toolkit" | awk '{print $1}' | sed 's/Boot//g' | sed 's/\*//g' | xargs -t -I {} efibootmgr -b {} -B`
203+
204+
// Run test command to check for matches
205+
logger.Log.Infof("deletion test command: %s", testCmd)
206+
err = shell.ExecuteLive(squashErrors, "sh", "-c", testCmd)
207+
208+
if err != nil {
209+
// No Edge Microvisor Toolkit entries found
210+
logger.Log.Info("No 'Edge Microvisor Toolkit' boot entries found. Nothing to delete.")
211+
return nil
190212
}
191-
err = shell.ExecuteLive(squashErrors, program, commandArgs...)
213+
214+
// Edge Microvisor Toolkit entries found and hence deleting the entries
215+
logger.Log.Infof("deletion execution command: %s", deleteCmd)
216+
err = shell.ExecuteLive(squashErrors, "sh", "-c", deleteCmd)
192217
return
193218
}
194219

0 commit comments

Comments
 (0)