diff --git a/cmd/installer/cmd/install.go b/cmd/installer/cmd/install.go index dc5b8259d14..0cb3ef9f971 100644 --- a/cmd/installer/cmd/install.go +++ b/cmd/installer/cmd/install.go @@ -74,6 +74,10 @@ func runInstallCmd() (err error) { log.Printf(" %s", warning) } } + + if config.Machine().Install().LegacyBIOSSupport() { + options.LegacyBIOSSupport = true + } } return install.Install(p, seq, options) diff --git a/cmd/installer/pkg/install/install.go b/cmd/installer/pkg/install/install.go index 1a3feaf81f6..999b9e1845f 100644 --- a/cmd/installer/pkg/install/install.go +++ b/cmd/installer/pkg/install/install.go @@ -26,16 +26,17 @@ import ( // Options represents the set of options available for an install. type Options struct { - ConfigSource string - Disk string - Platform string - Arch string - Board string - ExtraKernelArgs []string - Bootloader bool - Upgrade bool - Force bool - Zero bool + ConfigSource string + Disk string + Platform string + Arch string + Board string + ExtraKernelArgs []string + Bootloader bool + Upgrade bool + Force bool + Zero bool + LegacyBIOSSupport bool } // Install installs Talos. diff --git a/cmd/installer/pkg/install/manifest.go b/cmd/installer/pkg/install/manifest.go index da0b371cba8..7a03a342189 100644 --- a/cmd/installer/pkg/install/manifest.go +++ b/cmd/installer/pkg/install/manifest.go @@ -28,9 +28,10 @@ import ( // Manifest represents the instructions for preparing all block devices // for an installation. type Manifest struct { - PartitionOptions *runtime.PartitionOptions - Devices map[string]Device - Targets map[string][]*Target + PartitionOptions *runtime.PartitionOptions + Devices map[string]Device + Targets map[string][]*Target + LegacyBIOSSupport bool } // Device represents device options. @@ -52,8 +53,9 @@ func NewManifest(label string, sequence runtime.Sequence, bootPartitionFound boo } manifest = &Manifest{ - Devices: map[string]Device{}, - Targets: map[string][]*Target{}, + Devices: map[string]Device{}, + Targets: map[string][]*Target{}, + LegacyBIOSSupport: opts.LegacyBIOSSupport, } if opts.Board != constants.BoardNone { @@ -271,7 +273,9 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) log.Printf("creating new partition table on %s", device.Device) - gptOpts := []gpt.Option{} + gptOpts := []gpt.Option{ + gpt.WithMarkMBRBootable(m.LegacyBIOSSupport), + } if m.PartitionOptions != nil { gptOpts = append(gptOpts, gpt.WithPartitionEntriesStartLBA(m.PartitionOptions.PartitionsOffset)) diff --git a/go.mod b/go.mod index cbbbcee830c..cbaaaaf0bd3 100644 --- a/go.mod +++ b/go.mod @@ -66,7 +66,7 @@ require ( github.com/spf13/cobra v1.1.3 github.com/stretchr/testify v1.7.0 github.com/talos-systems/crypto v0.2.1-0.20210526123943-7776057f5086 - github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0 + github.com/talos-systems/go-blockdevice v0.2.1-0.20210526155905-30c2bc3cb62a github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3 github.com/talos-systems/go-kmsg v0.1.0 diff --git a/go.sum b/go.sum index 489ea9de66f..6e4acbd6b81 100644 --- a/go.sum +++ b/go.sum @@ -1216,6 +1216,8 @@ github.com/talos-systems/crypto v0.2.1-0.20210526123943-7776057f5086 h1:SAyrAftT github.com/talos-systems/crypto v0.2.1-0.20210526123943-7776057f5086/go.mod h1:xaNCB2/Bxaj+qrkdeodhRv5eKQVvKOGBBMj58MrIPY8= github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0 h1:EdawBvWE2v9+oiT6vFfUJB9cSTNWRPwcIamCyHEtthQ= github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0/go.mod h1:qnn/zDc09I1DA2BUDDCOSA2D0P8pIDjN8pGiRoRaQig= +github.com/talos-systems/go-blockdevice v0.2.1-0.20210526155905-30c2bc3cb62a h1:NLuIVKi5tBnRMgxk185AVGmMUzlRcggb2Abrw9uUq3E= +github.com/talos-systems/go-blockdevice v0.2.1-0.20210526155905-30c2bc3cb62a/go.mod h1:qnn/zDc09I1DA2BUDDCOSA2D0P8pIDjN8pGiRoRaQig= github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 h1:DI+BjK+fcrLBc70Fi50dZocQcaHosqsuWHrGHKp2NzE= github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0/go.mod h1:kf+rZzTEmlDiYQ6ulslvRONnKLQH8x83TowltGMhO+k= github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3 h1:beG97JtuU5oIL+ArSOKbJxbfsCfELOQ5VZu4RuSBJHU= diff --git a/pkg/machinery/config/provider.go b/pkg/machinery/config/provider.go index f19d1656452..6d8981adf29 100644 --- a/pkg/machinery/config/provider.go +++ b/pkg/machinery/config/provider.go @@ -81,6 +81,7 @@ type Install interface { Disk() (string, error) ExtraKernelArgs() []string Zero() bool + LegacyBIOSSupport() bool WithBootloader() bool } diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go index 5994b5b7dbe..4a4d7ebd90c 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_provider.go @@ -905,6 +905,11 @@ func (i *InstallConfig) Zero() bool { return i.InstallWipe } +// LegacyBIOSSupport implements the config.Provider interface. +func (i *InstallConfig) LegacyBIOSSupport() bool { + return i.InstallLegacyBIOSSupport +} + // WithBootloader implements the config.Provider interface. func (i *InstallConfig) WithBootloader() bool { return i.InstallBootloader diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go index 056bdb8e13e..9be7df2a37a 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_types.go @@ -841,6 +841,10 @@ type InstallConfig struct { // - false // - no InstallWipe bool `yaml:"wipe"` + // description: | + // Indicates if MBR partition should be marked as bootable (active). + // Should be enabled only for the systems with legacy BIOS that doesn't support GPT partitioning scheme. + InstallLegacyBIOSSupport bool `yaml:"legacyBIOSSupport,omitempty"` } // InstallDiskSizeMatcher disk size condition parser. diff --git a/pkg/machinery/config/types/v1alpha1/v1alpha1_types_doc.go b/pkg/machinery/config/types/v1alpha1/v1alpha1_types_doc.go index 166132396f5..0cc77628bdf 100644 --- a/pkg/machinery/config/types/v1alpha1/v1alpha1_types_doc.go +++ b/pkg/machinery/config/types/v1alpha1/v1alpha1_types_doc.go @@ -490,7 +490,7 @@ func init() { FieldName: "install", }, } - InstallConfigDoc.Fields = make([]encoder.Doc, 6) + InstallConfigDoc.Fields = make([]encoder.Doc, 7) InstallConfigDoc.Fields[0].Name = "disk" InstallConfigDoc.Fields[0].Type = "string" InstallConfigDoc.Fields[0].Note = "" @@ -543,6 +543,11 @@ func init() { "false", "no", } + InstallConfigDoc.Fields[6].Name = "legacyBIOSSupport" + InstallConfigDoc.Fields[6].Type = "bool" + InstallConfigDoc.Fields[6].Note = "" + InstallConfigDoc.Fields[6].Description = "Indicates if MBR partition should be marked as bootable (active).\nShould be enabled only for the systems with legacy BIOS that doesn't support GPT partitioning scheme." + InstallConfigDoc.Fields[6].Comments[encoder.LineComment] = "Indicates if MBR partition should be marked as bootable (active)." InstallDiskSizeMatcherDoc.Type = "InstallDiskSizeMatcher" InstallDiskSizeMatcherDoc.Comments[encoder.LineComment] = "InstallDiskSizeMatcher disk size condition parser." diff --git a/website/content/docs/v0.11/Reference/configuration.md b/website/content/docs/v0.11/Reference/configuration.md index 86546f3ed13..aa9cdaaf142 100644 --- a/website/content/docs/v0.11/Reference/configuration.md +++ b/website/content/docs/v0.11/Reference/configuration.md @@ -1805,6 +1805,20 @@ Valid values:
+
+ +legacyBIOSSupport bool + +
+
+ +Indicates if MBR partition should be marked as bootable (active). +Should be enabled only for the systems with legacy BIOS that doesn't support GPT partitioning scheme. + +
+ +
+