Question about udev Rules File?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question about udev Rules File?
# 1  
Old 11-05-2014
Question about udev Rules File?

Hello All,

I found this site here: AndDiSa Android Blog: Nexus 7 MTP automount on OpenSuse 11.4

That sites explains how to mount an Android device that can only connect to a computer using MTP or PTP instead of what it used
to get treated as, which was a Mass Storage Device.

In my Rules file for this I have 2 Android Cell phones configured. And I think I got it working correctly... When I connect either of my
Android devices to my laptop with a USB cable they do Auto-mount to the given directory correctly.

My question is about unmounting the devices. In the rules file it seems like you just unplug the phone and it does a "fusermount -u /dir".
But if you unplug the device before you unmount it, isn't that not a good thing? Or is MTP different from unmounting a HDD and it
won't cause any issues like data loss, corruption, etc...?

Here is my "/etc/udev/rules.d/50-android.rules" Rules File:
Code:
################################################## Motorola DROID Razr ##################################################
# DROID RAZR 16GB MTP mode (multimedia device)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e62", MODE="0666" # MTP media

 # DROID RAZR MTP mode : automatic mount when plugged in
ENV{ID_MODEL}=="XT926", ENV{ID_MODEL_ID}=="2e62", ACTION=="add", RUN+="/usr/bin/sudo /usr/bin/go-mtpfs /mnt/DROID_Razr"

 # DROID RAZR MTP mode : automatic unmount when unplugged
ENV{ID_MODEL}=="XT926", ENV{ID_MODEL_ID}=="2e62", ACTION=="remove", RUN+="/usr/bin/fusermount -u /mnt/DROID_Razr"



################################################## Motorola DROID Turbo ##################################################
# DROID Turbo 64GB MTP mode (multimedia device)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2ea4", MODE="0666" # MTP media

 # DROID Turbo MTP mode : automatic mount when plugged in
ENV{ID_MODEL}=="XT1254", ENV{ID_MODEL_ID}=="2ea4", ACTION=="add", RUN+="/usr/bin/sudo /usr/bin/go-mtpfs /mnt/DROID_Turbo"

 # DROID Turbo MTP mode : automatic unmount when unplugged
ENV{ID_MODEL}=="XT1254", ENV{ID_MODEL_ID}=="2ea4", ACTION=="remove", RUN+="/usr/bin/fusermount -u /mnt/DROID_Turbo"

If this helps with my unmounting question, here is what mtab looks like when I attach the 1st one from the rules file:
Code:
Locked(DeviceFs(XT12 on /mnt/DROID_Razr type  fuse.Locked(DeviceFs(XT12  (rw,nosuid,nodev,relatime,user_id=0,group_id=0)

Also, besides that unmount question I was wondering how I could set this up so when the device is mounted it is owned by my
user and NOT root. Is that something I setup in the /etc/sudoers file?


Here is what the directory looks like in a terminal (*as my user and as root):
Code:
# ls -l
d????????? ? ?       ?         ?            ? DROID_Razr

# sudo ls -l
myusername password: 
drwxr-xr-x 0 root    root      0 Dec 31  1969 DROID_Razr

Any thoughts or suggestions would be greatly appreciated!

Thanks in Advance,
Matt
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fdisk and grep command not working in udev trigger

Hi Guys, Can someone take a look at my scripts what missing, plugin usb drive the script is running can log all my echo but cannot execute command. Is there any configuration in linux or to my scripts need to add?. What i want to achieve is every time I plugin the usbdisk automatic mount to... (21 Replies)
Discussion started by: lxdorney
21 Replies

2. Solaris

[Solved] Question changing timezone rules / zic

Dear, One of our customer which is located in Iraq/Baghdad, has informed us about a official change in daylight saving time in few days later and has asked us to fix this issue. So, the current timezone of that system is set as 'Asia/Baghdad' which is correct. however to fix the issue I went... (0 Replies)
Discussion started by: Anti_Evil
0 Replies

3. Shell Programming and Scripting

udev rules for mounting CDROM

Hi All, I need a simple udev rules in my server Centos 5.4. This rules needs to get trigger my script whenever the cdrom is attached to the server. Could you please provide your suggestion on it. Thanks, Kalai (0 Replies)
Discussion started by: kalpeer
0 Replies

4. Ubuntu

FAQ adding rules in udev for my usb 8G to autorun rsync

Hi, I would like to ask if someone knows and show/point me or simple help me how udev rules work in lucyd, upon my quest and search all the tuts i used is based on old udev since something i read the udev change in lucyd version.. I want to accomplised when i plug my usb 8Gb device and automount... (0 Replies)
Discussion started by: jao_madn
0 Replies

5. Linux

Error: Retrigger failed udev events in Fedora 14!

Hi everybody! I installed Fedora 14 from dvd iso file (3.3 GB). But after that, when i enter command init 3 or init 5 an error occurs: "retrigger failed udev events". Who has experienced pls give me some suggestions. Tks so much! Ok now I can use graphic mode. The first time, I use 256MB for... (0 Replies)
Discussion started by: nguyendu0102
0 Replies

6. Shell Programming and Scripting

Pass params with Udev

Hello! I'm sorry if this is the false Forum, didn't really knew where to put it... My question: I have serveral USB-Sticks and wrote several Udev-Rules for theme, each Sticks needs to do something else, but all are using the same script (they have common tasks to do) and only some parts are... (2 Replies)
Discussion started by: al0x
2 Replies

7. Post Here to Contact Site Administrators and Moderators

Rules and mods question

DukeNuke2 posted the following: The person DukeNuke2 was addressing this to was someone that was advising a poster to "Rule 11: Post questions with descriptive subjects." and to use code tags in the post. Are we not supposed to help each other get better responses? If someone posts... (1 Reply)
Discussion started by: Ikon
1 Replies

8. Linux

udev core 5

installed fedora core 5 on a pc with USB and some usual things. in boot up it is stopped at "Starting udev:". Its harddisk light is busy. is it reconfiguring the kernel?. what do to solve this problem?. (0 Replies)
Discussion started by: GJ2
0 Replies
Login or Register to Ask a Question