|
@@ -131,9 +131,12 @@ func (m *Manager) CreateRAIDDevice(devName string, raidLevel int, raidDeviceIds
|
|
|
// DANGER: Wipe the whole disk given the disk path
|
|
|
func (m *Manager) WipeDisk(diskPath string) error {
|
|
|
// Unmount the disk
|
|
|
- umountCmd := exec.Command("sudo", "umount", diskPath)
|
|
|
- if err := umountCmd.Run(); err != nil {
|
|
|
- return fmt.Errorf("error unmounting disk %s: %v", diskPath, err)
|
|
|
+ isMounted, _ := DeviceIsMounted(diskPath)
|
|
|
+ if isMounted {
|
|
|
+ umountCmd := exec.Command("sudo", "umount", diskPath)
|
|
|
+ if err := umountCmd.Run(); err != nil {
|
|
|
+ return fmt.Errorf("error unmounting disk %s: %v", diskPath, err)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Wipe all filesystem signatures on each of the partitions
|