Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Aug 2020 18:12:34 +0530
From:      Manish Jain <bourne.identity@hotmail.com>
To:        Polytropon <freebsd@edvax.de>, 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:  <DB8PR06MB64427319E175193D1B828135F65D0@DB8PR06MB6442.eurprd06.prod.outlook.com>
In-Reply-To: <20200819142952.3686baa8.freebsd@edvax.de>
References:  <C6B11926-65BE-4A05-B421-9F3E9C9AACF6@kukulies.org> <20200819142952.3686baa8.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help


On 2020-08-19 17:59, Polytropon wrote:
>> 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.


A note: it is perfectly safe to disconnect device any time after umount 
has returned. The one problem is umount may take anything between a 
second and a few hours (!) to return. This depends on whether the 
filesystem was mounted as sync or async (the default).

When fs is mounted with sync option on, I/O is very slow - ~10x slower 
than with async.

With async option on at the time of mount, I/O is much faster, the 
algorithmic complexity of the code dealing with the I/O is much higher, 
and a whole lot of data may remain unflushed even after an I/O command 
(cp for instance) has returned. It is at the time of umount all this 
data gets flushed - although you can manually force the flush yourself 
with `sync`, in which case `umount` will return quickly.


Hope this helps,
Manish Jain




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DB8PR06MB64427319E175193D1B828135F65D0>