symlink created with udev points to partition instead of drive

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite
1












Here is what I am trying to accomplish with a udev rule. Maybe I need more than one.



I have a micro-sd card I insert into a usb adapter. This card has multiple partitions. I want to have a /dev/sdcard that points to the root of the card when it is inserted. I also want the group of the device to be set to a specific group.



So my card might have /dev/sdd, /dev/sdd1, /dev/sdd2



I want /dev/sdcard to point to /dev/sdd



Here is the rule I am currently using.



ATTRSremovable=="1",SUBSYSTEMS=="block",SYMLINK+="sdcard",GROUP="rawdisk"


I currently see the group of /dev/sdd correctly changed to rawdisk.



$ ls -la /dev/sdd
brw-rw---- 1 root rawdisk 8, 48 Apr 19 14:51 /dev/sdd


However, /dev/sdcard points to /dev/sdd2 instead of /dev/sdd



$ ls -la /dev/sdcard
lrwxrwxrwx 1 root root 4 Apr 19 14:51 /dev/sdcard -> sdd2


And removing the card does not remove /dev/sdcard



$ udevadm info --name=/dev/sdd --attribute-walk

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:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2/block/sdd':
KERNEL=="sdd"
SUBSYSTEM=="block"
DRIVER==""
ATTRro=="0"
ATTRsize=="0"
ATTRstat==" 3815 2182 44808 49392 16 0 128 2028 0 28516 51416"
ATTRrange=="16"
ATTRdiscard_alignment=="0"
ATTRevents=="media_change"
ATTRext_range=="256"
ATTRevents_poll_msecs=="2000"
ATTRalignment_offset=="0"
ATTRinflight==" 0 0"
ATTRremovable=="1"
ATTRcapability=="51"
ATTRevents_async==""

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2':
KERNELS=="4:0:0:2"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRSrev=="1.00"
ATTRStype=="0"
ATTRSscsi_level=="0"
ATTRSmodel=="SD/MMC "
ATTRSstate=="running"
ATTRSqueue_type=="none"
ATTRSiodone_cnt=="0x2ad5"
ATTRSiorequest_cnt=="0x2ad5"
ATTRSdevice_busy=="0"
ATTRSevt_capacity_change_reported=="0"
ATTRStimeout=="30"
ATTRSevt_media_change=="0"
ATTRSmax_sectors=="240"
ATTRSioerr_cnt=="0xf6"
ATTRSqueue_depth=="1"
ATTRSvendor=="Generic-"
ATTRSevt_soft_threshold_reached=="0"
ATTRSdevice_blocked=="0"
ATTRSevt_mode_parameter_change_reported=="0"
ATTRSevt_lun_change_reported=="0"
ATTRSevt_inquiry_change_reported=="0"
ATTRSdh_state=="detached"
ATTRSiocounterbits=="32"
ATTRSinquiry==""
ATTRSeh_timeout=="10"

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0':
KERNELS=="target4:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4':
KERNELS=="host4"
SUBSYSTEMS=="scsi"
DRIVERS==""

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1':
KERNELS=="1-1:1.1"
SUBSYSTEMS=="usb"
DRIVERS=="usb-storage"
ATTRSbInterfaceClass=="08"
ATTRSbInterfaceSubClass=="06"
ATTRSbInterfaceProtocol=="50"
ATTRSbNumEndpoints=="02"
ATTRSauthorized=="1"
ATTRSsupports_autosuspend=="1"
ATTRSbAlternateSetting==" 0"
ATTRSbInterfaceNumber=="01"
ATTRSinterface=="Bulk-In, Bulk-Out, Interface"

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1':
KERNELS=="1-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRSbDeviceSubClass=="00"
ATTRSbDeviceProtocol=="00"
ATTRSdevpath=="1"
ATTRSidVendor=="0bda"
ATTRSspeed=="480"
ATTRSbNumInterfaces==" 2"
ATTRSbConfigurationValue=="1"
ATTRSbMaxPacketSize0=="64"
ATTRSbusnum=="1"
ATTRSdevnum=="3"
ATTRSconfiguration=="CARD READER"
ATTRSbMaxPower=="500mA"
ATTRSauthorized=="1"
ATTRSbmAttributes=="80"
ATTRSbNumConfigurations=="1"
ATTRSmaxchild=="0"
ATTRSbcdDevice=="6123"
ATTRSavoid_reset_quirk=="0"
ATTRSquirks=="0x0"
ATTRSserial=="20070818000000000"
ATTRSversion==" 2.00"
ATTRSurbnum=="126995"
ATTRSltm_capable=="no"
ATTRSmanufacturer=="Generic"
ATTRSremovable=="unknown"
ATTRSidProduct=="0161"
ATTRSbDeviceClass=="00"
ATTRSproduct=="USB2.0-CRW"

looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRSbDeviceSubClass=="00"
ATTRSbDeviceProtocol=="00"
ATTRSdevpath=="0"
ATTRSidVendor=="1d6b"
ATTRSspeed=="480"
ATTRSbNumInterfaces==" 1"
ATTRSbConfigurationValue=="1"
ATTRSbMaxPacketSize0=="64"
ATTRSauthorized_default=="1"
ATTRSbusnum=="1"
ATTRSdevnum=="1"
ATTRSconfiguration==""
ATTRSbMaxPower=="0mA"
ATTRSauthorized=="1"
ATTRSbmAttributes=="e0"
ATTRSbNumConfigurations=="1"
ATTRSmaxchild=="12"
ATTRSinterface_authorized_default=="1"
ATTRSbcdDevice=="0404"
ATTRSavoid_reset_quirk=="0"
ATTRSquirks=="0x0"
ATTRSserial=="0000:00:0b.0"
ATTRSversion==" 2.00"
ATTRSurbnum=="101"
ATTRSltm_capable=="no"
ATTRSmanufacturer=="Linux 4.4.0-116-generic ehci_hcd"
ATTRSremovable=="unknown"
ATTRSidProduct=="0002"
ATTRSbDeviceClass=="09"
ATTRSproduct=="EHCI Host Controller"

looking at parent device '/devices/pci0000:00/0000:00:0b.0':
KERNELS=="0000:00:0b.0"
SUBSYSTEMS=="pci"
DRIVERS=="ehci-pci"
ATTRSirq=="19"
ATTRSsubsystem_vendor=="0x0000"
ATTRSbroken_parity_status=="0"
ATTRSclass=="0x0c0320"
ATTRScompanion==""
ATTRSdriver_override=="(null)"
ATTRSconsistent_dma_mask_bits=="32"
ATTRSdma_mask_bits=="32"
ATTRSlocal_cpus=="f"
ATTRSdevice=="0x265c"
ATTRSuframe_periodic_max=="100"
ATTRSenable=="1"
ATTRSmsi_bus=="1"
ATTRSlocal_cpulist=="0-3"
ATTRSvendor=="0x8086"
ATTRSsubsystem_device=="0x0000"
ATTRSnuma_node=="-1"
ATTRSd3cold_allowed=="0"

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""






share|improve this question
























    up vote
    1
    down vote

    favorite
    1












    Here is what I am trying to accomplish with a udev rule. Maybe I need more than one.



    I have a micro-sd card I insert into a usb adapter. This card has multiple partitions. I want to have a /dev/sdcard that points to the root of the card when it is inserted. I also want the group of the device to be set to a specific group.



    So my card might have /dev/sdd, /dev/sdd1, /dev/sdd2



    I want /dev/sdcard to point to /dev/sdd



    Here is the rule I am currently using.



    ATTRSremovable=="1",SUBSYSTEMS=="block",SYMLINK+="sdcard",GROUP="rawdisk"


    I currently see the group of /dev/sdd correctly changed to rawdisk.



    $ ls -la /dev/sdd
    brw-rw---- 1 root rawdisk 8, 48 Apr 19 14:51 /dev/sdd


    However, /dev/sdcard points to /dev/sdd2 instead of /dev/sdd



    $ ls -la /dev/sdcard
    lrwxrwxrwx 1 root root 4 Apr 19 14:51 /dev/sdcard -> sdd2


    And removing the card does not remove /dev/sdcard



    $ udevadm info --name=/dev/sdd --attribute-walk

    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:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2/block/sdd':
    KERNEL=="sdd"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTRro=="0"
    ATTRsize=="0"
    ATTRstat==" 3815 2182 44808 49392 16 0 128 2028 0 28516 51416"
    ATTRrange=="16"
    ATTRdiscard_alignment=="0"
    ATTRevents=="media_change"
    ATTRext_range=="256"
    ATTRevents_poll_msecs=="2000"
    ATTRalignment_offset=="0"
    ATTRinflight==" 0 0"
    ATTRremovable=="1"
    ATTRcapability=="51"
    ATTRevents_async==""

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2':
    KERNELS=="4:0:0:2"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRSrev=="1.00"
    ATTRStype=="0"
    ATTRSscsi_level=="0"
    ATTRSmodel=="SD/MMC "
    ATTRSstate=="running"
    ATTRSqueue_type=="none"
    ATTRSiodone_cnt=="0x2ad5"
    ATTRSiorequest_cnt=="0x2ad5"
    ATTRSdevice_busy=="0"
    ATTRSevt_capacity_change_reported=="0"
    ATTRStimeout=="30"
    ATTRSevt_media_change=="0"
    ATTRSmax_sectors=="240"
    ATTRSioerr_cnt=="0xf6"
    ATTRSqueue_depth=="1"
    ATTRSvendor=="Generic-"
    ATTRSevt_soft_threshold_reached=="0"
    ATTRSdevice_blocked=="0"
    ATTRSevt_mode_parameter_change_reported=="0"
    ATTRSevt_lun_change_reported=="0"
    ATTRSevt_inquiry_change_reported=="0"
    ATTRSdh_state=="detached"
    ATTRSiocounterbits=="32"
    ATTRSinquiry==""
    ATTRSeh_timeout=="10"

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0':
    KERNELS=="target4:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4':
    KERNELS=="host4"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1':
    KERNELS=="1-1:1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb-storage"
    ATTRSbInterfaceClass=="08"
    ATTRSbInterfaceSubClass=="06"
    ATTRSbInterfaceProtocol=="50"
    ATTRSbNumEndpoints=="02"
    ATTRSauthorized=="1"
    ATTRSsupports_autosuspend=="1"
    ATTRSbAlternateSetting==" 0"
    ATTRSbInterfaceNumber=="01"
    ATTRSinterface=="Bulk-In, Bulk-Out, Interface"

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRSbDeviceSubClass=="00"
    ATTRSbDeviceProtocol=="00"
    ATTRSdevpath=="1"
    ATTRSidVendor=="0bda"
    ATTRSspeed=="480"
    ATTRSbNumInterfaces==" 2"
    ATTRSbConfigurationValue=="1"
    ATTRSbMaxPacketSize0=="64"
    ATTRSbusnum=="1"
    ATTRSdevnum=="3"
    ATTRSconfiguration=="CARD READER"
    ATTRSbMaxPower=="500mA"
    ATTRSauthorized=="1"
    ATTRSbmAttributes=="80"
    ATTRSbNumConfigurations=="1"
    ATTRSmaxchild=="0"
    ATTRSbcdDevice=="6123"
    ATTRSavoid_reset_quirk=="0"
    ATTRSquirks=="0x0"
    ATTRSserial=="20070818000000000"
    ATTRSversion==" 2.00"
    ATTRSurbnum=="126995"
    ATTRSltm_capable=="no"
    ATTRSmanufacturer=="Generic"
    ATTRSremovable=="unknown"
    ATTRSidProduct=="0161"
    ATTRSbDeviceClass=="00"
    ATTRSproduct=="USB2.0-CRW"

    looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRSbDeviceSubClass=="00"
    ATTRSbDeviceProtocol=="00"
    ATTRSdevpath=="0"
    ATTRSidVendor=="1d6b"
    ATTRSspeed=="480"
    ATTRSbNumInterfaces==" 1"
    ATTRSbConfigurationValue=="1"
    ATTRSbMaxPacketSize0=="64"
    ATTRSauthorized_default=="1"
    ATTRSbusnum=="1"
    ATTRSdevnum=="1"
    ATTRSconfiguration==""
    ATTRSbMaxPower=="0mA"
    ATTRSauthorized=="1"
    ATTRSbmAttributes=="e0"
    ATTRSbNumConfigurations=="1"
    ATTRSmaxchild=="12"
    ATTRSinterface_authorized_default=="1"
    ATTRSbcdDevice=="0404"
    ATTRSavoid_reset_quirk=="0"
    ATTRSquirks=="0x0"
    ATTRSserial=="0000:00:0b.0"
    ATTRSversion==" 2.00"
    ATTRSurbnum=="101"
    ATTRSltm_capable=="no"
    ATTRSmanufacturer=="Linux 4.4.0-116-generic ehci_hcd"
    ATTRSremovable=="unknown"
    ATTRSidProduct=="0002"
    ATTRSbDeviceClass=="09"
    ATTRSproduct=="EHCI Host Controller"

    looking at parent device '/devices/pci0000:00/0000:00:0b.0':
    KERNELS=="0000:00:0b.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci-pci"
    ATTRSirq=="19"
    ATTRSsubsystem_vendor=="0x0000"
    ATTRSbroken_parity_status=="0"
    ATTRSclass=="0x0c0320"
    ATTRScompanion==""
    ATTRSdriver_override=="(null)"
    ATTRSconsistent_dma_mask_bits=="32"
    ATTRSdma_mask_bits=="32"
    ATTRSlocal_cpus=="f"
    ATTRSdevice=="0x265c"
    ATTRSuframe_periodic_max=="100"
    ATTRSenable=="1"
    ATTRSmsi_bus=="1"
    ATTRSlocal_cpulist=="0-3"
    ATTRSvendor=="0x8086"
    ATTRSsubsystem_device=="0x0000"
    ATTRSnuma_node=="-1"
    ATTRSd3cold_allowed=="0"

    looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""






    share|improve this question






















      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      Here is what I am trying to accomplish with a udev rule. Maybe I need more than one.



      I have a micro-sd card I insert into a usb adapter. This card has multiple partitions. I want to have a /dev/sdcard that points to the root of the card when it is inserted. I also want the group of the device to be set to a specific group.



      So my card might have /dev/sdd, /dev/sdd1, /dev/sdd2



      I want /dev/sdcard to point to /dev/sdd



      Here is the rule I am currently using.



      ATTRSremovable=="1",SUBSYSTEMS=="block",SYMLINK+="sdcard",GROUP="rawdisk"


      I currently see the group of /dev/sdd correctly changed to rawdisk.



      $ ls -la /dev/sdd
      brw-rw---- 1 root rawdisk 8, 48 Apr 19 14:51 /dev/sdd


      However, /dev/sdcard points to /dev/sdd2 instead of /dev/sdd



      $ ls -la /dev/sdcard
      lrwxrwxrwx 1 root root 4 Apr 19 14:51 /dev/sdcard -> sdd2


      And removing the card does not remove /dev/sdcard



      $ udevadm info --name=/dev/sdd --attribute-walk

      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:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2/block/sdd':
      KERNEL=="sdd"
      SUBSYSTEM=="block"
      DRIVER==""
      ATTRro=="0"
      ATTRsize=="0"
      ATTRstat==" 3815 2182 44808 49392 16 0 128 2028 0 28516 51416"
      ATTRrange=="16"
      ATTRdiscard_alignment=="0"
      ATTRevents=="media_change"
      ATTRext_range=="256"
      ATTRevents_poll_msecs=="2000"
      ATTRalignment_offset=="0"
      ATTRinflight==" 0 0"
      ATTRremovable=="1"
      ATTRcapability=="51"
      ATTRevents_async==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2':
      KERNELS=="4:0:0:2"
      SUBSYSTEMS=="scsi"
      DRIVERS=="sd"
      ATTRSrev=="1.00"
      ATTRStype=="0"
      ATTRSscsi_level=="0"
      ATTRSmodel=="SD/MMC "
      ATTRSstate=="running"
      ATTRSqueue_type=="none"
      ATTRSiodone_cnt=="0x2ad5"
      ATTRSiorequest_cnt=="0x2ad5"
      ATTRSdevice_busy=="0"
      ATTRSevt_capacity_change_reported=="0"
      ATTRStimeout=="30"
      ATTRSevt_media_change=="0"
      ATTRSmax_sectors=="240"
      ATTRSioerr_cnt=="0xf6"
      ATTRSqueue_depth=="1"
      ATTRSvendor=="Generic-"
      ATTRSevt_soft_threshold_reached=="0"
      ATTRSdevice_blocked=="0"
      ATTRSevt_mode_parameter_change_reported=="0"
      ATTRSevt_lun_change_reported=="0"
      ATTRSevt_inquiry_change_reported=="0"
      ATTRSdh_state=="detached"
      ATTRSiocounterbits=="32"
      ATTRSinquiry==""
      ATTRSeh_timeout=="10"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0':
      KERNELS=="target4:0:0"
      SUBSYSTEMS=="scsi"
      DRIVERS==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4':
      KERNELS=="host4"
      SUBSYSTEMS=="scsi"
      DRIVERS==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1':
      KERNELS=="1-1:1.1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb-storage"
      ATTRSbInterfaceClass=="08"
      ATTRSbInterfaceSubClass=="06"
      ATTRSbInterfaceProtocol=="50"
      ATTRSbNumEndpoints=="02"
      ATTRSauthorized=="1"
      ATTRSsupports_autosuspend=="1"
      ATTRSbAlternateSetting==" 0"
      ATTRSbInterfaceNumber=="01"
      ATTRSinterface=="Bulk-In, Bulk-Out, Interface"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1':
      KERNELS=="1-1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb"
      ATTRSbDeviceSubClass=="00"
      ATTRSbDeviceProtocol=="00"
      ATTRSdevpath=="1"
      ATTRSidVendor=="0bda"
      ATTRSspeed=="480"
      ATTRSbNumInterfaces==" 2"
      ATTRSbConfigurationValue=="1"
      ATTRSbMaxPacketSize0=="64"
      ATTRSbusnum=="1"
      ATTRSdevnum=="3"
      ATTRSconfiguration=="CARD READER"
      ATTRSbMaxPower=="500mA"
      ATTRSauthorized=="1"
      ATTRSbmAttributes=="80"
      ATTRSbNumConfigurations=="1"
      ATTRSmaxchild=="0"
      ATTRSbcdDevice=="6123"
      ATTRSavoid_reset_quirk=="0"
      ATTRSquirks=="0x0"
      ATTRSserial=="20070818000000000"
      ATTRSversion==" 2.00"
      ATTRSurbnum=="126995"
      ATTRSltm_capable=="no"
      ATTRSmanufacturer=="Generic"
      ATTRSremovable=="unknown"
      ATTRSidProduct=="0161"
      ATTRSbDeviceClass=="00"
      ATTRSproduct=="USB2.0-CRW"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1':
      KERNELS=="usb1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb"
      ATTRSbDeviceSubClass=="00"
      ATTRSbDeviceProtocol=="00"
      ATTRSdevpath=="0"
      ATTRSidVendor=="1d6b"
      ATTRSspeed=="480"
      ATTRSbNumInterfaces==" 1"
      ATTRSbConfigurationValue=="1"
      ATTRSbMaxPacketSize0=="64"
      ATTRSauthorized_default=="1"
      ATTRSbusnum=="1"
      ATTRSdevnum=="1"
      ATTRSconfiguration==""
      ATTRSbMaxPower=="0mA"
      ATTRSauthorized=="1"
      ATTRSbmAttributes=="e0"
      ATTRSbNumConfigurations=="1"
      ATTRSmaxchild=="12"
      ATTRSinterface_authorized_default=="1"
      ATTRSbcdDevice=="0404"
      ATTRSavoid_reset_quirk=="0"
      ATTRSquirks=="0x0"
      ATTRSserial=="0000:00:0b.0"
      ATTRSversion==" 2.00"
      ATTRSurbnum=="101"
      ATTRSltm_capable=="no"
      ATTRSmanufacturer=="Linux 4.4.0-116-generic ehci_hcd"
      ATTRSremovable=="unknown"
      ATTRSidProduct=="0002"
      ATTRSbDeviceClass=="09"
      ATTRSproduct=="EHCI Host Controller"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0':
      KERNELS=="0000:00:0b.0"
      SUBSYSTEMS=="pci"
      DRIVERS=="ehci-pci"
      ATTRSirq=="19"
      ATTRSsubsystem_vendor=="0x0000"
      ATTRSbroken_parity_status=="0"
      ATTRSclass=="0x0c0320"
      ATTRScompanion==""
      ATTRSdriver_override=="(null)"
      ATTRSconsistent_dma_mask_bits=="32"
      ATTRSdma_mask_bits=="32"
      ATTRSlocal_cpus=="f"
      ATTRSdevice=="0x265c"
      ATTRSuframe_periodic_max=="100"
      ATTRSenable=="1"
      ATTRSmsi_bus=="1"
      ATTRSlocal_cpulist=="0-3"
      ATTRSvendor=="0x8086"
      ATTRSsubsystem_device=="0x0000"
      ATTRSnuma_node=="-1"
      ATTRSd3cold_allowed=="0"

      looking at parent device '/devices/pci0000:00':
      KERNELS=="pci0000:00"
      SUBSYSTEMS==""
      DRIVERS==""






      share|improve this question












      Here is what I am trying to accomplish with a udev rule. Maybe I need more than one.



      I have a micro-sd card I insert into a usb adapter. This card has multiple partitions. I want to have a /dev/sdcard that points to the root of the card when it is inserted. I also want the group of the device to be set to a specific group.



      So my card might have /dev/sdd, /dev/sdd1, /dev/sdd2



      I want /dev/sdcard to point to /dev/sdd



      Here is the rule I am currently using.



      ATTRSremovable=="1",SUBSYSTEMS=="block",SYMLINK+="sdcard",GROUP="rawdisk"


      I currently see the group of /dev/sdd correctly changed to rawdisk.



      $ ls -la /dev/sdd
      brw-rw---- 1 root rawdisk 8, 48 Apr 19 14:51 /dev/sdd


      However, /dev/sdcard points to /dev/sdd2 instead of /dev/sdd



      $ ls -la /dev/sdcard
      lrwxrwxrwx 1 root root 4 Apr 19 14:51 /dev/sdcard -> sdd2


      And removing the card does not remove /dev/sdcard



      $ udevadm info --name=/dev/sdd --attribute-walk

      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:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2/block/sdd':
      KERNEL=="sdd"
      SUBSYSTEM=="block"
      DRIVER==""
      ATTRro=="0"
      ATTRsize=="0"
      ATTRstat==" 3815 2182 44808 49392 16 0 128 2028 0 28516 51416"
      ATTRrange=="16"
      ATTRdiscard_alignment=="0"
      ATTRevents=="media_change"
      ATTRext_range=="256"
      ATTRevents_poll_msecs=="2000"
      ATTRalignment_offset=="0"
      ATTRinflight==" 0 0"
      ATTRremovable=="1"
      ATTRcapability=="51"
      ATTRevents_async==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0/4:0:0:2':
      KERNELS=="4:0:0:2"
      SUBSYSTEMS=="scsi"
      DRIVERS=="sd"
      ATTRSrev=="1.00"
      ATTRStype=="0"
      ATTRSscsi_level=="0"
      ATTRSmodel=="SD/MMC "
      ATTRSstate=="running"
      ATTRSqueue_type=="none"
      ATTRSiodone_cnt=="0x2ad5"
      ATTRSiorequest_cnt=="0x2ad5"
      ATTRSdevice_busy=="0"
      ATTRSevt_capacity_change_reported=="0"
      ATTRStimeout=="30"
      ATTRSevt_media_change=="0"
      ATTRSmax_sectors=="240"
      ATTRSioerr_cnt=="0xf6"
      ATTRSqueue_depth=="1"
      ATTRSvendor=="Generic-"
      ATTRSevt_soft_threshold_reached=="0"
      ATTRSdevice_blocked=="0"
      ATTRSevt_mode_parameter_change_reported=="0"
      ATTRSevt_lun_change_reported=="0"
      ATTRSevt_inquiry_change_reported=="0"
      ATTRSdh_state=="detached"
      ATTRSiocounterbits=="32"
      ATTRSinquiry==""
      ATTRSeh_timeout=="10"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4/target4:0:0':
      KERNELS=="target4:0:0"
      SUBSYSTEMS=="scsi"
      DRIVERS==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/host4':
      KERNELS=="host4"
      SUBSYSTEMS=="scsi"
      DRIVERS==""

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1':
      KERNELS=="1-1:1.1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb-storage"
      ATTRSbInterfaceClass=="08"
      ATTRSbInterfaceSubClass=="06"
      ATTRSbInterfaceProtocol=="50"
      ATTRSbNumEndpoints=="02"
      ATTRSauthorized=="1"
      ATTRSsupports_autosuspend=="1"
      ATTRSbAlternateSetting==" 0"
      ATTRSbInterfaceNumber=="01"
      ATTRSinterface=="Bulk-In, Bulk-Out, Interface"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1/1-1':
      KERNELS=="1-1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb"
      ATTRSbDeviceSubClass=="00"
      ATTRSbDeviceProtocol=="00"
      ATTRSdevpath=="1"
      ATTRSidVendor=="0bda"
      ATTRSspeed=="480"
      ATTRSbNumInterfaces==" 2"
      ATTRSbConfigurationValue=="1"
      ATTRSbMaxPacketSize0=="64"
      ATTRSbusnum=="1"
      ATTRSdevnum=="3"
      ATTRSconfiguration=="CARD READER"
      ATTRSbMaxPower=="500mA"
      ATTRSauthorized=="1"
      ATTRSbmAttributes=="80"
      ATTRSbNumConfigurations=="1"
      ATTRSmaxchild=="0"
      ATTRSbcdDevice=="6123"
      ATTRSavoid_reset_quirk=="0"
      ATTRSquirks=="0x0"
      ATTRSserial=="20070818000000000"
      ATTRSversion==" 2.00"
      ATTRSurbnum=="126995"
      ATTRSltm_capable=="no"
      ATTRSmanufacturer=="Generic"
      ATTRSremovable=="unknown"
      ATTRSidProduct=="0161"
      ATTRSbDeviceClass=="00"
      ATTRSproduct=="USB2.0-CRW"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0/usb1':
      KERNELS=="usb1"
      SUBSYSTEMS=="usb"
      DRIVERS=="usb"
      ATTRSbDeviceSubClass=="00"
      ATTRSbDeviceProtocol=="00"
      ATTRSdevpath=="0"
      ATTRSidVendor=="1d6b"
      ATTRSspeed=="480"
      ATTRSbNumInterfaces==" 1"
      ATTRSbConfigurationValue=="1"
      ATTRSbMaxPacketSize0=="64"
      ATTRSauthorized_default=="1"
      ATTRSbusnum=="1"
      ATTRSdevnum=="1"
      ATTRSconfiguration==""
      ATTRSbMaxPower=="0mA"
      ATTRSauthorized=="1"
      ATTRSbmAttributes=="e0"
      ATTRSbNumConfigurations=="1"
      ATTRSmaxchild=="12"
      ATTRSinterface_authorized_default=="1"
      ATTRSbcdDevice=="0404"
      ATTRSavoid_reset_quirk=="0"
      ATTRSquirks=="0x0"
      ATTRSserial=="0000:00:0b.0"
      ATTRSversion==" 2.00"
      ATTRSurbnum=="101"
      ATTRSltm_capable=="no"
      ATTRSmanufacturer=="Linux 4.4.0-116-generic ehci_hcd"
      ATTRSremovable=="unknown"
      ATTRSidProduct=="0002"
      ATTRSbDeviceClass=="09"
      ATTRSproduct=="EHCI Host Controller"

      looking at parent device '/devices/pci0000:00/0000:00:0b.0':
      KERNELS=="0000:00:0b.0"
      SUBSYSTEMS=="pci"
      DRIVERS=="ehci-pci"
      ATTRSirq=="19"
      ATTRSsubsystem_vendor=="0x0000"
      ATTRSbroken_parity_status=="0"
      ATTRSclass=="0x0c0320"
      ATTRScompanion==""
      ATTRSdriver_override=="(null)"
      ATTRSconsistent_dma_mask_bits=="32"
      ATTRSdma_mask_bits=="32"
      ATTRSlocal_cpus=="f"
      ATTRSdevice=="0x265c"
      ATTRSuframe_periodic_max=="100"
      ATTRSenable=="1"
      ATTRSmsi_bus=="1"
      ATTRSlocal_cpulist=="0-3"
      ATTRSvendor=="0x8086"
      ATTRSsubsystem_device=="0x0000"
      ATTRSnuma_node=="-1"
      ATTRSd3cold_allowed=="0"

      looking at parent device '/devices/pci0000:00':
      KERNELS=="pci0000:00"
      SUBSYSTEMS==""
      DRIVERS==""








      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 19 at 19:14









      uglyoldbob

      62




      62




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          The rule is too generic and matched all the nodes /dev/sdd, /dev/sdd1, /dev/sdd2. It matches the block device and its partitions nodes.



          So udev:



          1. creates a symlink /dev/sdcard → /dev/sdd

          2. and quickly replaces it with /dev/sdcard → /dev/sdd1

          3. then again with /dev/sdcard → /dev/sdd2

          See with this rule:



          ATTRremovable=="1",SUBSYSTEM=="block",DRIVERS=="sd",SYMLINK+="sdcard",GROUP="rawdisk"



          Note, I replaced SUBSYSTEMS,ATTRS with SUBSYSTEM,ATTR.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1026500%2fsymlink-created-with-udev-points-to-partition-instead-of-drive%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            The rule is too generic and matched all the nodes /dev/sdd, /dev/sdd1, /dev/sdd2. It matches the block device and its partitions nodes.



            So udev:



            1. creates a symlink /dev/sdcard → /dev/sdd

            2. and quickly replaces it with /dev/sdcard → /dev/sdd1

            3. then again with /dev/sdcard → /dev/sdd2

            See with this rule:



            ATTRremovable=="1",SUBSYSTEM=="block",DRIVERS=="sd",SYMLINK+="sdcard",GROUP="rawdisk"



            Note, I replaced SUBSYSTEMS,ATTRS with SUBSYSTEM,ATTR.






            share|improve this answer
























              up vote
              0
              down vote













              The rule is too generic and matched all the nodes /dev/sdd, /dev/sdd1, /dev/sdd2. It matches the block device and its partitions nodes.



              So udev:



              1. creates a symlink /dev/sdcard → /dev/sdd

              2. and quickly replaces it with /dev/sdcard → /dev/sdd1

              3. then again with /dev/sdcard → /dev/sdd2

              See with this rule:



              ATTRremovable=="1",SUBSYSTEM=="block",DRIVERS=="sd",SYMLINK+="sdcard",GROUP="rawdisk"



              Note, I replaced SUBSYSTEMS,ATTRS with SUBSYSTEM,ATTR.






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                The rule is too generic and matched all the nodes /dev/sdd, /dev/sdd1, /dev/sdd2. It matches the block device and its partitions nodes.



                So udev:



                1. creates a symlink /dev/sdcard → /dev/sdd

                2. and quickly replaces it with /dev/sdcard → /dev/sdd1

                3. then again with /dev/sdcard → /dev/sdd2

                See with this rule:



                ATTRremovable=="1",SUBSYSTEM=="block",DRIVERS=="sd",SYMLINK+="sdcard",GROUP="rawdisk"



                Note, I replaced SUBSYSTEMS,ATTRS with SUBSYSTEM,ATTR.






                share|improve this answer












                The rule is too generic and matched all the nodes /dev/sdd, /dev/sdd1, /dev/sdd2. It matches the block device and its partitions nodes.



                So udev:



                1. creates a symlink /dev/sdcard → /dev/sdd

                2. and quickly replaces it with /dev/sdcard → /dev/sdd1

                3. then again with /dev/sdcard → /dev/sdd2

                See with this rule:



                ATTRremovable=="1",SUBSYSTEM=="block",DRIVERS=="sd",SYMLINK+="sdcard",GROUP="rawdisk"



                Note, I replaced SUBSYSTEMS,ATTRS with SUBSYSTEM,ATTR.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 16 at 22:35









                user.dz

                33.7k1186167




                33.7k1186167



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1026500%2fsymlink-created-with-udev-points-to-partition-instead-of-drive%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    pylint3 and pip3 broken

                    Missing snmpget and snmpwalk

                    How to enroll fingerprints to Ubuntu 17.10 with VFS491