Skip to content

Commit

Permalink
fix(utils): log mkfs.ext4 error output
Browse files Browse the repository at this point in the history
Prior to this, if `mkfs.ext4` failed, all we saw was "failed to
format /dev/sda. err: exit status 1".  With this change, we'll
see the command output, which is a bit more useful, for exmaple:
"failed to format /dev/sda. exit status 1: mke2fs 1.46.4
(18-Aug-2021) /dev/sda is apparently in use by the system;
will not make a filesystem here!"

Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit 81e8774)
  • Loading branch information
tserong authored and bk201 committed Sep 25, 2024
1 parent 3ed68b1 commit 09e7801
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func MakeExt4DiskFormatting(devPath, uuid string) error {
args = append(args, "-U", uuid)
}
cmd := exec.Command("mkfs.ext4", args...)
if _, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to format %s. err: %v", devPath, err)
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to format %s. %v: %s", devPath, err,
strings.ReplaceAll(strings.TrimSpace(string(output)), "\n", " "))
}
return nil
}
Expand Down

0 comments on commit 09e7801

Please sign in to comment.