How to wake unmounted external drive within a script?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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:



  1. 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.

  2. 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.







share|improve this question


























    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:



    1. 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.

    2. 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.







    share|improve this question
























      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:



      1. 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.

      2. 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.







      share|improve this question














      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:



      1. 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.

      2. 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.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 27 at 10:34









      muru

      1




      1










      asked Apr 27 at 10:27









      Arronical

      12.6k84489




      12.6k84489

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491