0

I have a setup where I need to log quite a bit of data on my Raspberry Pi. I have a 128GB USB stick that mounts to a folder called external where all my scripts/programs log to. This works well, except when the USB is removed the logs are written to the mount point and my script fails to remount it with:

FUSE exfat 1.3.0
WARN: volume was not unmounted cleanly.
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option

I added the "nonempty" option and it didn't seem to notice it. I tried every possible combination of the -nonempty option, looked all over the internet, and couldn't get it to mount to a directory with contents.

Some of the things I tried, but did not work:

mount -o nonempty /path/to/drive /path/to/external
mount /path/to/drive /path/to/external -o nonempty
mount.exfat-fuse -o nonempty /path/to/drive /path/to/external
mount.exfat-fuse /path/to/drive /path/to/external -o nonempty

If I understand correctly, nonempty should just mount on top of my internal folder and hide the contents until it is removed. This is the behavior I want, if there is no USB present it writes to the internal drive, and if there is it writes to the external drive, no need to change my scripts. If you have any other ideas on how to make this work, I am open to suggestions.

Thanks

1

Create a folder on your exFAT drive and write logs to that folder. That way, when the drive is not mounted, the folder will not exist and thus no files could be created in it.

A similar effect could be achieved with permissions: forbid the user running the script to create files in the mount point. When the drive is mounted, the mount point will be hidden and the permissions of the mounted filesystem will apply.

3
  • My understanding is that you must have an existing folder to mount a drive to? I was trying to avoid having any logic or "intelligence" in the software that is writing the logs. Ideally, any program would just write to the log folder and then the script manages mounting a drive to swap over to external logging. It looks like in the next release we will have what I am trying to achieve. – CraftyMyner Apr 11 at 16:22
  • @CraftyMyner Yes, you need an existing folder to mount your drive to. My point is that you need to have a folder on the drive to use for logging: that folder will not exist until you mount the drive. – Dmitry Grigoryev Apr 11 at 22:13
  • Right now the system tries to log to a folder inside where the drive is mounted. This means there is no logic for the application to know where it needs to log, if the drive is inserted it automatically switches it that instead otherwise it ends up on the primary drive. – CraftyMyner Apr 17 at 8:07
0

exfat currently doesn't pass command line options to fuse. This behavior is also stated in the man page [1]: man mount.exfat-fuse

-o options

File system specific options. For more details see FILE SYSTEM OPTIONS section below.

FILE SYSTEM OPTIONS hereby only includes options directly related to exFAT, not generic fuse options [2].

There exists an open issue regarding this problem, specifically for the nonempty option [3]. The author of this issue also created a pull request to fix this, but only for the nonempty option [4]. relan, the exfat maintainer, would prefer a solution that removes exFAT specific options from the options string to pass the remaining options to fuse afterwards [5]. This would make all fuse-related options work.

[1] https://man.archlinux.org/man/community/exfat-utils/mount.exfat-fuse.8.en
[2] https://man.archlinux.org/man/community/exfat-utils/mount.exfat-fuse.8.en#FILE_SYSTEM_OPTIONS
[3] https://github.com/relan/exfat/issues/131
[4] https://github.com/relan/exfat/pull/130
[5] https://github.com/relan/exfat/pull/130#issuecomment-531639520

5
  • Thank you for this information, do you know of any workarounds to mount exfat drives to folders with items inside. Currently, I am recreating the mount point before each mount to ensure that no files exist but "nonempty" option would but a much better solution. – CraftyMyner Apr 5 at 13:38
  • Unfortunately I'm not aware of any. You could of course modify the source code of exfat to just always pass nonempty to fuse and then compile it. I just asked the maintainer of exfat if it would be ok if I started to work on fixing this issue. – jkhsjdhjs Apr 6 at 17:18
  • It turns out the auhtor (relan) already did this on a separate branch (optwhitelist). – jkhsjdhjs Apr 6 at 19:34
  • optwhitelist has now been merged into master. So the nonempty mount option will work with the next release. – jkhsjdhjs Apr 10 at 10:55
  • Good to hear, thanks for digging into this. – CraftyMyner Apr 11 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.