Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know that the eject command can be used to eject almost any hardware component attached, but can it be used to eject USB drives?

Is it possible to eject USB drives and external HDD's with the eject command?

share|improve this question

2 Answers

up vote 3 down vote accepted

No. Nor do they need to be; eject is used for opening optical drives, where one cannot pull the media from directly.

Unmounting is sufficient for USB/eSATA/etc. storage devices.

share|improve this answer
Hmm, I saw eject hdd as in /dev/sda somewhere. I guess the reference was wrong then. – Joe Barr Apr 2 '12 at 0:49
You can do it, but it usually doesn't do very much if anything at all. – Ignacio Vazquez-Abrams Apr 2 '12 at 0:51
This assumes that the device is mounted in the first place, and that carries along another big set of assumptions (it's got a filesystem that you can read, for one). Imagine that you're erasing a bunch of external drives - they probably never get mounted. eject is the right thing to use. – James Moore Oct 5 '12 at 15:03

"Ejecting" has no meaning for hardware without a tray or other loading mechanism (I assume it works with tape drives too).

However, testing with an external USB flash drive tells that eject works much like umount - with the side effect of making the device nodes disappear, e.g.

% ls  /dev/sdc*
/dev/sdc  /dev/sdc1
% sudo eject /dev/sdc
% ls  /dev/sdc*
/dev/sdc

Note that /dev/sdc1 has disappeared.

share|improve this answer
1  
Never tried it with tapes (mt rewoffl is more convenient because it also rewinds), but it does work with motorised floppy drives like those found on old Macs and Sun workstations. – Alexios Apr 2 '12 at 4:23
@Alexios interesting. – Renan Apr 2 '12 at 16:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.