How to wake unmounted external drive within a script?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I have a hard drive in an external enclosure connected to a 14.04 server installation by a USB 2 cable. Periodically a Bash scripted process checks that the correct drive is connected using lsblk
, collects a series of files and copies them to the drive.
The drive has normally been connected and powered on for a couple of days before this process takes place.
Very occasionally the drive does not appear to be connected, it appears it has entered some sort of sleep mode from which it is very slow to respond. lsblk
does not return any of the drive's details and my script responds as if no drive is connected.
I've observed this outside of the script too, sometimes I'll check available drives with fdisk -l
with two varieties of outcome:
- The command will take much longer than normal before returning details of the external drive. In this situation executing the command again immediately afterwards will return all of the results at the usual speed.
- The command runs slowly and the external drive will not be listed in the output at all. If I run the command again the drive appears in the output as
normal. It just seems as if it didn't respond quickly enough the
first time.
Is there a command that I can reliably use in a Bash script to make sure that the external drive is 'awake' and ready to respond?
I supppose I could use fdisk -l
and redirect to /dev/null
but I suspect there's a more appropriate command.
If it's of any use It's a Seagate Desktop HDD ST1000DM003 in a Evo Labs E-U3F SATA enclosure.
command-line mount suspend usb-drive
add a comment |Â
up vote
1
down vote
favorite
I have a hard drive in an external enclosure connected to a 14.04 server installation by a USB 2 cable. Periodically a Bash scripted process checks that the correct drive is connected using lsblk
, collects a series of files and copies them to the drive.
The drive has normally been connected and powered on for a couple of days before this process takes place.
Very occasionally the drive does not appear to be connected, it appears it has entered some sort of sleep mode from which it is very slow to respond. lsblk
does not return any of the drive's details and my script responds as if no drive is connected.
I've observed this outside of the script too, sometimes I'll check available drives with fdisk -l
with two varieties of outcome:
- The command will take much longer than normal before returning details of the external drive. In this situation executing the command again immediately afterwards will return all of the results at the usual speed.
- The command runs slowly and the external drive will not be listed in the output at all. If I run the command again the drive appears in the output as
normal. It just seems as if it didn't respond quickly enough the
first time.
Is there a command that I can reliably use in a Bash script to make sure that the external drive is 'awake' and ready to respond?
I supppose I could use fdisk -l
and redirect to /dev/null
but I suspect there's a more appropriate command.
If it's of any use It's a Seagate Desktop HDD ST1000DM003 in a Evo Labs E-U3F SATA enclosure.
command-line mount suspend usb-drive
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a hard drive in an external enclosure connected to a 14.04 server installation by a USB 2 cable. Periodically a Bash scripted process checks that the correct drive is connected using lsblk
, collects a series of files and copies them to the drive.
The drive has normally been connected and powered on for a couple of days before this process takes place.
Very occasionally the drive does not appear to be connected, it appears it has entered some sort of sleep mode from which it is very slow to respond. lsblk
does not return any of the drive's details and my script responds as if no drive is connected.
I've observed this outside of the script too, sometimes I'll check available drives with fdisk -l
with two varieties of outcome:
- The command will take much longer than normal before returning details of the external drive. In this situation executing the command again immediately afterwards will return all of the results at the usual speed.
- The command runs slowly and the external drive will not be listed in the output at all. If I run the command again the drive appears in the output as
normal. It just seems as if it didn't respond quickly enough the
first time.
Is there a command that I can reliably use in a Bash script to make sure that the external drive is 'awake' and ready to respond?
I supppose I could use fdisk -l
and redirect to /dev/null
but I suspect there's a more appropriate command.
If it's of any use It's a Seagate Desktop HDD ST1000DM003 in a Evo Labs E-U3F SATA enclosure.
command-line mount suspend usb-drive
I have a hard drive in an external enclosure connected to a 14.04 server installation by a USB 2 cable. Periodically a Bash scripted process checks that the correct drive is connected using lsblk
, collects a series of files and copies them to the drive.
The drive has normally been connected and powered on for a couple of days before this process takes place.
Very occasionally the drive does not appear to be connected, it appears it has entered some sort of sleep mode from which it is very slow to respond. lsblk
does not return any of the drive's details and my script responds as if no drive is connected.
I've observed this outside of the script too, sometimes I'll check available drives with fdisk -l
with two varieties of outcome:
- The command will take much longer than normal before returning details of the external drive. In this situation executing the command again immediately afterwards will return all of the results at the usual speed.
- The command runs slowly and the external drive will not be listed in the output at all. If I run the command again the drive appears in the output as
normal. It just seems as if it didn't respond quickly enough the
first time.
Is there a command that I can reliably use in a Bash script to make sure that the external drive is 'awake' and ready to respond?
I supppose I could use fdisk -l
and redirect to /dev/null
but I suspect there's a more appropriate command.
If it's of any use It's a Seagate Desktop HDD ST1000DM003 in a Evo Labs E-U3F SATA enclosure.
command-line mount suspend usb-drive
edited Apr 27 at 10:34
muru
1
1
asked Apr 27 at 10:27
![](https://i.stack.imgur.com/smMAw.jpg?s=32&g=1)
![](https://i.stack.imgur.com/smMAw.jpg?s=32&g=1)
Arronical
12.6k84489
12.6k84489
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028722%2fhow-to-wake-unmounted-external-drive-within-a-script%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password