summaryrefslogtreecommitdiff
path: root/src/op_mode/format_disk.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-12-04 07:34:23 +0100
committerChristian Poessinger <christian@poessinger.com>2021-12-04 07:37:55 +0100
commit4207b4c264312fc496722874ec52e2db834dec37 (patch)
treed329143e832ff08469e23f90a510d0dfb7b462be /src/op_mode/format_disk.py
parent467eb1f18ec971d6d3913d9ecc58b241db104f0d (diff)
downloadvyos-1x-4207b4c264312fc496722874ec52e2db834dec37.tar.gz
vyos-1x-4207b4c264312fc496722874ec52e2db834dec37.zip
op-mode: disk: T4045: bugfix "format disk <new> like <old>"
Diffstat (limited to 'src/op_mode/format_disk.py')
-rwxr-xr-xsrc/op_mode/format_disk.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/op_mode/format_disk.py b/src/op_mode/format_disk.py
index b68948e40..b3ba44e87 100755
--- a/src/op_mode/format_disk.py
+++ b/src/op_mode/format_disk.py
@@ -43,10 +43,11 @@ def is_busy(disk: str):
def backup_partitions(disk: str):
"""Save sfdisk partitions output to a backup file"""
- device_path = '/dev/' + disk
- backup_ts = datetime.now().strftime('%Y-%m-%d-%H:%M')
- backup_file = '/var/tmp/backup_{}.{}'.format(disk, backup_ts)
- cmd(f'sudo /sbin/sfdisk -d {device_path} > {backup_file}')
+ device_path = f'/dev/{disk}'
+ backup_ts = datetime.now().strftime('%Y%m%d-%H%M')
+ backup_file = f'/var/tmp/backup_{disk}.{backup_ts}'
+ call(f'sfdisk -d {device_path} > {backup_file}')
+ print(f'Partition table backup saved to {backup_file}')
def list_partitions(disk: str):