0

How can I prevent, or clean up (in an unprivileged way), the USB mount directories that remain after a power loss?

Here I'm inserting my USB stick:
enter image description here
There are no other USB sticks present, and I created this situation beforehand by twice inserting the same USB stick and pulling the power cord from the PC.

As you see, these directories keep piling up, while being empty as nothing is mounted to them.

Background:

We're developing an application, to be run on embedded computers, that can export data to the USB stick when the user taps a button. The user should not insert more than one USB stick and the software will issue an error if it detects this. The end users are locked out of the underlying OS (i.e. kiosk mode) and wouldn't even be able to access it if they wanted to.

The computers that this application will run on may be power-cut once every day, for years.

Things I've tried or dismissed:

  • I could run commands like mount or lsblk and parse the output. While this works, it doesn't prevent the root cause of directories piling up, and when executed every few seconds just to detect if a real USB stick is present, it's a significant load on the system.
  • I cannot scan for non-empty directories, because the USB stick(s) may be empty.

1 Answer 1

0

The only way out seems to be to clear out the /media directory first before starting the udisks2 service (you may want to edit the systemd unit file for that service).

Relevant reading: https://askubuntu.com/a/1113439

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .