[systemd-devel] udev device mapper rules for early boot?

Colin Guthrie gmane at colin.guthr.ie
Wed Dec 12 05:17:38 PST 2012


'Twas brillig, and Nikolaus Rath at 11/12/12 17:52 did gyre and gimble:
> On 12/11/2012 09:47 AM, Colin Guthrie wrote:
>> 'Twas brillig, and Nikolaus Rath at 11/12/12 16:31 did gyre and gimble:
>>> On 12/11/2012 03:00 AM, Colin Guthrie wrote:
>>>> 'Twas brillig, and Nikolaus Rath at 10/12/12 19:03 did gyre and gimble:
>>>>> Hello,
>>>>>
>>>>> I have created a udev rule to set the owner of a specific block device:
>>>>>
>>>>> SUBSYSTEM=="block",
>>>>> ENV{DM_UUID}=="LVM-yYuoI8k05GWxZnz9BeEIwPUGGeojzF3dZZmXTYRqC051Tllj76OHdDlzYhKZUu7u",
>>>>> OWNER="1000"
>>>>>
>>>>> If I disable and re-enable this logical volume with lvchange, it gets
>>>>> created with the correct owner.
>>>>>
>>>>> However, when I boot the computer, the device is always owned by
>>>>> root:disk instead.
>>>>>
>>>>> I checked my initrd, and the rule is present in lib/udev/rules.d as
>>>>> 99-udev-custom.rules.
>>>>>
>>>>> Does anyone have a suggestion of how I could debug this further? Why is
>>>>> my rule ignored when the volume comes up the first time?
>>>> Random guess: does that user exist in the context of the initrd?
>>> No. But that shouldn't be a problem. The other rules in the initrd also
>>> refer to non-existing users (e.g. disk).
>> Are you sure that "disk" is the user here and not the group? Keep in
>> mind that dracut copies /etc/group to the initrd but only includes a cut
>> down /etc/passwd with just root and nobody defined...
> Yes, it's the group rather than the user. But no, that doesn't make a
> difference. My initrd has neither /etc/group nor /etc/passwd. I'm using
> Debian, so it's created with initramfs-tools rather than Dracut.

Hmm, OK, bang goes that theory then :)

>>> I guess udev just waits until
>>> passwd becomes available. Also, I tried specifying the UID instead of
>>> the name, but that didn't help either.
>> I don't think udev "waits until passwd becomes available". It's just a
>> hit and hope effort AFAIUI.
>>
>> You'll need to teach your initrd about your user if you want it to be
>> owned by your user (i.e. somehow modify the dracut module
>> modules.d/99base/module-setup.sh or better add a new module "99myuser"
>> or whatever, that is just a basic stub that just adds your user - that
>> way your change survives distro updates).
> If that's the problem, why doesn't it help to specify the uid?

I dunno, I would have suggested that perhaps udev does a getent or
something before using UIDs or names, but if the whole disk thing works
fine (and it's definitely fine *in* the initrd and it's not just getting
reinitialised before you can look at it in the real system - the only
way to check this would be to put a shell/break in the initrd and
inspect before doing the pivot root. dracut has rd.break= arguments but
dunno what you'll have with initramfs-tools), then I'm out of ideas.

Col




-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list