3

I use Linux Mint Cinnamon. I'd like to know what command does nemo use to mount drives when you click on an unmounted drive on the explorer sidebar.

I am asking because I need to automount some partitions at startup. I tried several mount option, but none of them mounts exactly how nemo does. Using mount it mounts with either too many permissions, not enough permissions or with ownership problems.

I couldn't figure out what options / command nemo uses, that's why I'm asking.

enter image description here --> enter image description here

  • What happens if you copy the options after you mount through GUI from the output of mount? – wvxvw Sep 25 '17 at 14:20
  • How can I do that? – jack Sep 25 '17 at 14:21
  • when you type mount in terminal, you might see something like gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000) - this is some filesystem mounted in userspace. Then you could open /etc/fstab and copy the corresponding options. – wvxvw Sep 25 '17 at 14:25
  • I see that line, but in fstab there's no correspondence to my ntfs partition, only to my ext4 linux partition. In mount I also see the line /dev/sda3 on /media/user/Storage type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096) which is my mounted partition. Are the stuff in parenthesis the mount options? – jack Sep 25 '17 at 14:34
8

As far as I know (I haven't looked directly at the code for Nemo, but I've seen a lot of other file managers), it's using a call to the UDisks DBus API. You can (probably) replicate the call that Nemo does manually with the command:

udisksctl mount --block-device=/dev/whatever

Which should spit out the path that the device got mounted on (on most systems it will be under /run/media/$USER, with a name matching the volume label (or the volume UUID if it lacks a label).

You can also pass this command the argument --options= to give it custom mount options.

The equivalent to unmount is:

udisksctl unmount --block-device=/dev/whatever

The downside to that approach is that it only works inside a working DBus session, which means it won't work during system startup.

If by 'on startup' you mean 'when I log in', then, you could use the pam_mount PAM module, which would allow you to also mount the filesystem when you log into the console, and will additionally unmount it correctly when you log out. Documentation for that can be found here. This is actually what gets used by most distributions to handle encrypted home directories (at least, traditionally, most of them are slowly migrating to the VFS Crypto API, but that's rather off-topic).

If you instead mean 'when the system boots up' by 'on startup', then you are actually better off not trying to replicate the exact means that Nemo uses to mount the filesystem. A much better approach is to curate the mount options yourself so that it behaves exactly as you want.

You mentioned in the comments that it was a NTFS volume you're trying to mount. Your basic /etc/fstab line for that should look like this (based on info from the comments):

/dev/sda3     /mnt/user/Storage    ntfs-3g    rw,nosuid,nodev,allow_other    0 0

On top of that, you can add other options. Suggestions that aren't used by default by most automounting tools include:

  • windows_names: This will prevent you from creating files you can't access from WIndows because of naming restrictions. Normally, you're not likely to accidentally create such files (most people don't use the restricted characters, and the reserved names are not used most places either), but it provides a nice safety net just in case.
  • hide_dot_files: This will automatically mark files with filenames beginning with a . as hidden, improving consistency between Windows and Linux.
  • hide_hidden_files: This will exclude files with the hidden attribute from being listed in directory listings (even with ls -a). Similar argument to the above option, although I'm not as fond of it myself.
  • streams_interface=xattr: This exposes NTFS alternate data streams as extended attributes, allowing most backup tools to save and restore them correctly.
  • big_writes: This improves write performance for large writes pretty significantly, but has no effect on how the data looks on the partition.

Additionally, you may want to look into getting a user mapping file set up if you use this volume regularly on both WIndows and Linux. That will allow permissions set in one OS to behave correctly in the other. The NTFS-3G manual page (check here) has reasonably good documentation of how to do that in the 'User Mapping' section.

  • +1 for such an elaborate answer. If I accept the answer, it means it solved my problem. I'll have to see. – jack Sep 25 '17 at 19:24
  • 1
    i believe the unmount option for udisksctl is unmount and not umount. Its mentioned in the udisksctl man pages as well. – anurupr Feb 25 '18 at 17:16
  • @anurupr You're correct, that was actually a typo I missed before I submitted the answer, corrected now. – Austin Hemmelgarn Feb 26 '18 at 19:40
  • On some of my GNU/Linux systems (mostly old live CDs), I don't have udisksctl. Instead, I have udisks, which seems to be fairly similar. – TSJNachos117 Feb 26 '18 at 22:45
  • @TSJNachos117 They're essentially the same thing, the name just changed between version 1 and version 2 of UDisks. – Austin Hemmelgarn Feb 27 '18 at 20:41
0

Nemo uses gio.

For example, if you have an unmounted LUKS device under "devices" in Nemo, and the passphrase is previously remembered by your keyring, you can mount it from a terminal without entering the password again.

First you need to know the direct device name for the volume you are trying to mount. You can find this by entering gio mount -li.

For example, if you're looking for a 50GB LUKS encrypted device, you'll see something like this:

Volume(3): 50 GB Encrypted
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'device'
   unix-device: '/dev/dm-3'

Now you can mount the unix-device like so:

gio mount -d /dev/dm-3

Everything as user. No sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.