Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
udev and mounting usb disks
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1403
Location: Adelaide/Australia

PostPosted: Wed Jun 07, 2017 11:54 am    Post subject: udev and mounting usb disks Reply with quote

I want to have Gentoo mount USB drives automatically on my system.
I want them to mount in /mnt/usb/mountpoint where mountpoint is the partition label or, if no label, the device name. I know, the standard is /media.
I have a script and udev rule but I don't know how to identify that the disk is a USB device.

I want my script to only process partitions on USB drives and mounts them as described above.
If I leave my script to simply mount disks, it gets called during boot up to mount system partitions, which is not what I want, as my script assumes /var/log is available and that is one of the filesystems that my script is invoked upon, during boot.

I suspect I might have to search the ID_PATH for 'usb', but I had hoped ID_BUS would contain 'usb', not 'ata'.

Any assistance would be greatly appreciated.

My udev rule is as follows :-
Code:
ENV{DEVTYPE}=="partition", RUN+="/bin/PartitionMount.sh", ENV{REMOVE_CMD}="/bin/PartitionUnmount.sh"

My script is called with the following environment, when I plug in a 500GB External Drive into my USB hub
Code:

ID_PART_ENTRY_SIZE=976766976
ID_MODEL=ST500LM012_HN-M500MBB
ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_2_1_0-scsi-0_0_0_0
ID_ATA=1
ID_MODEL_ENC=ST500LM012\x20HN-M500MBB\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_REVISION=2AR10001
DEVTYPE=partition
ID_FS_LABEL=TV_Disk
ID_BUS=ata
SUBSYSTEM=block
ID_FS_LABEL_ENC=TV\x20Disk
ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=254
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
ID_ATA_FEATURE_SET_PUIS_ENABLED=0
ID_SERIAL=ST500LM012_HN-M500MBB_S2TRJ9DC838543
ID_FS_UUID=800223FE0223F7B4
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.2/2-1.2:1.0/host6/target6:0:0/6:0:0:0/block/sdd/sdd1
ID_ATA_FEATURE_SET_SECURITY=1
ID_ATA_FEATURE_SET_AAM=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_ATA_FEATURE_SET_APM_ENABLED=0
ID_PART_ENTRY_DISK=8:48
REMOVE_CMD=/bin/PartitionUnmount.sh
PARTN=1
MINOR=49
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_PUIS=1
ACTION=add
ID_ATA_SATA_SIGNAL_RATE_GEN1=1
PWD=/
ID_PART_TABLE_UUID=a1d9c28b
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_TYPE=0x7
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_ATA_DOWNLOAD_MICROCODE=1
ID_FS_TYPE=ntfs-3g
USEC_INITIALIZED=11008156033
MAJOR=8
DEVLINKS=/dev/disk/by-id/ata-ST500LM012_HN-M500MBB_S2TRJ9DC838543-part1 /dev/disk/by-id/wwn-0x16455036197881925632x-part1 /dev/disk/by-label/TV\x20Disk /dev/disk/by-path/pci-0000:00:14.0-usb-0:1.2:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/800223FE0223F7B4
ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=0
DEVNAME=/dev/sdd1
SHLVL=1
ID_ATA_WRITE_CACHE=1
ID_FS_USAGE=filesystem
ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=106
ID_ATA_FEATURE_SET_AAM_ENABLED=0
ID_ATA_FEATURE_SET_APM=1
ID_WWN=0x16455036197881925632x
ID_TYPE=disk
ID_PART_ENTRY_UUID=a1d9c28b-01
ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=106
ID_WWN_WITH_EXTENSION=0x16455036197881925632x
ID_PART_TABLE_TYPE=dos
ID_PART_ENTRY_NUMBER=1
ID_FS_UUID_ENC=800223FE0223F7B4
ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_PART_ENTRY_OFFSET=2048
ID_ATA_SATA=1
ID_ATA_FEATURE_SET_HPA=1
ID_SERIAL_SHORT=S2TRJ9DC838543
ID_ATA_ROTATION_RATE_RPM=5400
ID_ATA_FEATURE_SET_HPA_ENABLED=1
SEQNUM=2273
ID_PATH=pci-0000:00:14.0-usb-0:1.2:1.0-scsi-0:0:0:0
_=/usr/bin/env

_________________
...Lyall
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7198

PostPosted: Wed Jun 07, 2017 1:31 pm    Post subject: Re: udev and mounting usb disks Reply with quote

lyallp wrote:
I suspect I might have to search the ID_PATH for 'usb', but I had hoped ID_BUS would contain 'usb', not 'ata'.

Good guess.
Code:
ID_BUS=usb

ID_MODEL=USB_Flash_Disk

I would look for usb in ID_PATH too.
And i don't know why it does that, i suppose the flash disk is handle by usb drivers, while the ata handling is done by the sata drivers, and the ID_BUS is showing the bus handling the object, and not the bus use by the object.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum