experchange > linux.misc

T (11-07-18, 11:50 PM)
Hi All,

Fedora 29

I am starting to use flash drive s with no led activity indicator.
In my scripts that write to them, I am able to umount then watch
the blinking lights to make sure it is done before removing them

But with no led indicator, how can I test from my script to
make sure it is done writing?

This is the dismount part of my script:

sync; sync
umount $StickTarget

Many thanks,
-T
Eli the Bearded (11-07-18, 11:54 PM)
In comp.os.linux.misc, T <T> wrote:
> But with no led indicator, how can I test from my script to
> make sure it is done writing?
> This is the dismount part of my script:
> sync; sync
> umount $StickTarget


My experience is that 'umount' will not return before the writes are all
complete. I usually wait a few seconds after anyway.

Elijah
------
hasn't done the sync;sync thing in a long time
Carlos E. R. (11-08-18, 12:01 AM)
On 07/11/2018 22.50, T wrote:
> Hi All,
> Fedora 29
> I am starting to use flash drive s with no led activity indicator.
> In my scripts that write to them, I am able to umount then watch
> the blinking lights to make sure it is done before removing them
> But with no led indicator, how can I test from my script to
> make sure it is done writing?
> This is the dismount part of my script:
>      sync; sync
>      umount $StickTarget


AFAIK, umount does not return till done. But if there are doubts, issue
a sync after it, not before, which should not return till done.
David W. Hodgins (11-08-18, 02:13 AM)
On Wed, 07 Nov 2018 16:50:04 -0500, T <T> wrote:

> I am starting to use flash drive s with no led activity indicator.
> In my scripts that write to them, I am able to umount then watch
> the blinking lights to make sure it is done before removing them
> But with no led indicator, how can I test from my script to
> make sure it is done writing?
> This is the dismount part of my script:
> sync; sync
> umount $StickTarget


While with many (perhaps most) usb sticks, the umount will not return
until the writing is finished, there are at least some where that is
not the case. I don't know what the difference is between the sticks
where it waits and those where it doesn't but I've found that waiting
until there are no processes in a device wait state for several seconds
works. This is most needed when using dd to copy an iso image to a drive,
where there is no filesystem open, to sync, or mount point to umount.

I run htop, press f6 to set the sort order, select STATE. Watch for any
processes in the state column (header shows just S) showing the state D.

Regards, Dave Hodgins
T (11-08-18, 02:20 AM)
On 11/7/18 2:01 PM, Carlos E. R. wrote:
> On 07/11/2018 22.50, T wrote:
> AFAIK, umount does not return till done.


"Supposedly". Other on the Fedora mailing list confirmed
they are having the same issue.

> But if there are doubts, issue
> a sync after it, not before, which should not return till done.


Will do! Thank you!

Will keeping the "before" hurt anything?
Robert Heller (11-08-18, 05:57 AM)
At Wed, 7 Nov 2018 23:01:24 +0100 "Carlos E. R." <robin_listas> wrote:

> On 07/11/2018 22.50, T wrote:
> AFAIK, umount does not return till done. But if there are doubts, issue
> a sync after it, not before, which should not return till done.


umount *always* blocks until all pending write buffers to the specified
filesystem are flushed.

sync blocks until all pending write buffers are flushed (to all file systems).
Robert Heller (11-08-18, 05:57 AM)
At Wed, 7 Nov 2018 16:20:23 -0800 T <T> wrote:

> On 11/7/18 2:01 PM, Carlos E. R. wrote:
> "Supposedly". Other on the Fedora mailing list confirmed
> they are having the same issue.
> Will do! Thank you!
> Will keeping the "before" hurt anything?


Nope.
T (11-08-18, 06:48 AM)
On 11/7/18 7:57 PM, Robert Heller wrote:
> At Wed, 7 Nov 2018 16:20:23 -0800 T <T> wrote:
> Nope.


Thank you!
The Natural Philosopher (11-08-18, 09:57 AM)
On 08/11/2018 00:13, David W. Hodgins wrote:
[..]
> I run htop, press f6 to set the sort order, select STATE. Watch for any
> processes in the state column (header shows just S) showing the state D.
> Regards, Dave Hodgins

One supposes that write to sticks - later sticks - are cached before
being written to the NAND, and nothing on the far side of the USB can
detect whether that has happened or not, and one relies on perhaps some
residual power in capacitors to complete the process if the stick is
prematurey yanked.

If there is wear levelling going on, its going to take some time to
finish. One suppooses.

No idea if any of the above is in fact the case tho...:-)
Carlos E.R. (11-08-18, 12:27 PM)
On 08/11/2018 01.20, T wrote:
> On 11/7/18 2:01 PM, Carlos E. R. wrote:
> "Supposedly".  Other on the Fedora mailing list confirmed
> they are having the same issue.
> Will do!  Thank you!
> Will keeping the "before" hurt anything?


No, just may take longer.
Charlie Gibbs (11-08-18, 09:38 PM)
On 2018-11-07, Carlos E. R. <robin_listas> wrote:

> On 07/11/2018 22.50, T wrote:
> AFAIK, umount does not return till done. But if there are doubts, issue
> a sync after it, not before, which should not return till done.


Just remember that song from the '70s:

Sync three times on the console if you want me.
Close all the pipes if the answer is no.
George (11-09-18, 03:25 AM)
T <T> wrote:
> Hi All,
> Fedora 29
> I am starting to use flash drive s with no led activity indicator.
> In my scripts that write to them, I am able to umount then watch
> the blinking lights to make sure it is done before removing them
> But with no led indicator, how can I test from my script to
> make sure it is done writing?
> This is the dismount part of my script:
> sync; sync
> umount $StickTarget


# sync and eject device [or device associated with a given partition]
tgt=/dev/sdc2 # Parent name [/dev/sdc] will work as well
sync
eject $tgt # umount all partitions on associated device
echo "OK to remove output device [$tgt]"
Carlos E.R. (11-09-18, 12:23 PM)
On 09/11/2018 02.25, George wrote:
> T <T> wrote:
> # sync and eject device [or device associated with a given partition]
> tgt=/dev/sdc2 # Parent name [/dev/sdc] will work as well
> sync
> eject $tgt # umount all partitions on associated device
> echo "OK to remove output device [$tgt]"


Good point. I forgot about eject.
T (11-09-18, 10:02 PM)
On 11/8/18 2:27 AM, Carlos E.R. wrote:
> On 08/11/2018 01.20, T wrote:
> No, just may take longer.


Okay with me. Thank you!
T (11-09-18, 10:03 PM)
On 11/8/18 11:38 AM, Charlie Gibbs wrote:
> On 2018-11-07, Carlos E. R. <robin_listas> wrote:
> Just remember that song from the '70s:
> Sync three times on the console if you want me.
> Close all the pipes if the answer is no.


:-)

Similar Threads