Set source drive to sleep instead of detaching it
This commit is contained in:
parent
f1592b92a6
commit
ffa2df416b
1 changed files with 5 additions and 7 deletions
|
|
@ -1960,7 +1960,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
|
||||||
|
|
||||||
def _poweroff_source_drive(idle_minutes):
|
def _poweroff_source_drive(idle_minutes):
|
||||||
"""Power off source drive after a while."""
|
"""Power off source drive after a while."""
|
||||||
source_dev = state.source.path.name
|
source_dev = state.source.path
|
||||||
|
|
||||||
# Bail early
|
# Bail early
|
||||||
if PLATFORM == 'Darwin':
|
if PLATFORM == 'Darwin':
|
||||||
|
|
@ -1982,14 +1982,12 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
|
||||||
i += 5
|
i += 5
|
||||||
|
|
||||||
# Power off drive
|
# Power off drive
|
||||||
cmd = f'echo 1 | sudo tee /sys/block/{source_dev}/device/delete'
|
cmd = ['sudo', 'hdparm', '-Y', source_dev]
|
||||||
proc = exe.run_program(cmd, check=False, shell=True)
|
proc = exe.run_program(cmd, check=False)
|
||||||
if proc.returncode:
|
if proc.returncode:
|
||||||
LOG.error('Failed to poweroff source %s', state.source.path)
|
std.print_error(f'Failed to poweroff source {source_dev}')
|
||||||
std.print_error(f'Failed to poweroff source {state.source.path}')
|
|
||||||
else:
|
else:
|
||||||
LOG.info('Powered off source %s', state.source.path)
|
std.print_warning(f'Powered off source {source_dev}')
|
||||||
std.print_error(f'Powered off source {state.source.path}')
|
|
||||||
std.print_standard(
|
std.print_standard(
|
||||||
'Press Enter to return to main menu...', end='', flush=True,
|
'Press Enter to return to main menu...', end='', flush=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue