diff --git a/.drone.jsonnet b/.drone.jsonnet index c1c2c6fef..9d1d61431 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -495,6 +495,8 @@ local release = { '_out/gcp-arm64.tar.gz', '_out/initramfs-amd64.xz', '_out/initramfs-arm64.xz', + '_out/metal-amd64.tar.gz', + '_out/metal-arm64.tar.gz', '_out/openstack-amd64.tar.gz', '_out/openstack-arm64.tar.gz', '_out/talos-amd64.iso', diff --git a/Dockerfile b/Dockerfile index 88b49d5a1..1bde2d854 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ FROM ghcr.io/talos-systems/xfsprogs:${PKGS} AS pkg-xfsprogs FROM ghcr.io/talos-systems/util-linux:${PKGS} AS pkg-util-linux FROM ghcr.io/talos-systems/kmod:${PKGS} AS pkg-kmod FROM ghcr.io/talos-systems/kernel:${PKGS} AS pkg-kernel +FROM ghcr.io/talos-systems/u-boot:${PKGS} AS pkg-u-boot # Resolve package images using ${EXTRAS} to be used later in COPY --from=. @@ -470,6 +471,7 @@ COPY --from=unicode-pf2 /usr/share/grub/unicode.pf2 /usr/share/grub/unicode.pf2 ARG TARGETARCH COPY --from=kernel /vmlinuz-${TARGETARCH} /usr/install/vmlinuz COPY --from=initramfs /initramfs-${TARGETARCH}.xz /usr/install/initramfs.xz +COPY --from=pkg-u-boot / /usr/install/u-boot COPY --from=installer-build /installer /bin/installer RUN ln -s /bin/installer /bin/talosctl ARG TAG diff --git a/Makefile b/Makefile index 656c95b38..330fa70c9 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ REGISTRY_AND_USERNAME := $(REGISTRY)/$(USERNAME) DOCKER_LOGIN_ENABLED ?= true ARTIFACTS := _out -TOOLS ?= ghcr.io/talos-systems/tools:v0.3.0-10-g83dc352 -PKGS ?= v0.3.0-27-g7a64952 +TOOLS ?= ghcr.io/talos-systems/tools:v0.3.0-11-g84c834e +PKGS ?= v0.3.0-35-g6b7be81 EXTRAS ?= v0.1.0-5-gcc2df81 GO_VERSION ?= 1.15 GOFUMPT_VERSION ?= abc0db2c416aca0f60ea33c23c76665f6e7ba0b6 @@ -173,7 +173,7 @@ talosctl: $(TALOSCTL_DEFAULT_TARGET) ## Builds the talosctl binary for the local image-%: ## Builds the specified image. Valid options are aws, azure, digital-ocean, gcp, and vmware (e.g. image-aws) @docker run --rm -v /dev:/dev --privileged $(REGISTRY)/$(USERNAME)/installer:$(TAG) image --platform $* --tar-to-stdout | tar xz -C $(ARTIFACTS) -images: image-aws image-azure image-digital-ocean image-gcp image-openstack image-vmware ## Builds all known images (AWS, Azure, Digital Ocean, GCP, Openstack, and VMware). +images: image-aws image-azure image-digital-ocean image-gcp image-metal image-openstack image-vmware ## Builds all known images (AWS, Azure, Digital Ocean, GCP, Metal, Openstack, and VMware). .PHONY: iso iso: ## Builds the ISO and outputs it to the artifact directory. diff --git a/cmd/installer/cmd/image.go b/cmd/installer/cmd/image.go index e2a024fa9..37f58f25d 100644 --- a/cmd/installer/cmd/image.go +++ b/cmd/installer/cmd/image.go @@ -86,7 +86,7 @@ func runImageCmd() (err error) { if options.ConfigSource == "" { switch p.Name() { case "aws", "azure", "digital-ocean", "gcp": - options.ConfigSource = "none" + options.ConfigSource = constants.ConfigNone case "vmware": options.ConfigSource = constants.ConfigGuestInfo default: @@ -148,6 +148,16 @@ func finalize(platform runtime.Platform, img string) (err error) { if err = ova.CreateOVAFromRAW(name, img, outputArg); err != nil { return err } + case "metal": + name := fmt.Sprintf("metal-%s.tar.gz", stdruntime.GOARCH) + + if options.Board != "" { + name = fmt.Sprintf("metal-%s-%s.tar.gz", options.Board, stdruntime.GOARCH) + } + + if err = tar(name, file, dir); err != nil { + return err + } } return nil diff --git a/cmd/installer/cmd/root.go b/cmd/installer/cmd/root.go index 3e9ae1680..900733ab3 100644 --- a/cmd/installer/cmd/root.go +++ b/cmd/installer/cmd/root.go @@ -36,6 +36,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&options.ConfigSource, "config", "", "The value of "+constants.KernelParamConfig) rootCmd.PersistentFlags().StringVar(&options.Disk, "disk", "", "The path to the disk to install to") rootCmd.PersistentFlags().StringVar(&options.Platform, "platform", "", "The value of "+constants.KernelParamPlatform) + rootCmd.PersistentFlags().StringVar(&options.Board, "board", constants.BoardNone, "The value of "+constants.KernelParamBoard) rootCmd.PersistentFlags().StringArrayVar(&options.ExtraKernelArgs, "extra-kernel-arg", []string{}, "Extra argument to pass to the kernel") rootCmd.PersistentFlags().BoolVar(&options.Bootloader, "bootloader", true, "Install a booloader to the specified disk") rootCmd.PersistentFlags().BoolVar(&options.Upgrade, "upgrade", false, "Indicates that the install is being performed by an upgrade") diff --git a/cmd/installer/pkg/install/install.go b/cmd/installer/pkg/install/install.go index a2efc1e82..e83bdf94c 100644 --- a/cmd/installer/pkg/install/install.go +++ b/cmd/installer/pkg/install/install.go @@ -6,7 +6,9 @@ package install import ( "fmt" + "io/ioutil" "log" + "os" "path/filepath" "github.com/talos-systems/go-blockdevice/blockdevice/probe" @@ -14,6 +16,7 @@ import ( "golang.org/x/sys/unix" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" + "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/bootloader" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub" "github.com/talos-systems/talos/internal/pkg/mount" @@ -26,6 +29,7 @@ type Options struct { ConfigSource string Disk string Platform string + Board string ExtraKernelArgs []string Bootloader bool Upgrade bool @@ -37,7 +41,10 @@ type Options struct { func Install(p runtime.Platform, seq runtime.Sequence, opts *Options) (err error) { cmdline := procfs.NewCmdline("") cmdline.Append(constants.KernelParamPlatform, p.Name()) - cmdline.Append(constants.KernelParamConfig, opts.ConfigSource) + + if opts.ConfigSource != "" { + cmdline.Append(constants.KernelParamConfig, opts.ConfigSource) + } if err = cmdline.AppendAll(p.KernelArgs().Strings()); err != nil { return err @@ -152,6 +159,17 @@ func (i *Installer) probeBootPartition() error { // // nolint: gocyclo func (i *Installer) Install(seq runtime.Sequence) (err error) { + if i.options.Board != constants.BoardNone { + var b runtime.Board + + b, err = board.NewBoard(i.options.Board) + if err != nil { + return err + } + + i.cmdline.Append(constants.KernelParamBoard, b.Name()) + } + if err = i.manifest.Execute(); err != nil { return err } @@ -220,6 +238,54 @@ func (i *Installer) Install(seq runtime.Sequence) (err error) { return err } + if i.options.Board != constants.BoardNone { + var b runtime.Board + + b, err = board.NewBoard(i.options.Board) + if err != nil { + return err + } + + log.Printf("installing U-Boot for %q board", b.Name()) + + var f *os.File + + if f, err = os.OpenFile(i.options.Disk, os.O_RDWR|unix.O_CLOEXEC, 0o666); err != nil { + return err + } + + // nolint: errcheck + defer f.Close() + + bin, off := b.UBoot() + + var uboot []byte + + uboot, err = ioutil.ReadFile(bin) + if err != nil { + return err + } + + log.Printf("writing %s to %s at offset %d", bin, i.options.Disk, off) + + var n int + + n, err = f.WriteAt(uboot, off) + if err != nil { + return err + } + + log.Printf("wrote %d bytes", n) + + // NB: In the case that the block device is a loopback device, we sync here + // to esure that the file is written before the loopback device is + // unmounted. + err = f.Sync() + if err != nil { + return err + } + } + if seq == runtime.SequenceUpgrade { var meta *bootloader.Meta diff --git a/cmd/installer/pkg/install/manifest.go b/cmd/installer/pkg/install/manifest.go index dd147653a..87a9a5cc7 100644 --- a/cmd/installer/pkg/install/manifest.go +++ b/cmd/installer/pkg/install/manifest.go @@ -9,6 +9,7 @@ import ( "bytes" "compress/gzip" "context" + "errors" "fmt" "io" "log" @@ -18,13 +19,13 @@ import ( "time" "github.com/talos-systems/go-blockdevice/blockdevice" - "github.com/talos-systems/go-blockdevice/blockdevice/table" - "github.com/talos-systems/go-blockdevice/blockdevice/table/gpt/partition" + "github.com/talos-systems/go-blockdevice/blockdevice/partition/gpt" "github.com/talos-systems/go-blockdevice/blockdevice/util" "github.com/talos-systems/go-retry/retry" "golang.org/x/sys/unix" "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" + "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board" "github.com/talos-systems/talos/internal/pkg/mount" "github.com/talos-systems/talos/pkg/archiver" "github.com/talos-systems/talos/pkg/machinery/constants" @@ -34,8 +35,9 @@ import ( // Manifest represents the instructions for preparing all block devices // for an installation. type Manifest struct { - Devices map[string]Device - Targets map[string][]*Target + PartitionOptions *runtime.PartitionOptions + Devices map[string]Device + Targets map[string][]*Target } // Device represents device options. @@ -138,6 +140,17 @@ func NewManifest(label string, sequence runtime.Sequence, bootPartitionFound boo Targets: map[string][]*Target{}, } + if opts.Board != constants.BoardNone { + var b runtime.Board + + b, err = board.NewBoard(opts.Board) + if err != nil { + return nil, err + } + + manifest.PartitionOptions = b.PartitionOptions() + } + // TODO: legacy, to support old Talos initramfs, assume force if boot partition not found if !bootPartitionFound { opts.Force = true @@ -345,14 +358,48 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) var bd *blockdevice.BlockDevice - if bd, err = blockdevice.Open(device.Device, blockdevice.WithNewGPT(device.ResetPartitionTable)); err != nil { + if bd, err = blockdevice.Open(device.Device); err != nil { return err } // nolint: errcheck defer bd.Close() - if device.ResetPartitionTable { + var pt *gpt.GPT + + created := false + + pt, err = bd.PartitionTable() + if err != nil { + if !errors.Is(err, blockdevice.ErrMissingPartitionTable) { + return err + } + + log.Printf("creating new partition table on %s", device.Device) + + gptOpts := []gpt.Option{} + + if m.PartitionOptions != nil { + gptOpts = append(gptOpts, gpt.WithPartitionEntriesStartLBA(m.PartitionOptions.PartitionsOffset)) + } + + pt, err = gpt.New(bd.Device(), gptOpts...) + if err != nil { + return err + } + + if err = pt.Write(); err != nil { + return err + } + + if bd, err = blockdevice.Open(device.Device); err != nil { + return err + } + + created = true + } + + if !created && device.ResetPartitionTable { log.Printf("resetting partition table on %s", device.Device) // TODO: how should it work with zero option above? @@ -365,13 +412,6 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) } } else { // clean up partitions which are going to be recreated - var pt table.PartitionTable - - pt, err = bd.PartitionTable() - if err != nil { - return err - } - keepPartitions := map[string]struct{}{} for _, target := range targets { @@ -387,8 +427,8 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) missingPartitions[label] = struct{}{} } - for _, part := range pt.Partitions() { - delete(missingPartitions, part.Label()) + for _, part := range pt.Partitions().Items() { + delete(missingPartitions, part.Name) } if len(missingPartitions) > 0 { @@ -396,9 +436,9 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) } // delete all partitions which are not skipped - for _, part := range pt.Partitions() { - if _, ok := keepPartitions[part.Label()]; !ok { - log.Printf("deleting partition %s", part.Label()) + for _, part := range pt.Partitions().Items() { + if _, ok := keepPartitions[part.Name]; !ok { + log.Printf("deleting partition %s", part.Name) if err = pt.Delete(part); err != nil { return err @@ -415,8 +455,6 @@ func (m *Manifest) executeOnDevice(device Device, targets []*Target) (err error) } } - var pt table.PartitionTable - pt, err = bd.PartitionTable() if err != nil { return err @@ -507,7 +545,7 @@ func (m *Manifest) preserveContents(device Device, targets []*Target) (err error } var ( - sourcePart table.Partition + sourcePart *gpt.Partition fileSystemType FileSystemType fnmatchFilters []string ) @@ -521,8 +559,8 @@ func (m *Manifest) preserveContents(device Device, targets []*Target) (err error for _, source := range sources { // find matching existing partition table entry - for _, part := range pt.Partitions() { - if part.Label() == source.Label { + for _, part := range pt.Partitions().Items() { + if part.Name == source.Label { sourcePart = part fileSystemType = source.FileSystemType fnmatchFilters = source.FnmatchFilters @@ -600,11 +638,11 @@ func (m *Manifest) zeroDevice(device Device) (err error) { // Partition creates a new partition on the specified device. // nolint: dupl, gocyclo -func (t *Target) Partition(pt table.PartitionTable, pos int, bd *blockdevice.BlockDevice) (err error) { +func (t *Target) Partition(pt *gpt.GPT, pos int, bd *blockdevice.BlockDevice) (err error) { if t.Skip { - for _, part := range pt.Partitions() { - if part.Label() == t.Label { - t.PartitionName, err = util.PartPath(t.Device, int(part.No())) + for _, part := range pt.Partitions().Items() { + if part.Name == t.Label { + t.PartitionName, err = util.PartPath(t.Device, int(part.Number)) if err != nil { return err } @@ -620,17 +658,17 @@ func (t *Target) Partition(pt table.PartitionTable, pos int, bd *blockdevice.Blo log.Printf("partitioning %s - %s\n", t.Device, t.Label) - opts := []interface{}{ - partition.WithPartitionType(t.PartitionType), - partition.WithPartitionName(t.Label), + opts := []gpt.PartitionOption{ + gpt.WithPartitionType(t.PartitionType), + gpt.WithPartitionName(t.Label), } if t.Size == 0 { - opts = append(opts, partition.WithMaximumSize(true)) + opts = append(opts, gpt.WithMaximumSize(true)) } if t.LegacyBIOSBootable { - opts = append(opts, partition.WithLegacyBIOSBootableAttribute(true)) + opts = append(opts, gpt.WithLegacyBIOSBootableAttribute(true)) } part, err := pt.InsertAt(pos, t.Size, opts...) @@ -638,7 +676,7 @@ func (t *Target) Partition(pt table.PartitionTable, pos int, bd *blockdevice.Blo return err } - t.PartitionName, err = util.PartPath(t.Device, int(part.No())) + t.PartitionName, err = util.PartPath(t.Device, int(part.Number)) if err != nil { return err } @@ -755,8 +793,8 @@ func withTemporaryMounted(partPath string, flags uintptr, fileSystemType FileSys } // SaveContents saves contents of partition to the target (in-memory). -func (t *Target) SaveContents(device Device, source table.Partition, fileSystemType FileSystemType, fnmatchFilters []string) error { - partPath, err := util.PartPath(device.Device, int(source.No())) +func (t *Target) SaveContents(device Device, source *gpt.Partition, fileSystemType FileSystemType, fnmatchFilters []string) error { + partPath, err := util.PartPath(device.Device, int(source.Number)) if err != nil { return err } diff --git a/cmd/installer/pkg/install/manifest_test.go b/cmd/installer/pkg/install/manifest_test.go index a4d178f32..302e4d75e 100644 --- a/cmd/installer/pkg/install/manifest_test.go +++ b/cmd/installer/pkg/install/manifest_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/talos-systems/go-blockdevice/blockdevice" "github.com/talos-systems/go-blockdevice/blockdevice/loopback" - "github.com/talos-systems/go-blockdevice/blockdevice/table/gpt/partition" + "github.com/talos-systems/go-blockdevice/blockdevice/partition/gpt" "github.com/talos-systems/go-blockdevice/blockdevice/util" "github.com/talos-systems/talos/cmd/installer/pkg/install" @@ -111,34 +111,34 @@ func (suite *manifestSuite) verifyBlockdevice(manifest *install.Manifest, curren suite.Assert().Len(table.Partitions(), 6) - part := table.Partitions()[0] - suite.Assert().Equal(install.EFISystemPartition, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.EFIPartitionLabel, part.Label()) - suite.Assert().EqualValues(0, part.(*partition.Partition).Flags) + part := table.Partitions().Items()[0] + suite.Assert().Equal(install.EFISystemPartition, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.EFIPartitionLabel, part.Name) + suite.Assert().EqualValues(0, part.Attributes) suite.Assert().EqualValues(install.EFISize/lbaSize, part.Length()) - part = table.Partitions()[1] - suite.Assert().Equal(install.BIOSBootPartition, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.BIOSGrubPartitionLabel, part.Label()) - suite.Assert().EqualValues(4, part.(*partition.Partition).Flags) + part = table.Partitions().Items()[1] + suite.Assert().Equal(install.BIOSBootPartition, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.BIOSGrubPartitionLabel, part.Name) + suite.Assert().EqualValues(4, part.Attributes) suite.Assert().EqualValues(install.BIOSGrubSize/lbaSize, part.Length()) - part = table.Partitions()[2] - suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.BootPartitionLabel, part.Label()) - suite.Assert().EqualValues(0, part.(*partition.Partition).Flags) + part = table.Partitions().Items()[2] + suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.BootPartitionLabel, part.Name) + suite.Assert().EqualValues(0, part.Attributes) suite.Assert().EqualValues(install.BootSize/lbaSize, part.Length()) - part = table.Partitions()[3] - suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.MetaPartitionLabel, part.Label()) - suite.Assert().EqualValues(0, part.(*partition.Partition).Flags) + part = table.Partitions().Items()[3] + suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.MetaPartitionLabel, part.Name) + suite.Assert().EqualValues(0, part.Attributes) suite.Assert().EqualValues(install.MetaSize/lbaSize, part.Length()) - part = table.Partitions()[4] - suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.StatePartitionLabel, part.Label()) - suite.Assert().EqualValues(0, part.(*partition.Partition).Flags) + part = table.Partitions().Items()[4] + suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.StatePartitionLabel, part.Name) + suite.Assert().EqualValues(0, part.Attributes) if !upgradeFromLegacy { suite.Assert().EqualValues(install.StateSize/lbaSize, part.Length()) @@ -146,10 +146,10 @@ func (suite *manifestSuite) verifyBlockdevice(manifest *install.Manifest, curren suite.Assert().EqualValues((diskSize-legacyEphemeralSize-install.EFISize-install.BIOSGrubSize-install.BootSize-install.MetaSize)/lbaSize-gptReserved, part.Length()) } - part = table.Partitions()[5] - suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.(*partition.Partition).Type.String())) - suite.Assert().Equal(constants.EphemeralPartitionLabel, part.Label()) - suite.Assert().EqualValues(0, part.(*partition.Partition).Flags) + part = table.Partitions().Items()[5] + suite.Assert().Equal(install.LinuxFilesystemData, strings.ToUpper(part.Type.String())) + suite.Assert().Equal(constants.EphemeralPartitionLabel, part.Name) + suite.Assert().EqualValues(0, part.Attributes) if !upgradeFromLegacy { suite.Assert().EqualValues((diskSize-install.EFISize-install.BIOSGrubSize-install.BootSize-install.MetaSize-install.StateSize)/lbaSize-gptReserved, part.Length()) @@ -189,7 +189,7 @@ func (suite *manifestSuite) verifyBlockdevice(manifest *install.Manifest, curren suite.Assert().NoError(mount.Unmount(mountpoints)) }() - metaPath := fmt.Sprintf("%sp%d", suite.loopbackDevice.Name(), table.Partitions()[3].No()) + metaPath := fmt.Sprintf("%sp%d", suite.loopbackDevice.Name(), table.Partitions().Items()[3].Number) if verifyConfigPersistence { suite.Assert().FileExists(filepath.Join(tempDir, "system", "state", "config.yaml")) @@ -383,7 +383,12 @@ func (suite *manifestSuite) TestTargetInstall() { } func (suite *manifestSuite) createTalosLegacyLayout() { - bd, err := blockdevice.Open(suite.loopbackDevice.Name(), blockdevice.WithNewGPT(true)) + bd, err := blockdevice.Open(suite.loopbackDevice.Name()) + suite.Require().NoError(err) + + _, err = gpt.New(bd.Device()) + suite.Require().NoError(err) + suite.Require().NoError(err) defer bd.Close() //nolint: errcheck @@ -393,16 +398,16 @@ func (suite *manifestSuite) createTalosLegacyLayout() { suite.Require().NoError(err) partBoot, err := table.Add(512*install.MiB, - partition.WithLegacyBIOSBootableAttribute(true), - partition.WithPartitionName(constants.LegacyBootPartitionLabel), - partition.WithPartitionType("28732AC1-1FF8-D211-BA4B-00A0C93EC93B"), + gpt.WithLegacyBIOSBootableAttribute(true), + gpt.WithPartitionName(constants.LegacyBootPartitionLabel), + gpt.WithPartitionType("28732AC1-1FF8-D211-BA4B-00A0C93EC93B"), ) suite.Require().NoError(err) partEphemeral, err := table.Add(0, - partition.WithPartitionName(constants.EphemeralPartitionLabel), - partition.WithPartitionType("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), - partition.WithMaximumSize(true), + gpt.WithPartitionName(constants.EphemeralPartitionLabel), + gpt.WithPartitionType("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), + gpt.WithMaximumSize(true), ) suite.Require().NoError(err) @@ -411,12 +416,12 @@ func (suite *manifestSuite) createTalosLegacyLayout() { suite.Require().NoError(bd.Close()) // format partitions - partBootPath, err := util.PartPath(suite.loopbackDevice.Name(), int(partBoot.No())) + partBootPath, err := util.PartPath(suite.loopbackDevice.Name(), int(partBoot.Number)) suite.Require().NoError(err) suite.Require().NoError(makefs.VFAT(partBootPath)) - partEphemeralPath, err := util.PartPath(suite.loopbackDevice.Name(), int(partEphemeral.No())) + partEphemeralPath, err := util.PartPath(suite.loopbackDevice.Name(), int(partEphemeral.Number)) suite.Require().NoError(err) suite.Require().NoError(makefs.XFS(partEphemeralPath, makefs.WithLabel(constants.EphemeralPartitionLabel))) diff --git a/cmd/installer/pkg/raw.go b/cmd/installer/pkg/raw.go index 9705a83cf..8293ca671 100644 --- a/cmd/installer/pkg/raw.go +++ b/cmd/installer/pkg/raw.go @@ -12,7 +12,7 @@ import ( const ( // RAWDiskSize is the minimum size disk we can create. - RAWDiskSize = 544 + RAWDiskSize = 546 ) // CreateRawDisk creates a raw disk by invoking the `dd` command. diff --git a/go.mod b/go.mod index 86703a037..b74aaf4cc 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,7 @@ require ( github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 github.com/talos-systems/bootkube-plugin v0.0.0-20201123195241-c59f3fa21116 github.com/talos-systems/crypto v0.2.1-0.20201112141136-12a489768a6b - github.com/talos-systems/go-blockdevice v0.1.1-0.20201120123651-2a1baadffdf8 + github.com/talos-systems/go-blockdevice v0.1.1-0.20201126002059-98754ec2bb20 github.com/talos-systems/go-loadbalancer v0.1.0 github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 github.com/talos-systems/go-retry v0.1.1-0.20201113203059-8c63d290a688 diff --git a/go.sum b/go.sum index 6f6c4ab76..d94e3fb5d 100644 --- a/go.sum +++ b/go.sum @@ -812,8 +812,6 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smira/bootkube-plugin v0.0.0-20201123172154-4071e320ca24 h1:bGtMDnyhJMMAPYzjH0W/U7FPrEgmnbnF2DxpXGDsSEE= -github.com/smira/bootkube-plugin v0.0.0-20201123172154-4071e320ca24/go.mod h1:AbdJAgHK5rJNDPUN3msPTfQJSR9b4DKb5xNN07uG8/Y= github.com/smira/go-xz v0.0.0-20150414201226-0c531f070014 h1:tne8XW3soRDJn4DIiqBc4jw+DPashtFMTSC9G0pC3ug= github.com/smira/go-xz v0.0.0-20150414201226-0c531f070014/go.mod h1:smSuTvETRIkX95VAIWBdKoGJuUxif7NT7FgbkpVqOiA= github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= @@ -865,14 +863,13 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 h1:b6uOv7YOFK0TYG7HtkIgExQo+2RdLuwRft63jn2HWj8= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/talos-systems/bootkube-plugin v0.0.0-20200915135634-229d57e818f3/go.mod h1:AbdJAgHK5rJNDPUN3msPTfQJSR9b4DKb5xNN07uG8/Y= github.com/talos-systems/bootkube-plugin v0.0.0-20201123195241-c59f3fa21116 h1:ly3meWKF9LIVOv0BLI3y74jJAKluivEDymVVXTzAwIA= github.com/talos-systems/bootkube-plugin v0.0.0-20201123195241-c59f3fa21116/go.mod h1:AbdJAgHK5rJNDPUN3msPTfQJSR9b4DKb5xNN07uG8/Y= github.com/talos-systems/crypto v0.2.0/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= github.com/talos-systems/crypto v0.2.1-0.20201112141136-12a489768a6b h1:EctcXxyT5hTXnrUbdKvN8oxZLxc8HOJ9E8paAkv3yRg= github.com/talos-systems/crypto v0.2.1-0.20201112141136-12a489768a6b/go.mod h1:KwqG+jANKU1FNQIapmioHQ5fkovY1DJkAqMenjYBGh0= -github.com/talos-systems/go-blockdevice v0.1.1-0.20201120123651-2a1baadffdf8 h1:D4NLy7uXLIWvhFaOAf1Olml5U76sNmaY03dNt2pHnOg= -github.com/talos-systems/go-blockdevice v0.1.1-0.20201120123651-2a1baadffdf8/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo= +github.com/talos-systems/go-blockdevice v0.1.1-0.20201126002059-98754ec2bb20 h1:4RQ6fsV8rZ684Up6fep2hu/J/I2i2yQeb7MX+unrmso= +github.com/talos-systems/go-blockdevice v0.1.1-0.20201126002059-98754ec2bb20/go.mod h1:efEE9wjtgxiovqsZAV39xlOd/AOI/0sLuZqb5jEgeqo= github.com/talos-systems/go-loadbalancer v0.1.0 h1:MQFONvSjoleU8RrKq1O1Z8CyTCJGd4SLqdAHDlR6o9s= github.com/talos-systems/go-loadbalancer v0.1.0/go.mod h1:D5Qjfz+29WVjONWECZvOkmaLsBb3f5YeWME0u/5HmIc= github.com/talos-systems/go-procfs v0.0.0-20200219015357-57c7311fdd45 h1:FND/LgzFHTBdJBOeZVzdO6B47kxQZvSIzb9AMIXYotg= @@ -925,7 +922,6 @@ github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yuin/goldmark v1.2.1 h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= @@ -987,12 +983,10 @@ golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgn golang.org/x/exp v0.0.0-20191024150812-c286b889502e/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299 h1:zQpM52jfKHG6II1ISZY1ZcpygvuSFZpLwfluuF89XOg= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 h1:FR+oGxGfbQu1d+jglI3rCkjAjUnhRSZcUxr+DqlDLNo= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1004,7 +998,6 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= @@ -1058,7 +1051,6 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -1134,14 +1126,10 @@ golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE= golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f h1:6Sc1XOXTulBN6imkqo6XoAXDEzoQ4/ro6xy7Vn8+rOM= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 h1:bNEHhJCnrwMKNMmOx3yAynp5vs5/gRy+XWFtZFu7NBM= golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd h1:5CtCZbICpIOFdgO940moixOPjc0178IU44m4EjOO5IY= @@ -1151,7 +1139,6 @@ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fq golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -1214,7 +1201,6 @@ golang.org/x/tools v0.0.0-20201019175715-b894a3290fff h1:HiwHyqQ9ttqCHuTa++R4wNx golang.org/x/tools v0.0.0-20201019175715-b894a3290fff/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1225,7 +1211,6 @@ google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEn google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0 h1:yzlyyDW/J0w8yNFJIhiAJy4kq74S+1DOLdawELNxFMA= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= @@ -1261,7 +1246,6 @@ google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a h1:pOwg4OoaRYScjmR4LlLgdtnyoHYTSAVhhqe5uPdpII8= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1276,7 +1260,6 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.0 h1:2pJjwYOdkZ9HlN4sWRYBg9ttH5bCOlsueaM+b/oYjwo= google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= @@ -1337,7 +1320,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= diff --git a/internal/app/machined/internal/install/install.go b/internal/app/machined/internal/install/install.go index 1e17f4ede..58224efc1 100644 --- a/internal/app/machined/internal/install/install.go +++ b/internal/app/machined/internal/install/install.go @@ -66,10 +66,14 @@ func RunInstallerContainer(disk, platform, ref string, reg config.Registries, op // TODO(andrewrynhard): To handle cases when the newer version changes the // platform name, this should be determined in the installer container. - var config *string - if config = procfs.ProcCmdline().Get(constants.KernelParamConfig).First(); config == nil { - c := "none" - config = &c + config := constants.ConfigNone + if c := procfs.ProcCmdline().Get(constants.KernelParamConfig).First(); c != nil { + config = *c + } + + board := constants.BoardNone + if c := procfs.ProcCmdline().Get(constants.KernelParamBoard).First(); c != nil { + board = *c } upgrade := strconv.FormatBool(options.Upgrade) @@ -81,7 +85,8 @@ func RunInstallerContainer(disk, platform, ref string, reg config.Registries, op "install", "--disk=" + disk, "--platform=" + platform, - "--config=" + *config, + "--board=" + board, + "--config=" + config, "--upgrade=" + upgrade, "--force=" + force, "--zero=" + zero, diff --git a/internal/app/machined/pkg/runtime/board.go b/internal/app/machined/pkg/runtime/board.go new file mode 100644 index 000000000..90508302a --- /dev/null +++ b/internal/app/machined/pkg/runtime/board.go @@ -0,0 +1,18 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package runtime + +// PartitionOptions are the board specific options for customizing the +// partition table. +type PartitionOptions struct { + PartitionsOffset uint64 +} + +// Board defines the requirements for a SBC. +type Board interface { + Name() string + UBoot() (string, int64) + PartitionOptions() *PartitionOptions +} diff --git a/internal/app/machined/pkg/runtime/v1alpha1/board/board.go b/internal/app/machined/pkg/runtime/v1alpha1/board/board.go new file mode 100644 index 000000000..a257ef64d --- /dev/null +++ b/internal/app/machined/pkg/runtime/v1alpha1/board/board.go @@ -0,0 +1,54 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package board + +import ( + "errors" + "fmt" + "os" + + "github.com/talos-systems/go-procfs/procfs" + + "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" + libretechallh3cch5 "github.com/talos-systems/talos/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5" + "github.com/talos-systems/talos/pkg/machinery/constants" +) + +// CurrentBoard is a helper func for discovering the current board. +// +// nolint: gocyclo +func CurrentBoard() (b runtime.Board, err error) { + var board string + + if p := procfs.ProcCmdline().Get(constants.KernelParamBoard).First(); p != nil { + board = *p + } + + if p, ok := os.LookupEnv("BOARD"); ok { + board = p + } + + if board == "" { + return nil, errors.New("failed to determine board") + } + + return newBoard(board) +} + +// NewBoard initializes and returns a runtime.Board. +func NewBoard(board string) (b runtime.Board, err error) { + return newBoard(board) +} + +func newBoard(board string) (b runtime.Board, err error) { + switch board { + case constants.BoardLibretechAllH3CCH5: + b = &libretechallh3cch5.LibretechAllH3CCH5{} + default: + return nil, fmt.Errorf("unsupported board: %q", board) + } + + return b, nil +} diff --git a/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5/libretech_all_h3_cc_h5.go b/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5/libretech_all_h3_cc_h5.go new file mode 100644 index 000000000..7bfcbdfd4 --- /dev/null +++ b/internal/app/machined/pkg/runtime/v1alpha1/board/libretech_all_h3_cc_h5/libretech_all_h3_cc_h5.go @@ -0,0 +1,32 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package libretechallh3cch5 + +import ( + "fmt" + + "github.com/talos-systems/talos/internal/app/machined/pkg/runtime" + "github.com/talos-systems/talos/pkg/machinery/constants" +) + +// LibretechAllH3CCH5 represents the Libre Computer ALL-H3-CC (Tritium). +// +// Reference: https://libre.computer/products/boards/all-h3-cc/ +type LibretechAllH3CCH5 struct{} + +// Name implenents the runtime.Board. +func (l *LibretechAllH3CCH5) Name() string { + return constants.BoardLibretechAllH3CCH5 +} + +// UBoot implenents the runtime.Board. +func (l *LibretechAllH3CCH5) UBoot() (string, int64) { + return fmt.Sprintf("/usr/install/u-boot/%s/u-boot-sunxi-with-spl.bin", constants.BoardLibretechAllH3CCH5), 1024 * 8 +} + +// PartitionOptions implenents the runtime.Board. +func (l *LibretechAllH3CCH5) PartitionOptions() *runtime.PartitionOptions { + return &runtime.PartitionOptions{PartitionsOffset: 2048} +} diff --git a/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/grub.go b/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/grub.go index 9ca9ef2c8..5cd2ad7fd 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/grub.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/grub.go @@ -53,8 +53,8 @@ terminal_output console {{ range $label := .Labels -}} menuentry "{{ $label.Root }}" { - set gfxmode=auto - set gfxpayload=text + set gfxmode=auto + set gfxpayload=text linux {{ $label.Kernel }} {{ $label.Append }} initrd {{ $label.Initrd }} } diff --git a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go index fbe4968b6..ebc71c578 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go @@ -25,7 +25,7 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/talos-systems/go-blockdevice/blockdevice" - "github.com/talos-systems/go-blockdevice/blockdevice/table" + "github.com/talos-systems/go-blockdevice/blockdevice/partition/gpt" "github.com/talos-systems/go-blockdevice/blockdevice/util" "github.com/talos-systems/go-procfs/procfs" "github.com/talos-systems/go-retry/retry" @@ -815,7 +815,7 @@ func partitionAndFormatDisks(logger *log.Logger, r runtime.Runtime) (err error) // nolint: errcheck defer bd.Close() - var pt table.PartitionTable + var pt *gpt.GPT pt, err = bd.PartitionTable() if err != nil { @@ -830,7 +830,7 @@ func partitionAndFormatDisks(logger *log.Logger, r runtime.Runtime) (err error) // - a partition table does not exist if pt != nil { - if len(pt.Partitions()) > 0 { + if len(pt.Partitions().Items()) > 0 { logger.Printf(("skipping setup of %q, found existing partitions"), disk.Device()) continue diff --git a/internal/pkg/mount/mount.go b/internal/pkg/mount/mount.go index 68291ae00..551b06568 100644 --- a/internal/pkg/mount/mount.go +++ b/internal/pkg/mount/mount.go @@ -329,8 +329,8 @@ func (p *Point) ResizePartition() (resized bool, err error) { return false, err } - for _, partition := range pt.Partitions() { - if partition.Label() == constants.EphemeralPartitionLabel { + for _, partition := range pt.Partitions().Items() { + if partition.Name == constants.EphemeralPartitionLabel { resized, err := pt.Resize(partition) if err != nil { return false, err diff --git a/pkg/machinery/constants/constants.go b/pkg/machinery/constants/constants.go index adf81e265..4ecc1756a 100644 --- a/pkg/machinery/constants/constants.go +++ b/pkg/machinery/constants/constants.go @@ -20,10 +20,23 @@ const ( // to the config. KernelParamConfig = "talos.config" + // ConfigNone indicates no config is required. + ConfigNone = "none" + // KernelParamPlatform is the kernel parameter name for specifying the // platform. KernelParamPlatform = "talos.platform" + // KernelParamBoard is the kernel parameter name for specifying the + // SBC. + KernelParamBoard = "talos.board" + + // BoardNone indicates that the install is not for a specific board. + BoardNone = "none" + + // BoardLibretechAllH3CCH5 is the name of the Libre Computer board ALL-H3-CC. + BoardLibretechAllH3CCH5 = "libretech_all_h3_cc_h5" + // KernelParamHostname is the kernel parameter name for specifying the // hostname. KernelParamHostname = "talos.hostname" diff --git a/pkg/provision/providers/firecracker/bootloader.go b/pkg/provision/providers/firecracker/bootloader.go index 76e7c2239..ef601a2d7 100644 --- a/pkg/provision/providers/firecracker/bootloader.go +++ b/pkg/provision/providers/firecracker/bootloader.go @@ -16,8 +16,7 @@ import ( "regexp" "github.com/talos-systems/go-blockdevice/blockdevice/filesystem/vfat" - "github.com/talos-systems/go-blockdevice/blockdevice/table" - "github.com/talos-systems/go-blockdevice/blockdevice/table/gpt" + "github.com/talos-systems/go-blockdevice/blockdevice/partition/gpt" "github.com/talos-systems/talos/pkg/machinery/constants" "github.com/talos-systems/talos/pkg/provision/internal/vmlinuz" @@ -114,7 +113,7 @@ func (b *BootLoader) Close() error { } func (b *BootLoader) findBootPartition() error { - diskTable, err := gpt.NewGPT("vda", b.diskF) + diskTable, err := gpt.Open(b.diskF) if err != nil { return fmt.Errorf("error creating GPT object: %w", err) } @@ -123,11 +122,11 @@ func (b *BootLoader) findBootPartition() error { return fmt.Errorf("error reading GPT: %w", err) } - var bootPartition table.Partition + var bootPartition *gpt.Partition - for _, part := range diskTable.Partitions() { + for _, part := range diskTable.Partitions().Items() { // TODO: should we do better matching here - if part.No() == 1 { + if part.Number == 1 { bootPartition = part break @@ -138,7 +137,7 @@ func (b *BootLoader) findBootPartition() error { return fmt.Errorf("no boot partition found") } - b.bootPartitionReader = io.NewSectionReader(b.diskF, bootPartition.Start()*diskImageSectorSize, bootPartition.Length()*diskImageSectorSize) + b.bootPartitionReader = io.NewSectionReader(b.diskF, int64(bootPartition.FirstLBA)*diskImageSectorSize, int64(bootPartition.Length())*diskImageSectorSize) return nil } diff --git a/pkg/provision/providers/qemu/launch.go b/pkg/provision/providers/qemu/launch.go index 0971b74c3..0b646f100 100644 --- a/pkg/provision/providers/qemu/launch.go +++ b/pkg/provision/providers/qemu/launch.go @@ -6,6 +6,7 @@ package qemu import ( "context" + "errors" "fmt" "log" "net" @@ -19,7 +20,7 @@ import ( "github.com/containernetworking/plugins/pkg/ns" "github.com/containernetworking/plugins/pkg/testutils" "github.com/google/uuid" - "github.com/talos-systems/go-blockdevice/blockdevice/table/gpt" + "github.com/talos-systems/go-blockdevice/blockdevice/partition/gpt" "github.com/talos-systems/talos/pkg/provision" "github.com/talos-systems/talos/pkg/provision/internal/cniutils" @@ -167,8 +168,12 @@ func checkPartitions(config *LaunchConfig) (bool, error) { defer disk.Close() //nolint: errcheck - diskTable, err := gpt.NewGPT("vda", disk) + diskTable, err := gpt.Open(disk) if err != nil { + if errors.Is(err, gpt.ErrPartitionTableDoesNotExist) { + return false, nil + } + return false, fmt.Errorf("error creating GPT object: %w", err) } @@ -176,7 +181,7 @@ func checkPartitions(config *LaunchConfig) (bool, error) { return false, nil } - return len(diskTable.Partitions()) > 0, nil + return len(diskTable.Partitions().Items()) > 0, nil } // launchVM runs qemu with args built based on config. diff --git a/website/content/docs/v0.8/Single Board Computers/libretech_all_h3_cc_h5.md b/website/content/docs/v0.8/Single Board Computers/libretech_all_h3_cc_h5.md new file mode 100644 index 000000000..97ad8f073 --- /dev/null +++ b/website/content/docs/v0.8/Single Board Computers/libretech_all_h3_cc_h5.md @@ -0,0 +1,34 @@ +--- +title: "Libre Computer Board ALL-H3-CC" +--- + +## Generating the Image + +Using the Talos installer container, we can generate an image for the libretech_all_h3_cc_h5 by running: + +```bash +docker run \ + --rm \ + -v /dev:/dev \ + --privileged \ + ghcr.io/talos-systems/installer:latest image --platform metal --board libretech_all_h3_cc_h5 --tar-to-stdout | tar xz +``` + +## Writing the Image + +Once the image generation is done, extract the raw disk and `dd` it your SD card (be sure to update `x` in `mmcblkx`): + +```bash +tar -xvf metal-libretech_all_h3_cc_h5-arm64.tar.gz +sudo dd if=disk.raw of=/dev/mmcblkx +``` + +## Bootstrapping the Node + +Now insert the SD card, turn on the board, and wait for the console to show you the instructions for bootstrapping the node. +Following the instructions in the console output, generate the configuration files and apply the `init.yaml`: + +```bash +talosctl gen config libre https://:6443 +talosctl apply-config --insecure --file init.yaml --nodes +``` diff --git a/website/gridsome.config.js b/website/gridsome.config.js index f0698ab39..eb3004ec2 100644 --- a/website/gridsome.config.js +++ b/website/gridsome.config.js @@ -85,6 +85,7 @@ module.exports = { { title: "Virtualized Platforms", method: "alphabetical" }, { title: "Cloud Platforms", method: "alphabetical" }, { title: "Local Platforms", method: "alphabetical" }, + { title: "Single Board Computers", method: "alphabetical" }, { title: "Guides", method: "alphabetical" }, { title: "Reference", method: "alphabetical" }, { title: "Learn More", method: "weighted" },