Welcome Guest.   Make a donation to an author on the site October 25, 2014, 01:55:16 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
View the new Member Awards and Badges page.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: "Safely" Remove USB Devices in *N*X  (Read 1590 times)
ewemoa
Honorary Member
**
Posts: 2,483



View Profile Give some DonationCredits to this forum member
« on: June 09, 2012, 07:18:44 PM »

Recently I came across the "Safe Removal" feature in palimpsest (aka Gnome Disk Utility) and I've started using it before detaching some of my USB devices.  I'm not quite sure what it does, but LEDs seem to turn off so I get the sense that using the feature may be better than not.

I'd like to be able to do this or something comparable from the command line though.

Anyone know how that might be done?

The local context is various Debian-based things -- so I guess I'm looking for a GNU/Linux-ish answer smiley
Logged
40hz
Supporting Member
**
Posts: 10,733



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: June 10, 2012, 06:51:59 AM »

Quote
The umount Command

The umount command is used to manually unmount filesystems on Linux and other Unix-like operating systems.

A filesystem in this context is a hierarchy of directories that is located on a single partition (logically independent section of a hard disk drive) or other device, such as a CDROM, DVD, floppy disk or USB key drive, and has a single filesystem type (i.e., method for organizing data).

See the man pages for full syntax (i.e. $man unmount) or here for a complete how-to in normal understandable English.
 smiley
Logged

Don't you see? It's turtles all the way down!
ewemoa
Honorary Member
**
Posts: 2,483



View Profile Give some DonationCredits to this forum member
« Reply #2 on: June 10, 2012, 08:55:12 PM »

Thanks for the feedback.

As near as I can tell in this environment, even after performing umount on all the partitions on a device (so df doesn't show anything mounted for the drive), the physical device's LED is on.  So as far as I can tell, "Safely Remove" is not the same thing as umount.  IIRC, palimpsest's UI has a button per partition for unmounting and a single button for "Safely Remove" for the whole device.



Came across this too:

Safely remove an USB hard drive in Linux
« Last Edit: June 10, 2012, 09:14:02 PM by ewemoa » Logged
MilesAhead
Member
**
Posts: 4,948



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: June 10, 2012, 09:51:22 PM »

http://linux.about.com/li...rary/cmd/blcmdl8_sync.htm

At least buffers would be flushed to disk. As for all the rest of it, suspending the USB port etc.. I don't know if they have all that perfected yet. Half the time it doesn't work in Windows either. If the eject works for a drive I'll use it. But most of the time it just hangs. Usually I just run sync.exe to flush buffers to disk then pull the drive or shut it off if it has a power switch. It's been some time since I ran Linux. I'm just going by the link you posted.

Logged

"Genius is not knowing you can't do it that way."
- MilesAhead
40hz
Supporting Member
**
Posts: 10,733



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: June 10, 2012, 10:56:21 PM »

1. FWIW I've never had a issue or experienced data loss using unmount with any mainstream Linux distro since about the era of Ubuntu 8.0.4.  Although in day to day practice I tend to use the eject menu option from the graphic environment since that is the preferred "safe" eject procedure in most distros. YMMV.

2. There is an eject command available in many distros as well. Syntax can be found here.

3. Supposedly this command accomplishes the same thing as the eject menu command does:

      sudo echo 1>/sys/bus/usb/devices/usb1/remove

Can't vouch for it however, since it comes to me by way of another Nix user and I've never used it personally. It's an interesting approach and you could always script it to make your own command(s). Requires root access.

Luck!  Cool

Logged

Don't you see? It's turtles all the way down!
ewemoa
Honorary Member
**
Posts: 2,483



View Profile Give some DonationCredits to this forum member
« Reply #5 on: June 11, 2012, 06:39:52 AM »

There are some claims that suggest that umount will lead to a sync (at least in recent *NIXes) without having to do so manually.  In any case, sync doesn't appear to lead to the device's LED turning off.

eject looked promising, so I gave it a try -- the results of sudo eject -v sdb were:

Quote
eject: device name is `sdb'
eject: expanded name is `/dev/sdb'
eject: `/dev/sdb' is not mounted
eject: `/dev/sdb' is not a mount point
eject: `/dev/sdb' is a multipartition device
eject: using device name `/dev/sdb' for ioctls
eject: trying to eject `/dev/sdb' using CD-ROM eject command
eject: CD-ROM eject command failed
eject: trying to eject `/dev/sdb' using SCSI commands
eject: SCSI eject failed
eject: trying to eject `/dev/sdb' using floppy eject command
eject: floppy eject command failed
eject: trying to eject `/dev/sdb' using tape offline command
eject: tape offline command failed
eject: unable to eject, last error: Invalid argument

FWIW, sdb does show up via dmesg and sudo blkid shows some /dev/sdb* lines.  The syntax of the command looks right as one of the examples from the man page was: eject sda

I tried the sudo echo 1 thing, but no luck (Permission denied) -- may be I chose the wrong thing for what comes between devices/ and /remove...

Perhaps some day there'll be a straight-forward easy way to do this smiley

Thanks all for your help.
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.031s | Server load: 0.18 ]