Can't automount USB stick with Fedora 21+systemd-udev, could with Gentoo on same machine
In Gentoo I had created a small script that was called by udev and allowed me to mount an USB device, identified by its serial number, to any mount point I chose.
Basically, /etc/udev/rules.d/00-removable.rules contains
SUBSYSTEM=="block", ACTION=="add", KERNEL=="sd[b-z]*", RUN+="/usr/local/bin/mountRemovableMedia.sh %k"
and my mountRemovableMedia.sh script uses the device parameter passed to determine the device serial, and then mount it to the mount point I want.
Now, in F21, with systemd, it doesn't work. The script is called (I have a log file written to by the script), the mount command is performed (returns 0, no error), but the actual mount doesn't happen: if I type 'mount' in a terminal, I can't see the device, and if I cd to its mountpoint the directory is empty.
I tried changing mount to udisksctl mount --block-device ... but it still doesn't work.
linux usb-flash-drive fedora udev systemd
add a comment |
In Gentoo I had created a small script that was called by udev and allowed me to mount an USB device, identified by its serial number, to any mount point I chose.
Basically, /etc/udev/rules.d/00-removable.rules contains
SUBSYSTEM=="block", ACTION=="add", KERNEL=="sd[b-z]*", RUN+="/usr/local/bin/mountRemovableMedia.sh %k"
and my mountRemovableMedia.sh script uses the device parameter passed to determine the device serial, and then mount it to the mount point I want.
Now, in F21, with systemd, it doesn't work. The script is called (I have a log file written to by the script), the mount command is performed (returns 0, no error), but the actual mount doesn't happen: if I type 'mount' in a terminal, I can't see the device, and if I cd to its mountpoint the directory is empty.
I tried changing mount to udisksctl mount --block-device ... but it still doesn't work.
linux usb-flash-drive fedora udev systemd
add a comment |
In Gentoo I had created a small script that was called by udev and allowed me to mount an USB device, identified by its serial number, to any mount point I chose.
Basically, /etc/udev/rules.d/00-removable.rules contains
SUBSYSTEM=="block", ACTION=="add", KERNEL=="sd[b-z]*", RUN+="/usr/local/bin/mountRemovableMedia.sh %k"
and my mountRemovableMedia.sh script uses the device parameter passed to determine the device serial, and then mount it to the mount point I want.
Now, in F21, with systemd, it doesn't work. The script is called (I have a log file written to by the script), the mount command is performed (returns 0, no error), but the actual mount doesn't happen: if I type 'mount' in a terminal, I can't see the device, and if I cd to its mountpoint the directory is empty.
I tried changing mount to udisksctl mount --block-device ... but it still doesn't work.
linux usb-flash-drive fedora udev systemd
In Gentoo I had created a small script that was called by udev and allowed me to mount an USB device, identified by its serial number, to any mount point I chose.
Basically, /etc/udev/rules.d/00-removable.rules contains
SUBSYSTEM=="block", ACTION=="add", KERNEL=="sd[b-z]*", RUN+="/usr/local/bin/mountRemovableMedia.sh %k"
and my mountRemovableMedia.sh script uses the device parameter passed to determine the device serial, and then mount it to the mount point I want.
Now, in F21, with systemd, it doesn't work. The script is called (I have a log file written to by the script), the mount command is performed (returns 0, no error), but the actual mount doesn't happen: if I type 'mount' in a terminal, I can't see the device, and if I cd to its mountpoint the directory is empty.
I tried changing mount to udisksctl mount --block-device ... but it still doesn't work.
linux usb-flash-drive fedora udev systemd
linux usb-flash-drive fedora udev systemd
edited Mar 3 '15 at 21:06
malat
5352923
5352923
asked Dec 24 '14 at 16:55
user3605616user3605616
613
613
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I have had the same problem with a script that worked fine in Fedora 20 and earlier. I think the reason why this does not work any more in Fedora 21 is that udev runs the script with a private mount namespace, although I have not confirmed this.
The workaround I have come up with is the following: Instead of executing the script with udev, I now execute it via a systemd unit.
In detail, I created the following systemd unit file as /etc/systemd/system/mount_device.service:
[Unit]
After=dev-[UUID].device
[Service]
ExecStart=/etc/systemd/scripts/mount_device.sh
[Install]
WantedBy=dev-[UUID].device
where the correct dev-[UUID].device has to be replaced by the right systemd device ID, which can be determined using systemctl --all --full -t device. The unit needs to be enabled by running systemctl enable mount_device.service.
If the script is executed in this way, the mount shows up as expected. The only drawback is that it only works if you know the UUID, label or similar in advance, which might not apply in your case.
too bad there is no such thing as/etc/systemd/scripts/mount_device.shon Debian :(
– malat
Mar 3 '15 at 20:36
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f856477%2fcant-automount-usb-stick-with-fedora-21systemd-udev-could-with-gentoo-on-same%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
I have had the same problem with a script that worked fine in Fedora 20 and earlier. I think the reason why this does not work any more in Fedora 21 is that udev runs the script with a private mount namespace, although I have not confirmed this.
The workaround I have come up with is the following: Instead of executing the script with udev, I now execute it via a systemd unit.
In detail, I created the following systemd unit file as /etc/systemd/system/mount_device.service:
[Unit]
After=dev-[UUID].device
[Service]
ExecStart=/etc/systemd/scripts/mount_device.sh
[Install]
WantedBy=dev-[UUID].device
where the correct dev-[UUID].device has to be replaced by the right systemd device ID, which can be determined using systemctl --all --full -t device. The unit needs to be enabled by running systemctl enable mount_device.service.
If the script is executed in this way, the mount shows up as expected. The only drawback is that it only works if you know the UUID, label or similar in advance, which might not apply in your case.
too bad there is no such thing as/etc/systemd/scripts/mount_device.shon Debian :(
– malat
Mar 3 '15 at 20:36
add a comment |
I have had the same problem with a script that worked fine in Fedora 20 and earlier. I think the reason why this does not work any more in Fedora 21 is that udev runs the script with a private mount namespace, although I have not confirmed this.
The workaround I have come up with is the following: Instead of executing the script with udev, I now execute it via a systemd unit.
In detail, I created the following systemd unit file as /etc/systemd/system/mount_device.service:
[Unit]
After=dev-[UUID].device
[Service]
ExecStart=/etc/systemd/scripts/mount_device.sh
[Install]
WantedBy=dev-[UUID].device
where the correct dev-[UUID].device has to be replaced by the right systemd device ID, which can be determined using systemctl --all --full -t device. The unit needs to be enabled by running systemctl enable mount_device.service.
If the script is executed in this way, the mount shows up as expected. The only drawback is that it only works if you know the UUID, label or similar in advance, which might not apply in your case.
too bad there is no such thing as/etc/systemd/scripts/mount_device.shon Debian :(
– malat
Mar 3 '15 at 20:36
add a comment |
I have had the same problem with a script that worked fine in Fedora 20 and earlier. I think the reason why this does not work any more in Fedora 21 is that udev runs the script with a private mount namespace, although I have not confirmed this.
The workaround I have come up with is the following: Instead of executing the script with udev, I now execute it via a systemd unit.
In detail, I created the following systemd unit file as /etc/systemd/system/mount_device.service:
[Unit]
After=dev-[UUID].device
[Service]
ExecStart=/etc/systemd/scripts/mount_device.sh
[Install]
WantedBy=dev-[UUID].device
where the correct dev-[UUID].device has to be replaced by the right systemd device ID, which can be determined using systemctl --all --full -t device. The unit needs to be enabled by running systemctl enable mount_device.service.
If the script is executed in this way, the mount shows up as expected. The only drawback is that it only works if you know the UUID, label or similar in advance, which might not apply in your case.
I have had the same problem with a script that worked fine in Fedora 20 and earlier. I think the reason why this does not work any more in Fedora 21 is that udev runs the script with a private mount namespace, although I have not confirmed this.
The workaround I have come up with is the following: Instead of executing the script with udev, I now execute it via a systemd unit.
In detail, I created the following systemd unit file as /etc/systemd/system/mount_device.service:
[Unit]
After=dev-[UUID].device
[Service]
ExecStart=/etc/systemd/scripts/mount_device.sh
[Install]
WantedBy=dev-[UUID].device
where the correct dev-[UUID].device has to be replaced by the right systemd device ID, which can be determined using systemctl --all --full -t device. The unit needs to be enabled by running systemctl enable mount_device.service.
If the script is executed in this way, the mount shows up as expected. The only drawback is that it only works if you know the UUID, label or similar in advance, which might not apply in your case.
answered Dec 31 '14 at 10:02
Lapse of ReasonLapse of Reason
1
1
too bad there is no such thing as/etc/systemd/scripts/mount_device.shon Debian :(
– malat
Mar 3 '15 at 20:36
add a comment |
too bad there is no such thing as/etc/systemd/scripts/mount_device.shon Debian :(
– malat
Mar 3 '15 at 20:36
too bad there is no such thing as
/etc/systemd/scripts/mount_device.sh on Debian :(– malat
Mar 3 '15 at 20:36
too bad there is no such thing as
/etc/systemd/scripts/mount_device.sh on Debian :(– malat
Mar 3 '15 at 20:36
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f856477%2fcant-automount-usb-stick-with-fedora-21systemd-udev-could-with-gentoo-on-same%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