@@ -17,6 +17,8 @@ package d2vm
1717import (
1818 "context"
1919 "fmt"
20+ "strconv"
21+ "strings"
2022
2123 "github.com/sirupsen/logrus"
2224)
@@ -42,7 +44,7 @@ func (g grubEFI) Setup(ctx context.Context, dev, root string, cmdline string) er
4244 return err
4345 }
4446 defer clean ()
45- if err := g .install (ctx , "--target=" + g .arch + "-efi" , "--efi-directory=/boot" , "--no-nvram" , "--removable" , "--no-floppy" ); err != nil {
47+ if err := g .install (ctx , "--target=" + g .arch + "-efi" , "--efi-directory=/boot" , "--no-nvram" , "--removable" , "--no-floppy" , "--force" ); err != nil {
4648 return err
4749 }
4850 if err := g .mkconfig (ctx ); err != nil {
@@ -56,8 +58,8 @@ type grubEFIProvider struct {
5658}
5759
5860func (g grubEFIProvider ) New (c Config , r OSRelease , arch string ) (Bootloader , error ) {
59- if r . ID == ReleaseCentOS || r . ID == ReleaseRocky || r . ID == ReleaseAlmaLinux {
60- return nil , fmt . Errorf ( "grub-efi is not supported for CentOS, use grub-bios instead" )
61+ if err := checkGrubEFISupport ( r ); err != nil {
62+ return nil , err
6163 }
6264 return grubEFI {grubCommon : newGrubCommon (c , r ), arch : arch }, nil
6365}
@@ -66,6 +68,17 @@ func (g grubEFIProvider) Name() string {
6668 return "grub-efi"
6769}
6870
71+ func checkGrubEFISupport (r OSRelease ) error {
72+ if r .ID == ReleaseCentOS {
73+ return fmt .Errorf ("grub (efi) is not supported for CentOS, use grub-bios instead" )
74+ }
75+ v , _ := strconv .Atoi (strings .Split (r .VersionID , "." )[0 ])
76+ if (r .ID == ReleaseAlmaLinux || r .ID == ReleaseRocky ) && v < 9 {
77+ return fmt .Errorf ("grub (efi) is not supported for %s (%s), use 9+ releases or grub-bios instead" , r .ID , r .VersionID )
78+ }
79+ return nil
80+ }
81+
6982func init () {
7083 RegisterBootloaderProvider (grubEFIProvider {})
7184}
0 commit comments