From owner-freebsd-questions@freebsd.org Wed Aug 19 15:44:42 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E06B83C1E65 for ; Wed, 19 Aug 2020 15:44:42 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from nightmare.dreamchaser.org (ns.dreamchaser.org [66.109.141.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "dreamchaser.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BWsXn3mkXz41SP for ; Wed, 19 Aug 2020 15:44:41 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from breakaway.dreamchaser.org (breakaway [192.168.151.122]) by nightmare.dreamchaser.org (8.15.2/8.15.2) with ESMTP id 07JFiTfZ037749; Wed, 19 Aug 2020 09:44:29 -0600 (MDT) (envelope-from freebsd@dreamchaser.org) Subject: Re: Correct way to disconnect/eject an USB hard disk ? To: Manish Jain , Polytropon , Christoph Kukulies Cc: Ruben via freebsd-questions References: <20200819142952.3686baa8.freebsd@edvax.de> From: Gary Aitken Reply-To: freebsd@dreamchaser.org Message-ID: Date: Wed, 19 Aug 2020 09:42:59 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (nightmare.dreamchaser.org [192.168.151.101]); Wed, 19 Aug 2020 09:44:29 -0600 (MDT) X-Rspamd-Queue-Id: 4BWsXn3mkXz41SP X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@dreamchaser.org designates 66.109.141.57 as permitted sender) smtp.mailfrom=freebsd@dreamchaser.org X-Spamd-Result: default: False [0.85 / 15.00]; HAS_REPLYTO(0.00)[freebsd@dreamchaser.org]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+mx]; NEURAL_SPAM_SHORT(0.15)[0.152]; MIME_GOOD(-0.10)[text/plain]; SUBJECT_ENDS_QUESTION(1.00)[]; REPLYTO_ADDR_EQ_FROM(0.00)[]; DMARC_NA(0.00)[dreamchaser.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_TO(0.00)[hotmail.com,edvax.de,kukulies.org]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:21947, ipnet:66.109.128.0/19, country:US]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Aug 2020 15:44:42 -0000 On 8/19/20 6:42 AM, Manish Jain wrote: > > > 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. Can you explain why I have seen umount commands return, and then the USB device "activity" light keeps blinking? I have on occasion waited for a while and it keeps blinking, and eventually I just unplugged it. Gary