[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help with udev trigger



	Hi.

On Fri, May 18, 2018 at 09:26:47AM +0100, Bhasker C V wrote:
> Hi,
> 
>  Version: buster
>  I do a manual cryptsetup to create my home directory after system boots up
>  I want to run fsck every time the device node is created from luks
> 
>  I added this udev rule
> 
> ACTION="change",DEVTYPE="disk",ID_FS_UUID="cf1b64cf-7a62-4a43-ad44-6c68f2bbdec5"
> RUN+="/bin/btrfsck /dev/mapper/home"
> 
> But this rule is not getting triggered. Could someone help please to
> point out what mistake I am doing ?

You have five mistakes here, actually:

1) udev rules use C-like syntax for comparison (==) and assingment (=).
Your rule tests nothing, it just assigns some values.

2) All udev 'attributes' have type, and you must specify it.
For instance DEVTYPE and ID_FS_UUID are ENVIRONMENT.

3) 'change' applies to changing device state. It's 'add' for device
creation.

4) RUN should go after a coma.

5) You're not supposed to spawn long-running processes from udev rules
directly. Utilize systemd.


Taking all this into the account, your rule should look like this (one
like, coma separated values):

ACTION=="add", ENV{DEVTYPE}=="disk",ENV{ID_FS_UUID}=="cf1b64cf-7a62-4a43-ad44-6c68f2bbdec5",RUN+="/bin/systemctl start my_brtfs_home_checking.service"

Your custom service file - like this:

[Service]
Type=oneshot
ExecStart=/bin/btrfsck /dev/mapper/home

Reco


Reply to: