1

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

CraftyMyner
  • 11
  • 1
  • 2

2 Answers2

1

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

jkhsjdhjs
  • 11
  • 1
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.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147