LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 02-26-2016, 12:38 AM   #1
hardikgohil1988
Member
 
Registered: Sep 2014
Posts: 63

Rep: Reputation: Disabled
udev rules


I am working on Customized CPU which have on-board 2 USB ports.

To mount it automatically I am using udev rules to achieve this.Following is the rule

Code:
ACTION=="add", KERNEL=="sd[a-z]?", NAME="%k", SYMLINK+="usb-%n", GROUP="users", OPTIONS+="last_rule"
ACTION=="add", KERNEL=="sd[a-z]?", RUN+="/bin/mkdir -p /mnt/usb", RUN+="/bin/mount -t vfat -o rw,flush /dev/%k /mnt/usb"
ACTION=="remove", KERNEL=="sd[a-z]?", RUN+="/bin/umount -l /mnt/usb"
ACTION=="remove", KERNEL=="sd[a-z]?", RUN+="/bin/rmdir /mnt/usb", OPTIONS+="last_rule"
USB ports are on BUS1 and BUS2.

how can I change the rule such that when USB device is connected on bus1 it should be mounted on USB1 and bus 2 USB2.

There is one variable from udevadm /dev/sda1
ATTRS{busnum}=="1".How to use this ?
 
Old 02-26-2016, 07:35 PM   #2
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
It has been a while since I wrote a udev rule. I always look at a linux box's udev rules for examples.
 
Old 02-28-2016, 10:15 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,906
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Member Response

Hi,

Maybe these links will help;
Quote:
From http://wiki.linuxquestions.org/wiki/...21.27.27.27.22

-- UDEV:
Udev: Introduction to Device Management In Modern Linux System <- 'Udev supplies a dynamic device directory containing only the nodes for devices which are connected to the system. It creates or removes the device node files in the /dev directory as they are plugged in or taken out.'
Writing udev rules <- 'This document assumes that you have udev installed and running OK with default configurations. This is usually handled by your Linux distribution.'
Persistent block device naming <- 'This article describes how to use persistent names for your block devices. This has been made possible by the introduction of udev and has some advantages over bus-based naming.'
-- Device Mapper:
Right To Your Own Devices <- By Kapil Hari Paranjape Great device mapper article
-- ACPI:
How to suspend and hibernate a laptop under Linux <- Good article
Suspend2 <- 'is most easily described as the Linux equivalent of M$Windows' hibernate functionality'. 'The installation and configuration of suspend2 are documented in detail in this HOWTO'
LessWatts.org <-'LessWatts is about creating a community around saving power on Linux, bringing developers, users, and sysadmins together to share software, optimizations, and tips and tricks.'
Hope this helps.
Have fun & enjoy!
 
Old 03-02-2016, 01:58 AM   #4
hardikgohil1988
Member
 
Registered: Sep 2014
Posts: 63

Original Poster
Rep: Reputation: Disabled
I am trying to pass attr{busnum} to script located in /etc/init.d/mount

Code:
ACTION=="add", KERNEL=="sd[a-z]?", NAME="%k", SYMLINK+="usb-%n", GROUP="users", OPTIONS+="last_rule"
ACTION=="add", KERNEL=="sd[a-z]?", RUN+="/etc/init.d/mount '$attr{busnum}'"
ACTION=="remove", KERNEL=="sd[a-z]?", RUN+="/bin/umount -l /mnt/usb"
ACTION=="remove", KERNEL=="sd[a-z]?", RUN+="/bin/rmdir /mnt/usb", OPTIONS+="last_rule"
mount script:

echo "bus number is $1"

when usb is added mount script doesn't print the busnum.

How can i Do this ?

Last edited by hardikgohil1988; 03-02-2016 at 01:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /etc/udev/rules.d/70-persistent-net.rules and 'ip link' rename rakeafake Linux - Networking 4 02-01-2016 09:34 PM
RKHunter ASCII text in /dev/.udev/rules.d/root.rules metrx Linux - Security 2 03-07-2014 09:37 AM
Slack 13.1 : /etc/udev/rules.d70-persistent-net.rules Ramurd Slackware 10 02-18-2011 10:56 AM
cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or directory rcg1984 Linux From Scratch 2 09-17-2008 08:02 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 04:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 05:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration