diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-12-04 07:34:23 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-12-04 07:37:55 +0100 |
commit | 4207b4c264312fc496722874ec52e2db834dec37 (patch) | |
tree | d329143e832ff08469e23f90a510d0dfb7b462be /src/op_mode/format_disk.py | |
parent | 467eb1f18ec971d6d3913d9ecc58b241db104f0d (diff) | |
download | vyos-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-x | src/op_mode/format_disk.py | 9 |
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): |