-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit of
udev-logitec-lhr-4bnheu3
.
- Loading branch information
0 parents
commit 05ffbe2
Showing
7 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# udev rules for Logitec LHR-4BNHEU3 | ||
# Copyright 2017 Koichi OKADA. All rights reserved. | ||
# This script is distributed under the MIT license. | ||
|
||
# | ||
# Note: This script must be read before `/lib/udev/rules.d/60-persistent-storage.rules`. | ||
# | ||
|
||
#GOTO="Logitec_LHR-4BNHEU3_end" # for DEBUG | ||
ACTION=="remove", GOTO="Logitec_LHR-4BNHEU3_end" | ||
|
||
SUBSYSTEM!="block", GOTO="Logitec_LHR-4BNHEU3_end" | ||
KERNEL!="sd*", GOTO="Logitec_LHR-4BNHEU3_end" | ||
ATTRS{idVendor}=="0789", GOTO="Logitec_LHR-4BNHEU3_Logitec" | ||
GOTO="Logitec_LHR-4BNHEU3_end" | ||
LABEL="Logitec_LHR-4BNHEU3_Logitec" | ||
ATTRS{idProduct}=="0192", GOTO="Logitec_LHR-4BNHEU3_Logitec_4BNHEU3" | ||
GOTO="Logitec_LHR-4BNHEU3_end" | ||
LABEL="Logitec_LHR-4BNHEU3_Logitec_4BNHEU3" | ||
|
||
# for partitions import parent information | ||
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*" | ||
|
||
# Logitec LHR-4BNHEU3 | ||
KERNEL=="sd*", ENV{ID_SERIAL}=="?*", GOTO="Logitec_LHR-4BNHEU3_SERIAL_set" | ||
IMPORT{builtin}="usb_id" | ||
IMPORT{program}="Logitec_LHR-4BNHEU3.sh $devnode" | ||
LABEL="Logitec_LHR-4BNHEU3_SERIAL_set" | ||
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_USB_SERIAL}" | ||
KERNEL=="sd*", ENV{DEVTYPE}=="partition", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_USB_SERIAL}-part%n" | ||
|
||
LABEL="Logitec_LHR-4BNHEU3_end" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /bin/sh | ||
# udev rules helper for Logitec LHR-4BNHEU3 | ||
# Copyright (c) 2017 Koichi OKADA. All rights reserved. | ||
# This script is distributed under the MIT license. | ||
|
||
ID_USB_INSTANCE="$ID_INSTANCE" | ||
ID_USB_MODEL="Logitec_LHR-4BNHEU3" | ||
ID_USB_MODEL_ENC="Logitec\\x20LHR-4BNHEU3" | ||
ID_USB_REVISION="$ID_USB_REVISION" | ||
ID_USB_SERIAL="${ID_USB_MODEL}_${ID_SERIAL_SHORT}-${ID_INSTANCE}" | ||
ID_USB_SERIAL_SHORT="$ID_SERIAL_SHORT" | ||
|
||
MODEL_NUMBER=`hdparm -I "$1" | grep "Model Number" | sed -e 's/.*: *//g'` | ||
ID_MODEL=`echo "$MODEL_NUMBER" | sed -e 's/ *$//g' -e 's/ /_/g'` | ||
ID_MODEL_ENC=`echo "$MODEL_NUMBER" | sed -e 's/ /\\x20/g'` | ||
ID_REVISION=`hdparm -I "$1" | grep "Firmware Revision" | sed -e 's/.*: *//g'` | ||
SERIAL_NUMBER=`hdparm -I "$1" | grep "Serial Number" | sed -e 's/.*: *//g'` | ||
WWN=`hdparm -I "$1" | grep "WWN" | sed -e 's/.*: */0x/g'` | ||
ID_SERIAL="${ID_MODEL}_${SERIAL_NUMBER}" | ||
ID_SERIAL_SHORT="$SERIAL_NUMBER" | ||
ID_WWN="$WWN" | ||
ID_WWN_WITH_EXTENSION="$WWN" | ||
|
||
echo "ID_USB_INSTANCE=$ID_USB_INSTANCE" | ||
echo "ID_USB_MODEL=$ID_USB_MODEL" | ||
echo "ID_USB_MODEL_ENC=$ID_USB_MODEL" | ||
echo "ID_USB_REVISION=$ID_USB_REVISION" | ||
echo "ID_USB_SERIAL=$ID_USB_SERIAL" | ||
echo "ID_USB_SERIAL_SHORT=$ID_USB_SERIAL_SHORT" | ||
|
||
echo "ID_USB_INSTANCE=" | ||
echo "ID_MODEL=$ID_MODEL" | ||
echo "ID_MODEL_ENC=$ID_MODEL" | ||
echo "ID_REVISION=$ID_REVISION" | ||
echo "ID_SERIAL=$ID_SERIAL" | ||
echo "ID_SERIAL_SHORT=$ID_SERIAL_SHORT" | ||
|
||
echo "ID_WWN=$ID_WWN" | ||
echo "ID_WWN_WITH_EXTENSION=$ID_WWN_WITH_EXTENSION" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
UDEVDIR=$(DESTDIR)/lib/udev | ||
RULEDIR=$(DESTDIR)/etc/udev/rules.d | ||
EXTRA_DIST = 60-Logitec_LHR-4BNHEU3.rules Logitec_LHR-4BNHEU3.sh README.md | ||
dist_noinst_SCRIPTS = bootstrap cleanall | ||
|
||
install-data-local: | ||
-$(mkdir_p) $(RULEDIR) | ||
$(INSTALL_DATA) 60-Logitec_LHR-4BNHEU3.rules $(RULEDIR) | ||
install-exec-local: | ||
-$(mkdir_p) $(UDEVDIR) | ||
$(INSTALL) Logitec_LHR-4BNHEU3.sh $(UDEVDIR) | ||
uninstall-local: | ||
$(RM) $(RULEDIR)/60-Logitec_LHR-4BNHEU3.rules $(UDEVDIR)/Logitec_LHR-4BNHEU3.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# udev rules for Logitec LHR-4BNHEU3 | ||
|
||
This project provides udev rules for Logitec [LHR-4BNHEU3](http://www.logitec.co.jp/products/hd/lhrbnu3/). | ||
|
||
The udev has `/lib/udev/rules.d/60-persistent-storage.rules` script. | ||
It provides Persistent Device Naming as below. | ||
|
||
~~~ | ||
$ ls -l /dev/disk/by-id | ||
usb-TOSHIBA_DT01ACA300_000000000000AAAA-0:0 -> ../../sdb | ||
usb-TOSHIBA_DT01ACA300_000000000000AAAA-0:1 -> ../../sdc | ||
usb-TOSHIBA_DT01ACA300_000000000000AAAA-0:2 -> ../../sdd | ||
usb-TOSHIBA_DT01ACA300_000000000000AAAA-0:3 -> ../../sde | ||
~~~ | ||
|
||
Unfortunately, `AAAA` is the serial number of LHR-4BNHEU3. | ||
It is not persistent device naming based on identifier of the HDD. | ||
|
||
So, this project provides persistent device naming based on identifier of the HDD as below. | ||
|
||
~~~ | ||
$ ls -l /dev/disk/by-id | ||
usb-Logitec_LHR-4BNHEU3_000000000000AAAA-0:0 -> ../../sdb | ||
usb-Logitec_LHR-4BNHEU3_000000000000AAAA-0:1 -> ../../sdc | ||
usb-Logitec_LHR-4BNHEU3_000000000000AAAA-0:2 -> ../../sdd | ||
usb-Logitec_LHR-4BNHEU3_000000000000AAAA-0:3 -> ../../sde | ||
usb-TOSHIBA_DT01ACA300_BBBBBBBBB -> ../../sdb | ||
usb-TOSHIBA_DT01ACA300_CCCCCCCCC -> ../../sdc | ||
usb-TOSHIBA_DT01ACA300_DDDDDDDDD -> ../../sdd | ||
usb-TOSHIBA_DT01ACA300_EEEEEEEEE -> ../../sde | ||
wwn-0xFFFFFFFFFFFFFFFF -> ../../sdb | ||
wwn-0xGGGGGGGGGGGGGGGG -> ../../sdc | ||
wwn-0xHHHHHHHHHHHHHHHH -> ../../sdd | ||
wwn-0xIIIIIIIIIIIIIIII -> ../../sde | ||
~~~ | ||
|
||
## License | ||
|
||
This project is distributed under the MIT license. | ||
|
||
## Prepare for install | ||
|
||
~~~ | ||
aclocal && automake --foreign --add-missing && autoconf && ./configure | ||
~~~ | ||
|
||
## Install | ||
|
||
~~~ | ||
sudo make install | ||
~~~ | ||
|
||
## Uninstall | ||
|
||
~~~ | ||
sudo make uninstall | ||
~~~ | ||
|
||
## Test | ||
|
||
To test `/dev/sdX`, give `/sys/class/block/sdX` to `udevadm` as below. | ||
|
||
~~~ | ||
sudo udevadm test /sys/class/block/sdX | ||
ls -l /dev/disk/by-id | ||
~~~ | ||
|
||
## Trigger all devices to change action | ||
|
||
To reflect installed settings immediately, run below command. | ||
|
||
~~~ | ||
sudo udevadm trigger | ||
~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
(( 5 <= DEBUG )) && set -x | ||
|
||
aclocal && \ | ||
automake --foreign --add-missing && \ | ||
autoconf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
[ -e Makefile ] && make distclean | ||
rm -vr Makefile.in aclocal.m4 autom4te.cache configure install-sh missing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AC_INIT([udev-Logitec-LHR-4BNHEU3], [0.0.0]) | ||
AM_INIT_AUTOMAKE | ||
AC_CONFIG_FILES([Makefile]) | ||
AC_OUTPUT |