Mount fuse.mergerfs in udev script
I use a udev rule to recognize when a specific USB stick is plugged. When it's plugged in, a bash script is started which mounts some devices. That works very well after I did some changes to the systemd-udev service as described here.
However, one of the mounts fail. It is a fuse-mergerfs mount. The command itself seems to succeed, but when doing an ls
on the mount folder I get a strange output and I cannot access the folder:
d????????? ? ? ? ? ? mountpoint
But if I run the mount command manually from the terminal everything is fine.
It also doesn't matter if the stick is plugged in during boot or if I plug it in after the system has already started. Mounting the fuse-mergerfs device does not work when mount
is called by the udev script.
Do you have any ideas?
systemd udev unionfs
add a comment |
I use a udev rule to recognize when a specific USB stick is plugged. When it's plugged in, a bash script is started which mounts some devices. That works very well after I did some changes to the systemd-udev service as described here.
However, one of the mounts fail. It is a fuse-mergerfs mount. The command itself seems to succeed, but when doing an ls
on the mount folder I get a strange output and I cannot access the folder:
d????????? ? ? ? ? ? mountpoint
But if I run the mount command manually from the terminal everything is fine.
It also doesn't matter if the stick is plugged in during boot or if I plug it in after the system has already started. Mounting the fuse-mergerfs device does not work when mount
is called by the udev script.
Do you have any ideas?
systemd udev unionfs
add a comment |
I use a udev rule to recognize when a specific USB stick is plugged. When it's plugged in, a bash script is started which mounts some devices. That works very well after I did some changes to the systemd-udev service as described here.
However, one of the mounts fail. It is a fuse-mergerfs mount. The command itself seems to succeed, but when doing an ls
on the mount folder I get a strange output and I cannot access the folder:
d????????? ? ? ? ? ? mountpoint
But if I run the mount command manually from the terminal everything is fine.
It also doesn't matter if the stick is plugged in during boot or if I plug it in after the system has already started. Mounting the fuse-mergerfs device does not work when mount
is called by the udev script.
Do you have any ideas?
systemd udev unionfs
I use a udev rule to recognize when a specific USB stick is plugged. When it's plugged in, a bash script is started which mounts some devices. That works very well after I did some changes to the systemd-udev service as described here.
However, one of the mounts fail. It is a fuse-mergerfs mount. The command itself seems to succeed, but when doing an ls
on the mount folder I get a strange output and I cannot access the folder:
d????????? ? ? ? ? ? mountpoint
But if I run the mount command manually from the terminal everything is fine.
It also doesn't matter if the stick is plugged in during boot or if I plug it in after the system has already started. Mounting the fuse-mergerfs device does not work when mount
is called by the udev script.
Do you have any ideas?
systemd udev unionfs
systemd udev unionfs
asked Jan 28 at 18:17
BiggieBiggie
20828
20828
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
[Using RUN in udev rules] is only suitable for short-lived scripts, as they will be killed if they are stil running after a timeout period.
I.e. the FUSE background process that implements your filesystem gets killed.
One alternative that comes to mind: if you have the systemd-mount
command, you could try using that in place of your mount
command. It will create a transient .mount
unit (as opposed to a .service
unit), and run the mount
program inside that unit.
The source I am quoting tries to provide a more general solution for long-running processes:
https://yakking.branchable.com/posts/systemd-2-udevd/
If you need a longer-running service, then you should integrate it
with a systemd unit, by defining the unit like:
cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
And add
ENV{SYSTEMD_WANTS}="my-service@%k.service"
to the udev rule.
This will run /path/to/your/script and pass it the path to the device
that has just appeared.
Unfortunately the above instructions are not correct for your case.
Your problem is not that your script itself took too long before returning. The problem is that your script returns after starting a "background process"; the process that implements your FUSE filesystem. When the script finishes, systemd
thinks it needs to clean up, and kill all the left-over processes which were started by the script.
This case is very similar to a legacy sysvinit script. So we can use the same solution they do:
When you write a systemd service to mount
a FUSE filesystem, do not use Type=simple
or Type=oneshot
. Use Type=forking
instead.
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
|
show 5 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497266%2fmount-fuse-mergerfs-in-udev-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
[Using RUN in udev rules] is only suitable for short-lived scripts, as they will be killed if they are stil running after a timeout period.
I.e. the FUSE background process that implements your filesystem gets killed.
One alternative that comes to mind: if you have the systemd-mount
command, you could try using that in place of your mount
command. It will create a transient .mount
unit (as opposed to a .service
unit), and run the mount
program inside that unit.
The source I am quoting tries to provide a more general solution for long-running processes:
https://yakking.branchable.com/posts/systemd-2-udevd/
If you need a longer-running service, then you should integrate it
with a systemd unit, by defining the unit like:
cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
And add
ENV{SYSTEMD_WANTS}="my-service@%k.service"
to the udev rule.
This will run /path/to/your/script and pass it the path to the device
that has just appeared.
Unfortunately the above instructions are not correct for your case.
Your problem is not that your script itself took too long before returning. The problem is that your script returns after starting a "background process"; the process that implements your FUSE filesystem. When the script finishes, systemd
thinks it needs to clean up, and kill all the left-over processes which were started by the script.
This case is very similar to a legacy sysvinit script. So we can use the same solution they do:
When you write a systemd service to mount
a FUSE filesystem, do not use Type=simple
or Type=oneshot
. Use Type=forking
instead.
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
|
show 5 more comments
[Using RUN in udev rules] is only suitable for short-lived scripts, as they will be killed if they are stil running after a timeout period.
I.e. the FUSE background process that implements your filesystem gets killed.
One alternative that comes to mind: if you have the systemd-mount
command, you could try using that in place of your mount
command. It will create a transient .mount
unit (as opposed to a .service
unit), and run the mount
program inside that unit.
The source I am quoting tries to provide a more general solution for long-running processes:
https://yakking.branchable.com/posts/systemd-2-udevd/
If you need a longer-running service, then you should integrate it
with a systemd unit, by defining the unit like:
cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
And add
ENV{SYSTEMD_WANTS}="my-service@%k.service"
to the udev rule.
This will run /path/to/your/script and pass it the path to the device
that has just appeared.
Unfortunately the above instructions are not correct for your case.
Your problem is not that your script itself took too long before returning. The problem is that your script returns after starting a "background process"; the process that implements your FUSE filesystem. When the script finishes, systemd
thinks it needs to clean up, and kill all the left-over processes which were started by the script.
This case is very similar to a legacy sysvinit script. So we can use the same solution they do:
When you write a systemd service to mount
a FUSE filesystem, do not use Type=simple
or Type=oneshot
. Use Type=forking
instead.
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
|
show 5 more comments
[Using RUN in udev rules] is only suitable for short-lived scripts, as they will be killed if they are stil running after a timeout period.
I.e. the FUSE background process that implements your filesystem gets killed.
One alternative that comes to mind: if you have the systemd-mount
command, you could try using that in place of your mount
command. It will create a transient .mount
unit (as opposed to a .service
unit), and run the mount
program inside that unit.
The source I am quoting tries to provide a more general solution for long-running processes:
https://yakking.branchable.com/posts/systemd-2-udevd/
If you need a longer-running service, then you should integrate it
with a systemd unit, by defining the unit like:
cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
And add
ENV{SYSTEMD_WANTS}="my-service@%k.service"
to the udev rule.
This will run /path/to/your/script and pass it the path to the device
that has just appeared.
Unfortunately the above instructions are not correct for your case.
Your problem is not that your script itself took too long before returning. The problem is that your script returns after starting a "background process"; the process that implements your FUSE filesystem. When the script finishes, systemd
thinks it needs to clean up, and kill all the left-over processes which were started by the script.
This case is very similar to a legacy sysvinit script. So we can use the same solution they do:
When you write a systemd service to mount
a FUSE filesystem, do not use Type=simple
or Type=oneshot
. Use Type=forking
instead.
[Using RUN in udev rules] is only suitable for short-lived scripts, as they will be killed if they are stil running after a timeout period.
I.e. the FUSE background process that implements your filesystem gets killed.
One alternative that comes to mind: if you have the systemd-mount
command, you could try using that in place of your mount
command. It will create a transient .mount
unit (as opposed to a .service
unit), and run the mount
program inside that unit.
The source I am quoting tries to provide a more general solution for long-running processes:
https://yakking.branchable.com/posts/systemd-2-udevd/
If you need a longer-running service, then you should integrate it
with a systemd unit, by defining the unit like:
cat >/etc/systemd/system/my-service@.service <<'EOF'
[Unit]
Description=My Service
[Service]
Type=simple
ExecStart=/path/to/your/script %I
EOF
And add
ENV{SYSTEMD_WANTS}="my-service@%k.service"
to the udev rule.
This will run /path/to/your/script and pass it the path to the device
that has just appeared.
Unfortunately the above instructions are not correct for your case.
Your problem is not that your script itself took too long before returning. The problem is that your script returns after starting a "background process"; the process that implements your FUSE filesystem. When the script finishes, systemd
thinks it needs to clean up, and kill all the left-over processes which were started by the script.
This case is very similar to a legacy sysvinit script. So we can use the same solution they do:
When you write a systemd service to mount
a FUSE filesystem, do not use Type=simple
or Type=oneshot
. Use Type=forking
instead.
edited Feb 2 at 16:53
answered Jan 28 at 18:52
sourcejedisourcejedi
24.1k439106
24.1k439106
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
|
show 5 more comments
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
It doesn't look like it's killed. E.g. if I add a sleep to the script, the PC hangs for that amount of time during boot. So, the timeout seems to be high enough.However, I tried it with a systemd service. It executes my script, too. And again, all mounts work, except for the fuse.mergerfs mount. This time, no weird "????" are shown, but the device is mounted neither.
– Biggie
Jan 29 at 16:34
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
@Biggie regarding the second part only: only FUSE mounts require a long-running process. If none of the other mounts are FUSE mounts, that would explain the difference.
– sourcejedi
Jan 29 at 16:44
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
I do not get any error message. The mount command succeeds with exit code 0 :)
– Biggie
Jan 29 at 16:56
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
"I cannot access the folder". What error message do you get when you try to access the folder?
– sourcejedi
Jan 29 at 16:57
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
It shows "Der Socket ist nicht verbunden". In english something like: "Socket ist not connected" or maybe "Transport endpoint" instead of socket ;)
– Biggie
Jan 29 at 17:01
|
show 5 more comments
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497266%2fmount-fuse-mergerfs-in-udev-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown