Well, this is embarrassing.
For many years I have been doing regular backups of all my files to a USB stick using a fancy script that I wrote.
It’s worked well until yesterday when nothing seemed to be written despite no error messages being displayed.
It turned out that the USB stick had been corrupted and I had to consult the internet to fix and reformat the device.
When one inserts a USB stick the file manager is started automatically and opens at the USB device. My script ignores the file manager and, when the backup is finished, unmounts the device and tells me to remove it. BUT the device is still active in the file manager. I suspect that over the years I have been lucky in removing my device after my script has unmounted it without damage to the device - until now!
Clearly, a device can be mounted by separate applications independently so it’s necessary to ensure that all applications accessing the device have unmounted it. Specifically; unmounting via the terminal will not unmount it from the file manager, but unmounting in the file manager will unmount it fully . Simply closing the file manager (without unmounting the USB) does not unmount it from the terminal.
Perhaps a knowledgeable member can tell us what’s happening.
My solution: as soon as the script has found the USB it now closes the file manager window that has just opened. As the script is now the only application mounting the device, it is safe to remove it after the script unmounts it.
Yes - I feel very foolish but thought that a reminder was in order.
Keith
(Dell Latitude E5570 running Ubuntu 20.04)
9 posts - 1 participant