1

I want to execute a command automatically shortly before a filesystem is unmounted. The command still needs the filesystem to be mounted but I am interested in information as "new" as possible. Therefore a simple cron job is not a nice solution. (You can assume the command is df /the/mount/point.)

Is there any way to run a command automatically just before a filesystem is unmounted? Via a mount option or systemd or anything else?

1

1 Answer 1

1

rename /bin/umount to /bin/umount.real

Write a script which runs the commands you want to call before unmounting and then call /bin/umount.real

create a soft link to your script as /bin/umount

2
  • 1
    Is there any guaranty that every program that will unmount a filesystem uses /bin/unmount? Or might some programs (like systemd for example) use a umount system call internally? Commented Apr 23, 2015 at 10:54
  • 1
    No, there is no guarantee. if an app has been programmed to call umount(), then this method will fail. Commented Apr 23, 2015 at 11:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.