Skip to content

Commit

Permalink
Clear all partition signatures on a devices before creating new (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Sep 10, 2021
1 parent f66e2ab commit 3cc1d3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
8 changes: 7 additions & 1 deletion cmd/storage/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/os/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
SGDisk = "sgdisk"
SSHD = "sshd"
SUM = "sum"
WIPEFS = "wipefs"
)

var commands = []string{
Expand All @@ -39,6 +40,7 @@ var commands = []string{
SGDisk,
SSHD,
SUM,
WIPEFS,
}

// CommandsExist check that all required binaries are installed in the initrd.
Expand Down

0 comments on commit 3cc1d3f

Please sign in to comment.