Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I really REALLY want to learn about UDISKS/UDISKS2 and UDEV. How do I accomplish this? My workstations are all Linux Mint 19.xx Cinnamon. Please don't tell me to "Read The Code."
It seems that every distro has files and parts in different places and might even have some different names for things.
The man pages tell me the details of the various executable components and the configuration files: Here is a button. Push it and this happens. Where do I find explanations for why I might have interest in that button in the first place?
Internet searches offer loads of details, but I'm left to discover which edition of which package for which disto the articles present.
Distro forum search also suffer from the "which edition of {package}" confusion. The revision velocity has far outstripped my ability to read articles in real time.
Why do I want to really REALLY learn this?
I handle a large number of SD cards, thumb/key drives, and other USB connected storage. I want to implement my own controls over
What devices get named;
Where each device gets mounted and mount-point names;
Notifications for events affecting each device;
Processing that happens at device connection & mount;
Processing that happens at device disconnect & unmount;
Logging surrounding all of this;
Other things I haven't thought of yet
{ASIDE}
In ancient times, there used to be a manual called "Theory of Operation," another called "Operations Manual," and another called "Administration Manual." The "Operations Manual" content was mostly like what we see in today's man pages. The "Administration Manual" covered all of the configuration, monitoring, error reporting, and fault analysis.
It is the "Theory of Operation" contents that I simply cannot find. This content explained why the application suite exists, what is supposed to accomplish expressed in the language of the business environment, described the several components of the suite and how they were connected, the interactions among the components, the interactions between the suite and the rest of the running applications.
{/ASIDE}
I'm not certain that any one reply will contain all that you ask for, but in any case I think many would agree that the archlinux wiki pages are often a source of useful information with practical use cases (and further references listed at the bottom of the respective pages)...
Where each device gets mounted and mount-point names;
To answer the first part of that question with respect to automatic "udisks2/desktop" mounting for users...
Quote:
Mount to /media (udisks2)
By default, udisks2 mounts removable drives under the ACL controlled directory /run/media/$USER/. If you wish to mount to /media instead, use this rule:
/etc/udev/rules.d/99-udisks2.rules
# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/VolumeName)
# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName)
# See udisks(8)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"
Quote:
Notifications for events affecting each device;
udisksd communicates with desktop environments via D-BUS (org.freedesktop.UDisks2 service) about storage device related events.
If you want to know about what's going on from a user perspective, you can use the following CLI utilities
...
udisksd communicates with desktop environments via D-BUS (org.freedesktop.UDisks2 service) about storage device related events.
If you want to know about what's going on from a user perspective, you can use the following CLI utilities
Code:
udevadm monitor
Code:
udisksctl monitor
I discovered use of /media/{something} instead of /media/USER/{something} but I appreciate your reply with that detail.
Like I said, I have a couple of bushels of SD cards and thumb drives -- a whole universe of makers and features and such.
I'd really like to understand what default behavior is.
What determines the {something} that becomes the device mount point name?
What is involved to manage the several "usb hub" parts that are my workstations and port replicators and such?
I really want to run my own script to sort out what happens for these devices.
Step 1 -- After the default mount happens, launch my script that will access the device at that mount point, decide if I want different, and make it available (sym link?) somewhere else. After that happens process the device at the newly created somewhere else.
Step 2 -- Take control as early as possible, create my own mount points, then launch my processing script(s) avoiding the dance around the default behavior.
{GRUMBLE}
I find it frustrating that the default processing for SD media and thumb drives seems hidden or otherwise hard to find. As a technical writer, I appreciate that folks are busy writing code instead of end-user/power-user documentation. It is also difficult to document code that is constantly evolving for better or worse.
I also find it frustrating that it appears that the choice or /media/USER/{something} and its derivatives were hard-coded into the utilities rather than some configuration detail.
{/GRUMBLE}
I'd really like to understand what default behavior is.
What determines the {something} that becomes the device mount point name?
If the filesystem has a volume label then that is used. You can set the label as required for each removable media volume you have if desired. IIRC, I think the UUID may be used in other situations.
For example, one of my devices shows up like this...
Code:
/dev/sdb1 on /run/media/dean/T9I11A type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
Code:
sdb 8:16 1 3.7G 0 disk
└─sdb1 8:17 1 3.7G 0 part /run/media/dean/T9I11A
Quote:
I really want to run my own script to sort out what happens for these devices.
Step 1 -- After the default mount happens, launch my script that will access the device at that mount point, decide if I want different, and make it available (sym link?) somewhere else. After that happens process the device at the newly created somewhere else.
Step 2 -- Take control as early as possible, create my own mount points, then launch my processing script(s) avoiding the dance around the default behavior.
If you trully would like to implement some other removable media mounting mechanism, you can inhibit udisks2 (assuming systemd) using
Code:
sudo systemctl stop udisks2.service
Code:
sudo systemctl mask udisks2.service
Now removable media will be ignored, and you can manually mount instead, or employ your own hand-rolled script triggered via udev/systemd. This might be enough to get you started and tweak as you like...
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
I'm a kindred spirit with the OP when it comes to the execrable state of some of the Linux documentation. This isn't first time this week (and it's only Wednesday!) that I've spent hours looking for information needed to complete something that was fairly simple to accomplish using just using the manpages a few years ago. But let's not go there.
Here's what I found works to keep USB devices from getting mounted under "/run/media/$USER/disgustingly-long-UUID" and, instead, mount them under "/media".
(NOTE: I agree with the OP that while these two locations might be great as hard-coded defaults, it should be possible to override them via a user-maintained configuration file.)
Create a udev rule for your device. For the Seagate Backup+ drive I use for big file transfers (giga-sneakernet that I resort to if/when the wifi on my laptop is hosed), that rule looks like:
Ferarri's tip on the "99-udisks2.rule" file moves the mount point out of that /run/media/$USER location to "/media".
When you add the udev rule for your USB device and add the 99-udisks2 rule, I bounced the udev subsystem using:
Code:
udevadm control --exit
udevadm control --start-exec-queue
udevadm control --reload
In addition, I bounced the udisks2 service (via YaST but doing it via the CLI would do the same thing) but this might have been completely unnecessary.
I'm sure that some of the udevadm command sequence might have been unnecessary but it was easier than a full reboot.
Anyway... Now, when I plug in that Seagate device, it's mounted at "/media/backup-plus".
What I have not figured out is how to unmount the USB device when working from a virtual console without using sudo. The Plasma device notifier lets me unmount it without any need for extra permissions.
In the past, my device mounts were being done directly from the udev rule that defined the specific device characteristics by specifying a script in a "RUN+=scriptname" clause in the rule. That hasn't worked since systemd became more insinuated into openSUSE (worked fine through 11.x, though).
I can see the symlink name appear in the "udisksctl monitor" output when I plug in the Seagate drive that that udev rule (above) was configured for. But I fail to see the connection between what the udev rule specifies and how that becomes known to udisks2. There is a "MountPoints" record displayed by "udisksctl monitor" but it's always an empty string. So, somehow, udev and udisks2 are figuring it all out but I'm decidedly not keen on "Then a miracle occurs" type operations on my computer systems. Would it kill the developers to include a document that show a diagram of how this all works? (Linux includes some real kick-booty tools that let you create such documents, ya know. ;^) )
Cheers... Hope this get you closer to what you were looking for.
What I have not figured out is how to unmount the USB device when working from a virtual console without using sudo. The Plasma device notifier lets me unmount it without any need for extra permissions.
You should be able to do this via udisksctl command eg
Code:
udisksctl unmount --block-device /dev/sdb1
Quote:
In the past, my device mounts were being done directly from the udev rule that defined the specific device characteristics by specifying a script in a "RUN+=scriptname" clause in the rule. That hasn't worked since systemd became more insinuated into openSUSE (worked fine through 11.x, though).
This can still be done by disabling (and masking) the udisks2.service, and using a custom systemd service + script as outlined in the post #6 if desired.
Quote:
I can see the symlink name appear in the "udisksctl monitor" output when I plug in the Seagate drive that that udev rule (above) was configured for. But I fail to see the connection between what the udev rule specifies and how that becomes known to udisks2.
I'm not a programmer/developer, but "under the hood" communication between udisksd and udev happens via D-Bus. http://storaged.org/doc/udisks2-api/latest/
and the 'dbus-monitor' command can be used to monitor messages going through this message bus.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by ferrari
You should be able to do this via udisksctl command eg
Code:
udisksctl unmount --block-device /dev/sdb1
This can still be done by disabling (and masking) the udisks2.service, and using a custom systemd service + script as outlined in the post #6 if desired.
I have multiple USB drives in an external enclosure that I used for daily rsyncs that are mounted via fstab (via "LABEL="). I'd hate to discover that disabling udisks2 adversely affects that mounting process. Just getting the UUIDs out of the mount points is a real boon. Using "udisksctl" in a script or, maybe, an alias will suffice for CLI work.
Quote:
I'm not a programmer/developer, but "under the hood" communication between udisksd and udev happens via D-Bus. http://storaged.org/doc/udisks2-api/latest/
and the 'dbus-monitor' command can be used to monitor messages going through this message bus.
Heh, I've always had this sneaking suspicion that D-Bus was going to demand my attention at some time.
I have multiple USB drives in an external enclosure that I used for daily rsyncs that are mounted via fstab (via "LABEL="). I'd hate to discover that disabling udisks2 adversely affects that mounting process. Just getting the UUIDs out of the mount points is a real boon. Using "udisksctl" in a script or, maybe, an alias will suffice for CLI work.
No, udisks specifically ignores devices included in /etc/fstab. Completely different mounting mechanisms. For such administrator-controlled mounts, the umount command is used (with root privileges required).
I'm a kindred spirit with the OP when it comes to the execrable state of some of the Linux documentation. This isn't first time this week (and it's only Wednesday!) that I've spent hours looking for information needed to complete something that was fairly simple to accomplish using just using the manpages a few years ago.
I'd love to DM/PM about documentation sometime.
Quote:
Originally Posted by rnturn
What I have not figured out is how to unmount the USB device when working from a virtual console without using sudo. The Plasma device notifier lets me unmount it without any need for extra permissions.
In the past, my device mounts were being done directly from the udev rule that defined the specific device characteristics by specifying a script in a "RUN+=scriptname" clause in the rule. That hasn't worked since systemd became more insinuated into openSUSE (worked fine through 11.x, though).
Take a look at the ownership and permissions for the drive and its mount point. Then look at the authorities granted to the remote process. Lastly, look at the permissions and authorities to accoumplish mount and unmount. I've made this work in the past by creating uid/gid and Access Control Lists (ACL) for all of the parts and the user running the script at the remote. That user and the script need entries in the sudoers file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.