Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
and don't get any error messages, I have tried inserting a usb stick with the following parameters
Code:
Bus 001 Device 008: ID 18a5:0302 Verbatim, Ltd 32GB Flash Drive
Which I believe should fire the script off when the usb drive is plugged in, I'm pretty sure I had this going once but now it does nothing, what am I doing wrong?
I've scoured the net but cant find anything anywhere, any thoughts/suggestions?
Check your log if the two events happened at the instant.
Or maybe your system have had no time enough to comple insert.sh before remove.sh takes over.
Try: comment the remove.sh line, reload udev, insert, and check by fdisk -l see if the drive is honored. If it is there then you are doing well.
Check your log if the two events happened at the instant.
Or maybe your system have had no time enough to comple insert.sh before remove.sh takes over.
Try: comment the remove.sh line, reload udev, insert, and check by fdisk -l see if the drive is honored. If it is there then you are doing well.
Don't forget to
Hope that helps. Good luck.
m.m.
I've divided the udev rules in to two now as I had a suspicion that the fact there were two in the same rule may have been causing an issue, and yes I had forgotten to make the script executable lol I just facepalmed so hard I now have a sore nose
Soooo current status is the insert detection is working....just need to sort the removal one now
Soooo we have progress....kind of, I have a script that I have now set to +x and it will run manually and do everything I want it to do when I fire the script from a command line however when I add it to the udev rules it doesnt seem to do anything at all now (I did get it to create a folder) what would cause it to be able to run fine from a command line but not from the udev rule?.
I have got this working on the box in question and have tried adding my scripts to this rule, on it's own it works perfectly and mounts the USB stick in the media folder in a folder it creates with the same name as the usb stick label, yet when I add my scripts to this they still dont "fire"
Code:
KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# Exit
LABEL="media_by_label_auto_mount_end"
I assumed it would be a simple matter of adding my scripts to the end of the "mount the device" line and the end of the "clean up after removal" line but nooooooo it's not that simple, so I have a script /etc/blah/blah.sh that I would like to run when the drive has mounted, where would I add it in here and what permissions would it need (it already has +x)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.