WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Auto mount USB drive from .X.d Not Working  (Read 4900 times)

Offline pek

  • Full Member
  • ***
  • Posts: 111
Re: Auto mount USB drive from .X.d Not Working
« Reply #15 on: September 17, 2021, 09:08:25 AM »
Good news.. It works this time..!!  ;D
Thank you Rich and curaga.

It took about 2 or 3 seconds to get mounted as can be seen in below debug.txt
Code: [Select]
+ sudo mkdir /tmp/theUSB
+ sync
+ drive=
+ '[' -z '' ']'
++ /sbin/blkid -lt LABEL=theLABEL -o device
+ drive=
+ sleep 1
+ '[' -z '' ']'
++ /sbin/blkid -lt LABEL=theLABEL -o device
+ drive=
+ sleep 1
+ '[' -z '' ']'
++ /sbin/blkid -lt LABEL=theLABEL -o device
+ drive=
+ sleep 1
+ '[' -z '' ']'
++ /sbin/blkid -lt LABEL=theLABEL -o device
+ drive=
+ sleep 1
+ '[' -z '' ']'
++ /sbin/blkid -lt LABEL=theLABEL -o device
+ drive=/dev/sdb1
+ sleep 1
+ '[' -z /dev/sdb1 ']'
+ sudo mount /dev/sdb1 /tmp/theUSB

However when I did "sleep 9" without the loop as above, it did not recognized.
Probably the USB drive needs to be probed a few times. Thus the loop "wakes" it up only in few seconds.

I'm not sure how how this works... But it does.
Thank you again guys...!!  :)

Offline pek

  • Full Member
  • ***
  • Posts: 111
Re: Auto mount USB drive from .X.d Not Working
« Reply #16 on: September 17, 2021, 09:47:11 AM »
Sorry.. my bad.
Actually "sleep 9" is also working.
I put it at the wrong line... That's why it did not work.
Code: [Select]
sudo mkdir /tmp/theUSB
sudo mount -L theLABEL /tmp/theUSB
s l e e p 9

the correct one is
Code: [Select]
sudo mkdir /tmp/theUSB
s l e e p 9
sudo mount -L theLABEL /tmp/theUSB

even so.. I prefer Rich's loop code. That way I don't need to guess how long the "sleep" should be.

All good.. Mistery solved.
Sorry for the hassles guys..
And best of all, I learn more new tricks... Thank you!!  ;D ;D

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11213
Re: Auto mount USB drive from .X.d Not Working
« Reply #17 on: September 17, 2021, 09:58:44 AM »
Hi pek
... I prefer Rich's loop code. That way I don't need to guess how long the "sleep" should be. ...
It's also faster since it waits only until the label becomes visible.

The  sleep  command also can handle decimal numbers.
If you want to reduce the wait time a little more, try  sleep 0.25

Offline pek

  • Full Member
  • ***
  • Posts: 111
Re: Auto mount USB drive from .X.d Not Working
« Reply #18 on: September 17, 2021, 10:47:47 PM »
The  sleep  command also can handle decimal numbers.
If you want to reduce the wait time a little more, try  sleep 0.25

Oh.. that's good to know. Thank you.