[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Distinguishing among [unmount, Safely Remove Drive, Eject]



On Sun 06 May 2018 at 15:53:05 +1200, Richard Hector wrote:

> On 06/05/18 07:35, Brian wrote:
> > On Sat 05 May 2018 at 11:06:25 -0500, Richard Owlett wrote:
> > 
> >> What are the distinguishing features of unmount, Safely Remove Drive, and
> >> Eject?
> > 
> > There are none. The device is either unmounted or it isn't. It cannnot
> > be half-unmounted.
> 
> Hmm. Is there not a point where it's been made inaccessible to the
> filesystem, but caches are not yet flushed?

I don't know but I've always thought that unmounting a USB stick led to
a sync action and buffers were flushed. Anyway, in the light of Henrique
de Moraes Holschuh's enlightening post I'll back away a little from my
previous mail and give a restructured response.

Although it is from a few years ago, the material at

  https://bugzilla.gnome.org/show_bug.cgi?id=598690

could still be useful. Safely Remove Drive and Eject are associated
with DEs, although Xfce seems to manage without them and has unmount as
an only option.

udisks2 is the software involved. A test (as an unprivileged user) after
plugging in a USB stick:

 lsblk                            (To get the device)
 udisksctl mount -b /dev/sdg1
 udisksctl unmount -b /dev/sdg1   (Must be done before the next command).
 udisksctl power-off -b /dev/sdg1 (Observe indicator light on the stick).

The stick needs detaching and re-inserting to get mounting to work again.

>From udisksctl(1):

 power-off
  Arranges for the drive to be safely removed and powered off. On the
  OS side this includes ensuring that no process is using the drive,
  then requesting that in-flight buffers and caches are committed to
  stable storage. The exact steps for powering off the drive depends
  on the drive itself and the interconnect used. For drives connected
  through USB, the effect is that the USB device will be deconfigured
  followed by disabling the upstream hub port it is connected to.
 
  Note that as some physical devices contain multiple drives (for
  example 4-in-1 flash card reader USB devices) powering off one drive
  may affect other drives. As such there are not a lot of guarantees
  associated with performing this action. Usually the effect is that
  the drive disappears as if it was unplugged.

I'm still pondering why I would need power-off with a USB device.

-- 
Brian.


Reply to: