mirror of https://git.48k.eu/ogclient
fs: call wipefs partition before formatting partition
call wipefs before formatting partition, to remove any labels and stale data. call wipefs if formatting fails, to leave partition in consistent state. moreover, remove unnecessary exception handling on get_partition_device().master
parent
6503d0ffe7
commit
cf9577a40e
|
@ -153,13 +153,19 @@ def mkfs(fs, disk, partition, label=None):
|
|||
if fs not in fsdict:
|
||||
raise OgError(f'mkfs failed, unsupported target filesystem {fs}')
|
||||
|
||||
try:
|
||||
partdev = get_partition_device(disk, partition)
|
||||
except ValueError as e:
|
||||
raise OgError(f'mkfs aborted: {e}') from e
|
||||
|
||||
return fsdict[fs](partdev, label)
|
||||
ret = subprocess.run(['wipefs', '-af', f'{partdev}'])
|
||||
if ret.returncode != 0:
|
||||
logging.warning(f'wipefs on {partdev}, fails with {ret.returncode}')
|
||||
|
||||
err = fsdict[fs](partdev, label)
|
||||
if err != 0:
|
||||
ret = subprocess.run(['wipefs', '-af', f'{partdev}'])
|
||||
if ret.returncode != 0:
|
||||
logging.warning(f'wipefs on {partdev} for consistency, fails with {ret.returncode}')
|
||||
|
||||
return err
|
||||
|
||||
def mkfs_ext4(partdev, label=None):
|
||||
err = -1
|
||||
|
|
Loading…
Reference in New Issue