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:39:05 +0100 |
commit | e87a1c8364158d0a40edaa984ccb7606e4243a1a (patch) | |
tree | edab63b8e5b040de44559ad08e9042d2b52b7011 /src | |
parent | e151c113e9e7153efb6cbf4216f2114b834d57ff (diff) | |
download | vyos-1x-e87a1c8364158d0a40edaa984ccb7606e4243a1a.tar.gz vyos-1x-e87a1c8364158d0a40edaa984ccb7606e4243a1a.zip |
op-mode: disk: T4045: bugfix "format disk <new> like <old>"
(cherry picked from commit 4207b4c264312fc496722874ec52e2db834dec37)
Diffstat (limited to 'src')
-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): |