Page 7 of 9 FirstFirst ... 56789 LastLast
Results 61 to 70 of 84

Thread: Create your own udev rules to control removable devices

  1. #61
    Join Date
    Mar 2008
    Beans
    49

    Re: Create your own udev rules to control removable devices

    Very useful guide, but unforunatly for me it covers mainly storage devices and yet USB attached. I have trouble with my DVB-cards both PCI and USB which change device number with every boot. How can i use this guide in this situation?
    Would be also great to update the guide for current Ubuntu release, means new commands and make it more device generic.

    KR

  2. #62
    Join Date
    Jun 2010
    Beans
    2

    Re: Create your own udev rules to control removable devices

    Quote Originally Posted by zaurus View Post
    Very useful guide, but unforunatly for me it covers mainly storage devices and yet USB attached. I have trouble with my DVB-cards both PCI and USB which change device number with every boot. How can i use this guide in this situation?
    Would be also great to update the guide for current Ubuntu release, means new commands and make it more device generic.

    KR
    You can use other match string, eg.:

    Code:
    root@server:~# cat /etc/udev/rules.d/10-local.rules
    # Mount hdd backup as /dev/sda
    SUBSYSTEMS=="usb",ATTRS{manufacturer}=="Western Digital ",ATTRS{serial}=="574341553434313231343834",KERNEL=="sda",SYMLINK+="sda%n"
    root@server:~#
    Serial is unique.

  3. #63
    Join Date
    Aug 2008
    Beans
    2

    Re: Create your own udev rules to control removable devices

    Hi!

    I've been using something similar on my old 7.04 installation to name fixed SATA hard disks.
    Today I finally decided to upgrade my system to lucid, but my udev rule file does not work anymore. The partitions on the disks get mounted "randomly" to one of the mount points described in fstab.

    I think the problem is that mountall and udev runs concurrently. (mountall runs in daemon mode, so udev starts before mountall is actually done with all of its work) While mountall is still mounting the file systems from the fstab files, udev renames the device nodes and everything gets messed up.

    I use a file in /etc/udev/rules.d named 10-local.rules with the following content:

    SUBSYSTEM=="block", SUBSYSTEMS=="scsi", ATTRS{model}=="SAMSUNG SP2514N ", NAME="sda%n"
    SUBSYSTEM=="block", SUBSYSTEMS=="scsi", ATTRS{model}=="SAMSUNG HD103UJ ", NAME="sdb%n"
    SUBSYSTEM=="block", SUBSYSTEMS=="scsi", ATTRS{model}=="Hitachi HDS72202", NAME="sdc%n"

    I've already tried to modify some .conf files in /etc/init, tried to mount /proc and run udev before mountall starts, run mountall normally instead of daemon mode but nothing helped.

    I hope somebody can help me. Thanks!

  4. #64
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Create your own udev rules to control removable devices

    Just a quick comment, see this:
    https://bugs.launchpad.net/ubuntu/+bug/569645
    It shows my work-arounds.
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

  5. #65
    Join Date
    Jan 2007
    Location
    Ridgeland WI US
    Beans
    464
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Create your own udev rules to control removable devices

    More upgrade papercuts.
    udev rules worked fine for me with Ubuntu 9.04. I had an entry in /etc/fstab for the devices I mount on the usb. I had rules.d with simple one liners to mount the USB device to it's own directory with mode=777 so it was shared as soon as I copied it across.
    Ubuntu 10.04 ended that.
    Now if I put the mount point in /etc/fstab and boot without having the camera card connected I get a stop and wait message that the card was not found, hit a key to continue the boot. When I connect it later it has mode=644, others cannot edit the photos.
    The rules.d rules from before don't work at all, they are ignored.
    So here is the work around I have now.
    I used "Mount under /media; use partition label if present"
    from:
    Udev ArchWiki
    Changing umask to 000, this mounts the device with mode=777 so when I copy it to /Data/Images/somewhere others on the NFS can edit the photos (my spouse ) Problem is only root can unmount it! ArchWiki's pmount did not work for me.
    So to unmount it I added an application launcher to my panel that is just "sudo umount /dev/sdc1". I'm only using one USB card reader at a time so it always gets sdc1 here.
    From a user (me) point of view the only difference is that now to unmount I click on the panel and enter my sudo password rather than the old way of right-click and unmount.
    It works but...
    Anyone got a better solution?
    Gigabyte GA-MA790GPT-UD3H - AMD Phenom II x3 720 - 8 GB RAM - 2009 - My first PC from parts!

  6. #66

    Re: Create your own udev rules to control removable devices

    http://ubuntuforums.org/showthread.php?t=1665278

    Please do help me with this problem. Thank you very much.

  7. #67
    Join Date
    Oct 2010
    Beans
    2

    Re: Create your own udev rules to control removable devices

    Hey I have been having problems for a year with /dev/sdb vs /dev/sdc on reboots. I have filled my disk because my mounted drive had the wrong name. I created different fstabs and created a script that looked for what sd? it mounted as then would overwrite the fstab. It was a stupid solution and worked about half the time. I ran across your tut and it worked. The cool thing is I am on a CENTOS box and your tut worked perfectly except the restarting udev. I googled how to restart it on contos and it worked perfectly.

    I wish I would have found this a year ago. You solved my issue completely so,


    THANK YOU!!!!!

  8. #68
    Join Date
    Jan 2008
    Location
    USA
    Beans
    751
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Create your own udev rules to control removable devices

    udevadm info -a -p $(udevadm info -q path -n /dev/sdb1)

    Udevadm info starts with the device specified by the devpath and then
    walks up the chain of parent devices. It prints for every device
    found, all possible attributes in the udev rules key format.
    A rule to match, can be composed by the attributes of the device
    and the attributes from one single parent device.

    looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2/target2:0:0/2:0:0:0/block/sdb/sdb1':
    KERNEL=="sdb1"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{partition}=="1"
    ATTR{start}=="63"
    ATTR{size}=="2930277104"
    ATTR{ro}=="0"
    ATTR{alignment_offset}=="0"
    ATTR{discard_alignment}=="4294935040"
    ATTR{stat}==" 47 4 408 516 0 0 0 0 0 516 516"
    ATTR{inflight}==" 0 0"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2/target2:0:0/2:0:0:0/block/sdb':
    KERNELS=="sdb"
    SUBSYSTEMS=="block"
    DRIVERS==""
    ATTRS{range}=="16"
    ATTRS{ext_range}=="256"
    ATTRS{removable}=="0"
    ATTRS{ro}=="0"
    ATTRS{size}=="2930277168"
    ATTRS{alignment_offset}=="0"
    ATTRS{discard_alignment}=="0"
    ATTRS{capability}=="50"
    ATTRS{stat}==" 62 30 736 7512 0 0 0 0 0 7512 7512"
    ATTRS{inflight}==" 0 0"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2/target2:0:0/2:0:0:0':
    KERNELS=="2:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="3"
    ATTRS{vendor}=="WD "
    ATTRS{model}=="15EADS External "
    ATTRS{rev}=="1.75"
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{iocounterbits}=="32"
    ATTRS{iorequest_cnt}=="0x6a"
    ATTRS{iodone_cnt}=="0x6a"
    ATTRS{ioerr_cnt}=="0x0"
    ATTRS{evt_media_change}=="0"
    ATTRS{dh_state}=="detached"
    ATTRS{queue_depth}=="1"
    ATTRS{queue_type}=="none"
    ATTRS{max_sectors}=="240"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2/target2:0:0':
    KERNELS=="target2:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2':
    KERNELS=="host2"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0':
    KERNELS=="1-5:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bInterfaceClass}=="08"
    ATTRS{bInterfaceSubClass}=="06"
    ATTRS{bInterfaceProtocol}=="50"
    ATTRS{supports_autosuspend}=="1"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5':
    KERNELS=="1-5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bMaxPower}==" 2mA"
    ATTRS{urbnum}=="326"
    ATTRS{idVendor}=="1058"
    ATTRS{idProduct}=="1003"
    ATTRS{bcdDevice}=="0175"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="2"
    ATTRS{devpath}=="5"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Western Digital "
    ATTRS{product}=="External HDD "
    ATTRS{serial}=="57442D574341565530323937323835"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}==" 0mA"
    ATTRS{urbnum}=="36"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0002"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="480"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="8"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.38-8-generic-pae ehci_hcd"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{serial}=="0000:00:1d.7"
    ATTRS{authorized_default}=="1"

    looking at parent device '/devices/pci0000:00/0000:00:1d.7':
    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci_hcd"
    ATTRS{vendor}=="0x8086"
    ATTRS{device}=="0x27cc"
    ATTRS{subsystem_vendor}=="0x1028"
    ATTRS{subsystem_device}=="0x01bd"
    ATTRS{class}=="0x0c0320"
    ATTRS{irq}=="20"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""
    ATTRS{companion}==""

    looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    How do i use this information?
    Amor cuerdo, no es Amor.

  9. #69
    Join Date
    Jan 2008
    Location
    USA
    Beans
    751
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Create your own udev rules to control removable devices

    I was able to get this working but then it started unmounting itself and would not mount by sudo mount -a. Any help?
    Amor cuerdo, no es Amor.

  10. #70
    Join Date
    Aug 2007
    Beans
    16

    Re: Create your own udev rules to control removable devices

    Im having similar issues to these later posts. It would seem, Natty (11.04) or does not even listen to rules?
    My rule file is 9-probox.rules (VirtualBox already has a 10- rules file in there)
    Here's the content, should work, no?
    SUBSYSTEM=="block", SUBSYSTEMS=="scsi", ATTRS{model}=="HD204UI", MODE="0755"
    But my drives (there are 2 matching this rule, external usb hard drives) still mount as 700 permissions!
    Anyone know why? I'm trying to add media from them to Plex Media Server, and it can not see inside them I'm assuming due to the permissions they mount with.
    Thanks!

Page 7 of 9 FirstFirst ... 56789 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •