symlink created with udev points to partition instead of drive
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
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==""
udev
add a comment |Â
up vote
1
down vote
favorite
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==""
udev
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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==""
udev
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==""
udev
asked Apr 19 at 19:14
uglyoldbob
62
62
add a comment |Â
add a comment |Â
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:
- creates a symlink /dev/sdcard â /dev/sdd
- and quickly replaces it with /dev/sdcard â /dev/sdd1
- 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.
add a comment |Â
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:
- creates a symlink /dev/sdcard â /dev/sdd
- and quickly replaces it with /dev/sdcard â /dev/sdd1
- 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.
add a comment |Â
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:
- creates a symlink /dev/sdcard â /dev/sdd
- and quickly replaces it with /dev/sdcard â /dev/sdd1
- 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.
add a comment |Â
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:
- creates a symlink /dev/sdcard â /dev/sdd
- and quickly replaces it with /dev/sdcard â /dev/sdd1
- 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.
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:
- creates a symlink /dev/sdcard â /dev/sdd
- and quickly replaces it with /dev/sdcard â /dev/sdd1
- 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.
answered May 16 at 22:35
![](https://i.stack.imgur.com/ZuYFV.png?s=32&g=1)
![](https://i.stack.imgur.com/ZuYFV.png?s=32&g=1)
user.dz
33.7k1186167
33.7k1186167
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password