You are not logged in.

#1 2016-11-12 21:11:03

LeftyAce
Member
Registered: 2012-08-18
Posts: 159

[solved] udisks2: how to restrict certain partitions from automounting

Hi all,

I have my /boot partition on a USB thumbdrive, and I don't want it automounting (because then I have to manually unmount it every time the computer boots up before I can unplug it). I do want other USB devices to automount when they're plugged in.

I'm runnining udiskie (and therefor also udisks2, I think) for automounting USB drives.

I have the following file in /etc/udev/rules.d:

# Ignore boot disk
ENV{ID_FS_UUID}=="fd6f60a7-44c9-418f-8efe-dbcc10629de8"
ENV{UDISKS_AUTO}="0"
ENV{UDISKS_IGNORE}="1"

That prevents the /boot drive from automounting, but it also prevents all other USB devices from automounting! If I uncomment the last line (ENV{UDISKS_IGNORE}="1"), then everything automounts, including the boot disk.

I thought the ENV{ID_FS_UUID} part restricted that rule to apply only to the specified UUID, but it seems to be applying to everything. Any ideas?

Thanks,

Lefty

Last edited by LeftyAce (2016-11-12 22:14:17)

Offline

#2 2016-11-12 21:13:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] udisks2: how to restrict certain partitions from automounting

man udiskie | less -p ignore

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2016-11-12 21:35:24

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [solved] udisks2: how to restrict certain partitions from automounting

Are you sure it's udisks that is automounting the partition and not something else?


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#4 2016-11-12 21:43:32

LeftyAce
Member
Registered: 2012-08-18
Posts: 159

Re: [solved] udisks2: how to restrict certain partitions from automounting

R00KIE, I'm not 100% sure, no. Let me disable udisks and reboot to see.
EDIT: Yes, it's udiskie. If I start udiskie in .xinitrc, then /boot ends up automounting. If I don't start udiskie in .xinitrc, it doesn't automount.

jasonwryan, if I'm translating your response correctly, you're saying "you don't use udev rules for this task, you use udiskie configuration."

If that's correct, I have a follow-up question: how to set the udiskie options? According to the man page:

The file .config/udiskie/config.yml can be used to configure defaults for command line parameters and customize further settings. The actual path may differ depending on $XDG_CONFIG_HOME. The file format is YAML, see http://en.wikipedia.org/wiki/YAML.
If you don’t want to install PyYAML, it is possible to use an equivalent JSON file with the name config.json instead.

Ok, install another package to write a config file? I'd rather not, so I'll try to "use an equivalent JSON file." Can you point me to an example for how those are supposed to be formatted? I'm looking at this page: http://json.org/example.html

And this is what I've cooked up for the udiskie config.json

{
    "ignore_device": {
        "id_uuid": "fd6f60a7-44c9-418f-8efe-dbcc10629de8"
    }
}

When I try to start udiskie, this is what I get:

$ udiskie
udiskie
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/udiskie/cli.py", line 289, in _start_async_tasks
    results = yield self._init()
  File "/usr/lib/python3.5/site-packages/udiskie/cli.py", line 395, in _init
    ignore_device=config.ignore_device,
  File "/usr/lib/python3.5/site-packages/udiskie/config.py", line 265, in ignore_device
    return FilterMatcher(map(IgnoreDevice, config_list), False)
  File "/usr/lib/python3.5/site-packages/udiskie/config.py", line 179, in __init__
    self._filters = list(filters)
  File "/usr/lib/python3.5/site-packages/udiskie/config.py", line 164, in __init__
    config_item = config_item.copy()
AttributeError: 'str' object has no attribute 'copy'

Any ideas what that's about?

Last edited by LeftyAce (2016-11-12 21:50:43)

Offline

#5 2016-11-12 21:53:29

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] udisks2: how to restrict certain partitions from automounting

Your config could look like this (there are examples in the man page) for a yml config:

ignore_device:
- id_uuid: 12345-6789-00000

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2016-11-12 21:54:54

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [solved] udisks2: how to restrict certain partitions from automounting

Let me see if I understand, you have found that udiskie is the apparent culprit but you are blaming and trying to bend udisks2 to do what you want?


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#7 2016-11-12 22:07:14

LeftyAce
Member
Registered: 2012-08-18
Posts: 159

Re: [solved] udisks2: how to restrict certain partitions from automounting

jasonwryan:
It looks like that example is not a working example. If I paste that code directly into config.json, I get this:

$ udiskie
Traceback (most recent call last):
  File "/usr/bin/udiskie", line 11, in <module>
    load_entry_point('udiskie==1.5.1', 'console_scripts', 'udiskie')()
  File "/usr/lib/python3.5/site-packages/udiskie/cli.py", line 243, in main
    return cls(argv).run()
  File "/usr/lib/python3.5/site-packages/udiskie/cli.py", line 209, in __init__
    config = udiskie.config.Config.from_file(config_file)
  File "/usr/lib/python3.5/site-packages/udiskie/config.py", line 237, in from_file
    return cls.from_file(path)
  File "/usr/lib/python3.5/site-packages/udiskie/config.py", line 253, in from_file
    return cls(load(f))
  File "/usr/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

That's what made me think I needed to write a "JSON file," rather than just an ordinary file, and I'm trying to figure out how to do that.

R00KIE, if I understand the arch wiki correctly, udiskie is a "helper" for udisks2, I thought I needed both: https://wiki.archlinux.org/index.php/udisks

I'm not "blaming" anything, just trying to figure out how to configure automount. For example, in the tips and tricks section of the arch wiki on udisks it shows using a udev rule to get disks to mount under /media. That worked for me, so I thought a udev rule would be the right way to configure other aspects of udisks2's behavior.

Apparently that is not the right way to configure it, so any suggestions are much appreciated!

Offline

#8 2016-11-12 22:09:25

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] udisks2: how to restrict certain partitions from automounting

That's because it is not json; it is a yml file, as I said in #5


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#9 2016-11-12 22:13:41

LeftyAce
Member
Registered: 2012-08-18
Posts: 159

Re: [solved] udisks2: how to restrict certain partitions from automounting

Aha, now the lightbulb goes off :-D I renamed that file config.yml, and it works.

I got fooled by this line in the man page:

If you don’t want to install PyYAML, it is possible to use an equivalent JSON file with the name config.json instead.

That made me think that my only options were: install PyYAML, or write an equivalent JSON file. Apparently either I have PyYAML installed already, or it isn't necessary after all.

Bottom line, it works, thank you!

Offline

#10 2016-11-12 22:15:54

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] udisks2: how to restrict certain partitions from automounting

 pacman -Qi udiskie

smile


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#11 2016-11-12 22:16:48

LeftyAce
Member
Registered: 2012-08-18
Posts: 159

Re: [solved] udisks2: how to restrict certain partitions from automounting

Sneaky :-)

Offline

Board footer

Powered by FluxBB