diff --git a/Makefile b/Makefile index f03d179b..6ea27666 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ ramdisk: -files="/sbin/mdadm:sbin/mdadm" \ -files="/sbin/mdmon:sbin/mdmon" \ -files="/sbin/sgdisk:sbin/sgdisk" \ + -files="/sbin/wipefs:sbin/wipefs" \ -files="/etc/ssl/certs/ca-certificates.crt:etc/ssl/certs/ca-certificates.crt" \ -files="/usr/lib/x86_64-linux-gnu/libnss_files.so:lib/libnss_files.so.2" \ -files="passwd:etc/passwd" \ diff --git a/cmd/storage/filesystem.go b/cmd/storage/filesystem.go index 8aee1b14..e33a18e9 100644 --- a/cmd/storage/filesystem.go +++ b/cmd/storage/filesystem.go @@ -113,9 +113,15 @@ func (f *Filesystem) createPartitions() error { } } if disk.Device != nil { + log.Info("wipe existing partition signatures", "command", command.WIPEFS+" --all"+" "+*disk.Device) + err := os.ExecuteCommand(command.WIPEFS, "--all", *disk.Device) + if err != nil { + log.Error("wipe existing partition signatures failed", "error", err) + return fmt.Errorf("unable wipe existing partitions on %s %w", *disk.Device, err) + } opts = append(opts, *disk.Device) log.Info("sgdisk create partitions", "command", opts) - err := os.ExecuteCommand(command.SGDisk, opts...) + err = os.ExecuteCommand(command.SGDisk, opts...) if err != nil { log.Error("sgdisk creating partitions failed", "error", err) return fmt.Errorf("unable to create partitions on %s %w", *disk.Device, err) diff --git a/pkg/os/command/commands.go b/pkg/os/command/commands.go index 08f0aa00..caafebb5 100644 --- a/pkg/os/command/commands.go +++ b/pkg/os/command/commands.go @@ -21,6 +21,7 @@ const ( SGDisk = "sgdisk" SSHD = "sshd" SUM = "sum" + WIPEFS = "wipefs" ) var commands = []string{ @@ -39,6 +40,7 @@ var commands = []string{ SGDisk, SSHD, SUM, + WIPEFS, } // CommandsExist check that all required binaries are installed in the initrd.