Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Can I re-detect a usb drive after ejecting it? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
dequeued
n00b
n00b


Joined: 16 Oct 2007
Posts: 19
Location: NYC

PostPosted: Wed Feb 20, 2008 4:34 am    Post subject: Can I re-detect a usb drive after ejecting it? [SOLVED] Reply with quote

I am working on a backup script -- and I want to eject an external usb hard drive when it is not being used.
Right now, after a usb device has been ejected, I have to physically remove it and then plug it back in.

Is there any easy way to, I guess, scan the usb bus for any plugged in devices and activate them?


Last edited by dequeued on Fri Feb 22, 2008 3:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
NathanZachary
Moderator
Moderator


Joined: 30 Jan 2007
Posts: 2609

PostPosted: Wed Feb 20, 2008 5:53 am    Post subject: Reply with quote

Restarting HAL would do it, but that is probably more of a hassle than just unplugging it.
_________________
“Truth, like infinity, is to be forever approached but never reached.” --Jean Ayres (1972)
---avatar cropped from =AimanStudio---
Back to top
View user's profile Send private message
MostAwesomeDude
Guru
Guru


Joined: 12 Aug 2007
Posts: 373

PostPosted: Wed Feb 20, 2008 6:04 am    Post subject: Reply with quote

Mount it with "-o sync" and then unmount it when you don't need to write to/read from it.
_________________
Don't believe the "n00b" under my name.
Back to top
View user's profile Send private message
dequeued
n00b
n00b


Joined: 16 Oct 2007
Posts: 19
Location: NYC

PostPosted: Wed Feb 20, 2008 6:54 am    Post subject: Reply with quote

MostAwesomeDude wrote:
Mount it with "-o sync" and then unmount it when you don't need to write to/read from it.


Ok, but my particular device spins down and goes into power save mode when it is ejected.

It uses a laptop hard drive, and know that they aren't rated to last as long, and I see no reason why it should be up and spinning 24/7 when I only write to it twice a week.

That's why I unmount and eject it -- would doing this have the desired effect?
Back to top
View user's profile Send private message
baeksu
l33t
l33t


Joined: 26 Sep 2004
Posts: 609
Location: Seoul, Korea

PostPosted: Wed Feb 20, 2008 7:02 am    Post subject: Reply with quote

AFAIK, you can't remount a device after it's been ejected. At least it has never worked for me with iPods.

You might want to have a look at sdparm. Some usb harddrives can be spun down with 'sdparm --command=stop /dev/sdx', though your mileage may vary.
_________________
Gnome:
1. A legendary being.
2. A never ending quest to make unix friendly to people who don't want unix and excruciating for those that do.
Back to top
View user's profile Send private message
MostAwesomeDude
Guru
Guru


Joined: 12 Aug 2007
Posts: 373

PostPosted: Wed Feb 20, 2008 9:21 am    Post subject: Reply with quote

dequeued wrote:
MostAwesomeDude wrote:
Mount it with "-o sync" and then unmount it when you don't need to write to/read from it.


Ok, but my particular device spins down and goes into power save mode when it is ejected.

It uses a laptop hard drive, and know that they aren't rated to last as long, and I see no reason why it should be up and spinning 24/7 when I only write to it twice a week.

That's why I unmount and eject it -- would doing this have the desired effect?


If it is dependent on a specific module, you could always rmmod and insmod the module; that would start the udev hotplug and HAL hotplug events again. Also you could probably spin it down with sdparm.

Oh, and if you can get the kernel to automatically spin it down (there should be a switch somewhere, Google for it;) you should know that if you spin up a laptop hard drive once every ten minutes to write for less than thirty seconds, it should be good for about six years on average. Laptop drives can spin up a lot more times than desktop drives.
_________________
Don't believe the "n00b" under my name.
Back to top
View user's profile Send private message
dequeued
n00b
n00b


Joined: 16 Oct 2007
Posts: 19
Location: NYC

PostPosted: Wed Feb 20, 2008 12:09 pm    Post subject: Reply with quote

baeksu wrote:
AFAIK, you can't remount a device after it's been ejected. At least it has never worked for me with iPods.

You might want to have a look at sdparm. Some usb harddrives can be spun down with 'sdparm --command=stop /dev/sdx', though your mileage may vary.


Thank you, that was exactly what i need to know.
I can even issue a scsi stop command to the drive when it is still mounted, causing it to spin down.
The next time the kernel tries to read from the drive, it is blocked until it spins up.

Just to prevent my drive from being spun up at random times, and to add some security and saftey, I am going to keep it unmounted when I am not using it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum