Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Aug 2020 14:29:52 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Christoph Kukulies <kuku@kukulies.org>
Cc:        Ruben via freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Correct way to disconnect/eject an USB hard disk ?
Message-ID:  <20200819142952.3686baa8.freebsd@edvax.de>
In-Reply-To: <C6B11926-65BE-4A05-B421-9F3E9C9AACF6@kukulies.org>
References:  <C6B11926-65BE-4A05-B421-9F3E9C9AACF6@kukulies.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wed, 19 Aug 2020 13:31:07 +0200, Christoph Kukulies wrote:
> I had this /dev/da4 external USB drive connected to the system and had mounted
> /dev/da4s3 to /mnt.
> 
> After unmounting, are there any other measures to cleanly disconnect
> the device?

Usually not. If umount has been executed, and you wait a few
seconds in order to let the command be finished successfully
by the USB drive's firmware (last things to be written are
_actually_ written), disconnect is possible at any time. The
important thing to consider is that the filesystem should
always be in a consistent state - that's what umount will
accomplish. Due to the fact that "things need some time",
waiting a few seconds is never wrong. After that, disconnecting
power is no problem.




> I found that someone wrote to use
> 
> camcontrol eject <dev>

This is not needed - except the device in question is an
optical unit, in that case it's optional, but convenient,
in most cases. :-)



> This is my picture:
> 
> dev/da0	/dev/da3	/dev/da4s2	/dev/da5
> /dev/da1	/dev/da4	/dev/da4s3	/dev/da5p1
> /dev/da2	/dev/da4s1	/dev/da4s4	/dev/da5p2
> # camcontrol devlist
> <KINGSTON SA400S37240G SBFKB1D1>   at scbus0 target 0 lun 0 (ada0,pass0)
> <WDC WD10EADS-22M2B0 01.00A01>     at scbus1 target 0 lun 0 (ada1,pass1)
> <Samsung SSD 840 EVO 120GB EXT0AB0Q>  at scbus2 target 0 lun 0 (ada2,pass2)
> <SAMSUNG HD502HJ 1AJ100E4>         at scbus3 target 0 lun 0 (ada3,pass3)
> <HL-DT-ST DVDRAM GH24NSD5 LV00>    at scbus4 target 0 lun 0 (cd0,pass4)
> <CREATIVE CD5230E 1.01>            at scbus6 target 1 lun 0 (cd1,pass5)
> <HD0 SCSI2SD 4.2>                  at scbus7 target 0 lun 0 (da0,pass6)
> <HD1 SCSI2SD 4.2>                  at scbus7 target 1 lun 0 (da1,pass7)
> <HD2 SCSI2SD 4.2>                  at scbus7 target 2 lun 0 (da2,pass8)
> <HD3 SCSI2SD 4.2>                  at scbus7 target 3 lun 0 (da3,pass9)
> <WDC WD30 EFRX-68EUZN0 0107>       at scbus8 target 0 lun 0 (da4,pass10)
> <WDC WD30 EZRX-00MMMB0 0107>       at scbus8 target 0 lun 1 (da5,pass11)
> # camcontrol eject da4
> Error received from stop unit command

Not all USB devices implement the "eject" command _and_
reply that they have successfully executed it. That command
is typically used for optical units, tape drives, and other
kinds of drives where you eject a medium (!) from the drive.
For USB-connected direct access media such as USB sticks,
USB hard disks, USB-to-(P/S)ATA adapters or USB SSDs, this
is not needed. Power off is enough.

The "eject" command is often seen as a counterpart of the
"load" command for those kinds of drives that support it.

>From "man camcontrol":

     load        Send the SCSI Start/Stop Unit (0x1B) command to the given
                 device with the start bit set and the load/eject bit set.

     eject       Send the SCSI Start/Stop Unit (0x1B) command to the given
                 device with the start bit cleared and the load/eject bit set.

Clearly, none of this applies to USB sticks. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20200819142952.3686baa8.freebsd>