You are not logged in.

#1 2010-08-19 03:35:30

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Linux equivalent of safely removing a usb device in windows?

I'm trying to get a wireless usb stick working well, and the last stumbling block I have is getting it to shut down (in a way) on a restart. If it doesn't it won't reinitialize properly, and I'll have remove it, then reload ndiswrapper, and plug it back in again. Windows automatically does this somehow, but I'm not sure what the linux analog would be.

Offline

#2 2010-08-19 04:31:49

dunz0r
Member
From: Sweden
Registered: 2009-03-30
Posts: 258
Website

Re: Linux equivalent of safely removing a usb device in windows?

You might try setting up a udev rule for it.


RTFM or GTFO
hax0r.se

Offline

#3 2010-08-19 05:16:48

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Linux equivalent of safely removing a usb device in windows?

Gnome does it for you but I'm thinking that you're not using Gnome.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2010-08-19 06:53:55

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: Linux equivalent of safely removing a usb device in windows?

I can use gnome np, or if I can modify the udev rules that's fine too, just point in the right direction.

Offline

#5 2010-08-19 06:56:35

yngwin
Member
Registered: 2009-05-08
Posts: 67

Re: Linux equivalent of safely removing a usb device in windows?

umount

Offline

#6 2010-08-19 07:03:49

icarus-c
Member
Registered: 2009-11-12
Posts: 17

Re: Linux equivalent of safely removing a usb device in windows?

note that omgwtfbyobbq is asking about  usb wireless adapter, but not usb flash drive...
and yea,  udev is the way to go

Offline

#7 2010-08-19 14:42:09

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: Linux equivalent of safely removing a usb device in windows?

What would a udev rule do in my case? I can't seem to figure out how to turn it off (the kernel power stuff doesn't support suspending the device), so can udev perform the equivalent of safely removing it in windows somehow?

Offline

#8 2010-08-20 13:06:26

Mohandas
Member
Registered: 2010-08-08
Posts: 4

Re: Linux equivalent of safely removing a usb device in windows?

Try something like :
sdparm --command=stop /dev/sdX

Last edited by Mohandas (2010-08-20 13:06:58)

Offline

#9 2010-08-20 19:40:41

parintachin
Member
Registered: 2009-05-25
Posts: 72

Re: Linux equivalent of safely removing a usb device in windows?

try eject /dev/sdx works also for flashdrives not just cd's plus the hardware-cache is flushed befor the device is unmounted and ejected

Offline

#10 2010-08-21 02:21:04

o1911
Member
From: Hobart, Australia
Registered: 2009-04-28
Posts: 106

Re: Linux equivalent of safely removing a usb device in windows?

Perhaps take a look at 'pmount' - it's meant for user-based permissions mounting.

However, I think this doesn't work for sata/esata drives... if that's the case, then what's a safe way to remove these drives without root and/or gui?

Last edited by o1911 (2010-08-21 02:21:21)


Arch x86_64

Offline

#11 2010-08-21 04:49:08

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: Linux equivalent of safely removing a usb device in windows?

I think I speak for the OP.  I have wondered about this for some time.  On every Linux I have encountered, unmounting a USB thumbdrive does dismount the device, but leaves the annunciator on the device illuminated. 

Certain other operating systems from the US Pacific Northwest manage to turn off the annunciator providing positive feedback that it is safe to unplug the device without the risk of corrupting it.

I had never seen Mohandas' suggestion so I tried it:

ewaller@odin:~/devel/wxwidgetsprojects/spacewar 1181 %sudo sdparm --command=stop /dev/sdb 
    /dev/sdb: SanDisk   Cruzer Mini       0.1 

The light blinked, but stayed on.  I verified it is truly unmounted.

How does one truly know when the drive has finished all of its house keeping? (Hint that can be thousands of milliseconds after the sync and dismount)?


edit: fixed typo

Last edited by ewaller (2010-08-21 04:50:07)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#12 2010-08-21 07:37:41

o1911
Member
From: Hobart, Australia
Registered: 2009-04-28
Posts: 106

Re: Linux equivalent of safely removing a usb device in windows?

You could try lsusb.


Arch x86_64

Offline

#13 2010-08-21 12:58:48

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Linux equivalent of safely removing a usb device in windows?

omgwtfbyobbq wrote:

I'm trying to get a wireless usb stick working

icarus-c wrote:

note that omgwtfbyobbq is asking about  usb wireless adapter, but not usb flash drive...

Wireless. Network device. Not a storage device.

You might see if you can turn it off via a utility like rfkill.

Offline

#14 2010-08-21 18:50:08

cubeist
Member
Registered: 2010-08-01
Posts: 36

Re: Linux equivalent of safely removing a usb device in windows?

umount is safe to use most of the time.  It will perform necessary housekeeping and unmount the drive, however, it does not cut off the power to the drive (which is why most USB sticks will still have an illuminated led).  You can use dmesg to ensure the USB is actually dismounted and it will show a message like: usb 2-6: USB disconnect, address 2

Safely remove drive, as I understand it, is just umount with a power kill command.  So after the drive is unmounted it kills the USB power and the drive cannot be mounted unless it is unplugged and plugged back in.

The reason most computer OS's have 'safely remove drive' is because many USB controllers (the chip on the USB drive) have a persistent remount feature.  If you don't kill the power to the darn thing it will start broadcasting the initialization handshaking sequence again...which will probably be ignored by the OS since, ironically, the computer thinks the hardware space the USB drive is broadcasting from has already been allocated.  At this point most users yank the USB drive out of the socket leaving the device in a non-clean state (remember the drive started to handshake with the computer and was waiting for a reply). 

however, my knowledge on this stuff is from several years ago, so things may not function the same way today tongue

Last edited by cubeist (2010-08-21 18:51:31)

Offline

#15 2010-08-21 19:31:05

capoeira
Member
From: Vila Velha - Brasil
Registered: 2010-05-25
Posts: 470

Re: Linux equivalent of safely removing a usb device in windows?

as I use dolphin to mount I use it to unmount, too

Offline

#16 2010-08-21 20:32:34

Roline
Member
From: Netherlands
Registered: 2009-12-05
Posts: 207
Website

Re: Linux equivalent of safely removing a usb device in windows?

try terminal wink


Bitbucket - DeviantART - Userstyles
*Currently Not Using Arch

Offline

#17 2010-08-31 00:59:08

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: Linux equivalent of safely removing a usb device in windows?

The problem is that it only shows up as a usb storage device in windows. In arch, there's no /dev/sd* besides my hd partitions at /dev/sda*, so I can't unmount it in that context. rfkill list doesn't pick it up unfortunately, but thanks for the ideas everyone!

Offline

Board footer

Powered by FluxBB