LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Udev Ruless (https://www.linuxquestions.org/questions/linux-general-1/udev-ruless-939440/)

vijay496 04-12-2012 07:37 AM

Udev Ruless
 
Hi all,

I am writing a rule so that my usb drive will automatically mount to a point.

Iam new bie to this please help me out to write rules..

I tried somehow like this

created a file by name zzz.rules in /etc/udev/rules.d/
1ST Try
--------------------------------------------------------------------------------
ACTION=="add",KERNEL=="sd?1-9]",SUBSYSTEM=="block",SUBSYSTEMS=="usb",SYMLINK+="vijayPD",RUN+="/bin/mount /dev/vijayPD /mnt"

ACTION=="remove",KERNEL=="sd?1-9]",SUBSYSTEM=="block",SUBSYSTEMS=="usb",RUN+="/bin/umount /mnt"
---------------------------------------------------------------------------------
But not succeded infact the Symlink is getting created but it is not mounting to /mnt

when I manually typed /usr/bin/sudo /bin/mount /dev/vijayPD /mnt it is getting mounted.
---------------------------------------------------------------------------------
2nd try
RUN+="/bin/su root -c /bin/mount /dev/vijayPD /mnt"
RUN+="/bin/su root -c /bin/umount /mnt"
---------------------------------------------------------------------------------
3rd try
RUN+="/usr/bin/sudo /bin/mount /dev/vijayPD /mnt"
RUN+="/usr/bin/sudo /bin/umount /mnt"
---------------------------------------------------------------------------------
I came across some threads mentioning to make use pmount and pumount and tried with it but no luck
4th try
RUN+="/usr/bin/pmount /dev/vijayPD /mnt"
RUN+="/usr/bin/pumount /mnt"
---------------------------------------------------------------------------------
So posting here would help me.

Help me.

Thanks,
VJ

EricTRA 04-13-2012 01:00 AM

Hi,

I've found this link very helpful when I needed to work with udev rules the first time. Hope it helps for you too.

Kind regards,

Eric

catkin 04-13-2012 01:17 AM

The mount command is /sbin/mount, not /bin/mount

BTW, IMHO the remove ACTION should not be required. The umount should happen before the remove or the file system is likely to be damaged.

onebuck 04-13-2012 02:28 PM

Moderator response
 
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of http://www.linuxquestions.org/questi...3/#post4650938


All times are GMT -5. The time now is 09:49 PM.