| | 52 | * [http://www.cyberciti.biz/tips/linux-assign-static-names-to-scsi-devices.html Linux udev tip: Assign Static SCSI Device Name] |
| | 53 | * [http://baalzephon.dyndns.org/tech/index.php?udev%E3%83%A1%E3%83%A2 udevメモ - PukiWiki Plus!] |
| | 54 | |
| | 55 | == /dev/sda を他の名前にする == |
| | 56 | * 現状では成功していない |
| | 57 | |
| | 58 | === 元の状態 === |
| | 59 | * mitty@walken:~$ sudo udevadm info -q path -n /dev/sda |
| | 60 | {{{ |
| | 61 | /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 62 | }}} |
| | 63 | |
| | 64 | * mitty@walken:~$ sudo udevadm info --query=all --name=/dev/sda |
| | 65 | {{{ |
| | 66 | P: /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 67 | N: sda |
| | 68 | S: block/8:0 |
| | 69 | S: disk/by-id/scsi-SATA_ST3500418AS_6VM9ABYD |
| | 70 | S: disk/by-id/ata-ST3500418AS_6VM9ABYD |
| | 71 | S: disk/by-id/wwn-0x5000c5001eda26f9 |
| | 72 | S: disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 |
| | 73 | E: UDEV_LOG=3 |
| | 74 | E: DEVPATH=/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 75 | E: MAJOR=8 |
| | 76 | E: MINOR=0 |
| | 77 | E: DEVNAME=/dev/sda |
| | 78 | E: DEVTYPE=disk |
| | 79 | E: SUBSYSTEM=block |
| | 80 | E: ID_ATA=1 |
| | 81 | E: ID_TYPE=disk |
| | 82 | E: ID_BUS=ata |
| | 83 | E: ID_MODEL=ST3500418AS |
| | 84 | E: ID_MODEL_ENC=ST3500418AS\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 |
| | 85 | E: ID_REVISION=CC38 |
| | 86 | E: ID_SERIAL=ST3500418AS_6VM9ABYD |
| | 87 | E: ID_SERIAL_SHORT=6VM9ABYD |
| | 88 | E: ID_ATA_WRITE_CACHE=1 |
| | 89 | E: ID_ATA_WRITE_CACHE_ENABLED=1 |
| | 90 | E: ID_ATA_FEATURE_SET_HPA=1 |
| | 91 | E: ID_ATA_FEATURE_SET_HPA_ENABLED=1 |
| | 92 | E: ID_ATA_FEATURE_SET_PM=1 |
| | 93 | E: ID_ATA_FEATURE_SET_PM_ENABLED=1 |
| | 94 | E: ID_ATA_FEATURE_SET_SECURITY=1 |
| | 95 | E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 |
| | 96 | E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=82 |
| | 97 | E: ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=82 |
| | 98 | E: ID_ATA_FEATURE_SET_SECURITY_FROZEN=1 |
| | 99 | E: ID_ATA_FEATURE_SET_SMART=1 |
| | 100 | E: ID_ATA_FEATURE_SET_SMART_ENABLED=1 |
| | 101 | E: ID_ATA_FEATURE_SET_AAM=1 |
| | 102 | E: ID_ATA_FEATURE_SET_AAM_ENABLED=1 |
| | 103 | E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=254 |
| | 104 | E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=254 |
| | 105 | E: ID_ATA_DOWNLOAD_MICROCODE=1 |
| | 106 | E: ID_ATA_SATA=1 |
| | 107 | E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1 |
| | 108 | E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1 |
| | 109 | E: ID_ATA_ROTATION_RATE_RPM=7200 |
| | 110 | E: ID_WWN=0x5000c5001eda26f9 |
| | 111 | E: ID_WWN_WITH_EXTENSION=0x5000c5001eda26f9 |
| | 112 | E: ID_SCSI_COMPAT=SATA_ST3500418AS_6VM9ABYD |
| | 113 | E: ID_PATH=pci-0000:00:1f.2-scsi-0:0:0:0 |
| | 114 | E: ID_PART_TABLE_TYPE=dos |
| | 115 | E: UDISKS_PRESENTATION_NOPOLICY=0 |
| | 116 | E: UDISKS_PARTITION_TABLE=1 |
| | 117 | E: UDISKS_PARTITION_TABLE_SCHEME=mbr |
| | 118 | E: UDISKS_PARTITION_TABLE_COUNT=2 |
| | 119 | E: UDISKS_ATA_SMART_IS_AVAILABLE=1 |
| | 120 | E: DEVLINKS=/dev/block/8:0 /dev/disk/by-id/scsi-SATA_ST3500418AS_6VM9ABYD /dev/disk/by-id/ata-ST3500418AS_6VM9ABYD /dev/disk/by-id/wwn-0x5000c5001eda26f9 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 |
| | 121 | |
| | 122 | }}} |
| | 123 | |
| | 124 | * mitty@walken:~$ sudo udevadm info -a --name=/dev/sda |
| | 125 | {{{ |
| | 126 | |
| | 127 | Udevadm info starts with the device specified by the devpath and then |
| | 128 | walks up the chain of parent devices. It prints for every device |
| | 129 | found, all possible attributes in the udev rules key format. |
| | 130 | A rule to match, can be composed by the attributes of the device |
| | 131 | and the attributes from one single parent device. |
| | 132 | |
| | 133 | looking at device '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda': |
| | 134 | KERNEL=="sda" |
| | 135 | SUBSYSTEM=="block" |
| | 136 | DRIVER=="" |
| | 137 | ATTR{range}=="16" |
| | 138 | ATTR{ext_range}=="256" |
| | 139 | ATTR{removable}=="0" |
| | 140 | ATTR{ro}=="0" |
| | 141 | ATTR{size}=="976773168" |
| | 142 | ATTR{alignment_offset}=="0" |
| | 143 | ATTR{discard_alignment}=="0" |
| | 144 | ATTR{capability}=="50" |
| | 145 | ATTR{stat}==" 7129 217 287320 92724 2036 269 47453 141436 0 35592 234152" |
| | 146 | ATTR{inflight}==" 0 0" |
| | 147 | ATTR{events}=="" |
| | 148 | ATTR{events_async}=="" |
| | 149 | ATTR{events_poll_msecs}=="-1" |
| | 150 | |
| | 151 | looking at parent device '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0': |
| | 152 | KERNELS=="2:0:0:0" |
| | 153 | SUBSYSTEMS=="scsi" |
| | 154 | DRIVERS=="sd" |
| | 155 | ATTRS{device_blocked}=="0" |
| | 156 | ATTRS{type}=="0" |
| | 157 | ATTRS{scsi_level}=="6" |
| | 158 | ATTRS{vendor}=="ATA " |
| | 159 | ATTRS{model}=="ST3500418AS " |
| | 160 | ATTRS{rev}=="CC38" |
| | 161 | ATTRS{state}=="running" |
| | 162 | ATTRS{timeout}=="30" |
| | 163 | ATTRS{iocounterbits}=="32" |
| | 164 | ATTRS{iorequest_cnt}=="0x24dc" |
| | 165 | ATTRS{iodone_cnt}=="0x24c0" |
| | 166 | ATTRS{ioerr_cnt}=="0xc" |
| | 167 | ATTRS{modalias}=="scsi:t-0x00" |
| | 168 | ATTRS{evt_media_change}=="0" |
| | 169 | ATTRS{queue_depth}=="31" |
| | 170 | ATTRS{queue_ramp_up_period}=="120000" |
| | 171 | ATTRS{queue_type}=="simple" |
| | 172 | |
| | 173 | looking at parent device '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0': |
| | 174 | KERNELS=="target2:0:0" |
| | 175 | SUBSYSTEMS=="scsi" |
| | 176 | DRIVERS=="" |
| | 177 | |
| | 178 | looking at parent device '/devices/pci0000:00/0000:00:1f.2/host2': |
| | 179 | KERNELS=="host2" |
| | 180 | SUBSYSTEMS=="scsi" |
| | 181 | DRIVERS=="" |
| | 182 | |
| | 183 | looking at parent device '/devices/pci0000:00/0000:00:1f.2': |
| | 184 | KERNELS=="0000:00:1f.2" |
| | 185 | SUBSYSTEMS=="pci" |
| | 186 | DRIVERS=="ahci" |
| | 187 | ATTRS{vendor}=="0x8086" |
| | 188 | ATTRS{device}=="0x3b22" |
| | 189 | ATTRS{subsystem_vendor}=="0x8086" |
| | 190 | ATTRS{subsystem_device}=="0x0037" |
| | 191 | ATTRS{class}=="0x010601" |
| | 192 | ATTRS{irq}=="49" |
| | 193 | ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,0000000f" |
| | 194 | ATTRS{local_cpulist}=="0-3" |
| | 195 | ATTRS{modalias}=="pci:v00008086d00003B22sv00008086sd00000037bc01sc06i01" |
| | 196 | ATTRS{numa_node}=="-1" |
| | 197 | ATTRS{dma_mask_bits}=="64" |
| | 198 | ATTRS{consistent_dma_mask_bits}=="64" |
| | 199 | ATTRS{enable}=="1" |
| | 200 | ATTRS{broken_parity_status}=="0" |
| | 201 | ATTRS{msi_bus}=="" |
| | 202 | |
| | 203 | looking at parent device '/devices/pci0000:00': |
| | 204 | KERNELS=="pci0000:00" |
| | 205 | SUBSYSTEMS=="" |
| | 206 | DRIVERS=="" |
| | 207 | |
| | 208 | }}} |
| | 209 | |
| | 210 | |
| | 211 | * mitty@walken:~$ sudo /lib/udev/scsi_id --page=0x83 --whitelisted --device=/dev/sda |
| | 212 | {{{ |
| | 213 | 35000c5001eda26f9 |
| | 214 | }}} |
| | 215 | * mitty@walken:~$ sudo /lib/udev/scsi_id -g -u --device /dev/sda |
| | 216 | {{{ |
| | 217 | 35000c5001eda26f9 |
| | 218 | }}} |
| | 219 | |
| | 220 | * mitty@walken:~$ ls -l /sys/block/ |
| | 221 | {{{ |
| | 222 | total 0 |
| | 223 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop0 -> ../devices/virtual/block/loop0 |
| | 224 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop1 -> ../devices/virtual/block/loop1 |
| | 225 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop2 -> ../devices/virtual/block/loop2 |
| | 226 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop3 -> ../devices/virtual/block/loop3 |
| | 227 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop4 -> ../devices/virtual/block/loop4 |
| | 228 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop5 -> ../devices/virtual/block/loop5 |
| | 229 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop6 -> ../devices/virtual/block/loop6 |
| | 230 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop7 -> ../devices/virtual/block/loop7 |
| | 231 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 sda -> ../devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 232 | lrwxrwxrwx 1 root root 0 Apr 16 15:09 sr0 -> ../devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sr0 |
| | 233 | }}} |
| | 234 | |
| | 235 | === 実験 === |
| | 236 | * /etc/udev/rules.d/10-fixed_hdd.rules |
| | 237 | {{{ |
| | 238 | # set device name for ST3500418AS 6VM9ABYD |
| | 239 | SUBSYSTEMS=="block", ENV{ID_SERIAL}=="ST3500418AS_6VM9ABYD", NAME="sdx%n" |
| | 240 | }}} |
| | 241 | * 成功しないがエラーも出ない |
| | 242 | |
| | 243 | * /etc/udev/rules.d/10-fixed_hdd.rules |
| | 244 | {{{ |
| | 245 | # set device name for ST3500418AS 6VM9ABYD |
| | 246 | SUBSYSTEMS=="block", PROGRAM=="/lib/udev/scsi_id -g -u --device %p", RESULT=="35000c5001eda26f9", NAME="sdx%n" |
| | 247 | }}} |
| | 248 | * mitty@walken:~$ sudo udevadm test /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 249 | {{{ |
| | 250 | run_command: calling: test |
| | 251 | udevadm_test: version 164 |
| | 252 | This program is for debugging only, it does not run any program, |
| | 253 | specified by a RUN key. It may show incorrect results, because |
| | 254 | some values may be different, or not available at a simulation run. |
| | 255 | |
| | 256 | parse_file: reading '/etc/udev/rules.d/10-fixed_hdd.rules' as rules file |
| | 257 | parse_file: reading '/lib/udev/rules.d/40-hplip.rules' as rules file |
| | 258 | |
| | 259 | (snip) |
| | 260 | |
| | 261 | udev_rules_new: rules use 231672 bytes tokens (19306 * 12 bytes), 35564 bytes buffer |
| | 262 | udev_rules_new: temporary index used 60940 bytes (3047 * 20 bytes) |
| | 263 | udev_device_new_from_syspath: device 0x7f1093f7c340 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda' |
| | 264 | udev_device_new_from_syspath: device 0x7f1093f7cee0 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda' |
| | 265 | udev_device_read_db: device 0x7f1093f7cee0 filled with db file data |
| | 266 | udev_rules_apply_to_event: PROGRAM '/lib/udev/scsi_id -g -u --device /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda' /etc/udev/rules.d/10-fixed_hdd.rules:2 |
| | 267 | util_run_program: '/lib/udev/scsi_id -g -u --device /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda' started |
| | 268 | util_run_program: '/lib/udev/scsi_id -g -u --device /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda' returned with exitcode 1 |
| | 269 | udev_device_new_from_syspath: device 0x7f1093f7c5c0 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0' |
| | 270 | udev_device_new_from_syspath: device 0x7f1093f77e30 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0' |
| | 271 | udev_device_new_from_syspath: device 0x7f1093f78160 has devpath '/devices/pci0000:00/0000:00:1f.2/host2' |
| | 272 | udev_device_new_from_syspath: device 0x7f1093f78480 has devpath '/devices/pci0000:00/0000:00:1f.2' |
| | 273 | udev_device_new_from_syspath: device 0x7f1093f78790 has devpath '/devices/pci0000:00' |
| | 274 | |
| | 275 | (snip) |
| | 276 | }}} |
| | 277 | * mitty@walken:~$ grep scsi_id /var/log/syslog |
| | 278 | {{{ |
| | 279 | Apr 16 16:17:48 walken scsi_id[4773]: custom logging function 0x7f3411a38010 registered |
| | 280 | Apr 16 16:17:48 walken scsi_id[4773]: scsi_id: cannot open /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda: No such file or directory |
| | 281 | Apr 16 16:17:48 walken scsi_id[4776]: custom logging function 0x7f96ccf96010 registered |
| | 282 | }}} |
| | 283 | * scsi_idのオプションが変わった模様 |
| | 284 | * [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=493075 #493075 - scsi_id changed commandline syntax (breaks multipath) - Debian Bug report logs] |
| | 285 | |
| | 286 | * /etc/udev/rules.d/10-fixed_hdd.rules |
| | 287 | {{{ |
| | 288 | # set device name for ST3500418AS 6VM9ABYD |
| | 289 | SUBSYSTEMS=="block", DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda", NAME="sdx%n" |
| | 290 | }}} |
| | 291 | * boot中のコンソール画面 |
| | 292 | {{{ |
| | 293 | Waiting for /dev to be fully populated...udevd-work[353]: kernel-provided name ' |
| | 294 | sda' and NAME= 'sdx' disagree, please use SYMLINK+= or change the kernel to prov |
| | 295 | ide the proper name |
| | 296 | }}} |
| | 297 | * mitty@walken:~$ ls -l /dev/sd* |
| | 298 | {{{ |
| | 299 | brw------- 1 root root 8, 0 Apr 16 16:30 /dev/sda |
| | 300 | brw-rw---- 1 root disk 8, 1 Apr 16 16:30 /dev/sda1 |
| | 301 | brw-rw---- 1 root disk 8, 2 Apr 16 16:30 /dev/sda2 |
| | 302 | brw-rw---- 1 root disk 8, 0 Apr 16 16:30 /dev/sdx |
| | 303 | }}} |
| | 304 | * mitty@walken:~$ sudo fdisk -lu /dev/sda |
| | 305 | {{{ |
| | 306 | Disk /dev/sda: 500.1 GB, 500107862016 bytes |
| | 307 | 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors |
| | 308 | Units = sectors of 1 * 512 = 512 bytes |
| | 309 | Sector size (logical/physical): 512 bytes / 512 bytes |
| | 310 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| | 311 | Disk identifier: 0x00086666 |
| | 312 | |
| | 313 | Device Boot Start End Blocks Id System |
| | 314 | /dev/sda1 * 2048 961177599 480587776 83 Linux |
| | 315 | /dev/sda2 961177600 976771071 7796736 82 Linux swap / Solaris |
| | 316 | }}} |
| | 317 | * mitty@walken:~$ sudo fdisk -lu /dev/sdx |
| | 318 | {{{ |
| | 319 | Disk /dev/sdx: 500.1 GB, 500107862016 bytes |
| | 320 | 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors |
| | 321 | Units = sectors of 1 * 512 = 512 bytes |
| | 322 | Sector size (logical/physical): 512 bytes / 512 bytes |
| | 323 | I/O size (minimum/optimal): 512 bytes / 512 bytes |
| | 324 | Disk identifier: 0x00086666 |
| | 325 | |
| | 326 | Device Boot Start End Blocks Id System |
| | 327 | /dev/sdx1 * 2048 961177599 480587776 83 Linux |
| | 328 | /dev/sdx2 961177600 976771071 7796736 82 Linux swap / Solaris |
| | 329 | }}} |
| | 330 | * mitty@walken:~$ ls -l /sys/block/ |
| | 331 | {{{ |
| | 332 | total 0 |
| | 333 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop0 -> ../devices/virtual/block/loop0 |
| | 334 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop1 -> ../devices/virtual/block/loop1 |
| | 335 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop2 -> ../devices/virtual/block/loop2 |
| | 336 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop3 -> ../devices/virtual/block/loop3 |
| | 337 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop4 -> ../devices/virtual/block/loop4 |
| | 338 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop5 -> ../devices/virtual/block/loop5 |
| | 339 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop6 -> ../devices/virtual/block/loop6 |
| | 340 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop7 -> ../devices/virtual/block/loop7 |
| | 341 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 sda -> ../devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda |
| | 342 | lrwxrwxrwx 1 root root 0 Apr 16 16:51 sr0 -> ../devices/pci0000:00/0000:00:1f.2/host5/target5:0:0/5:0:0:0/block/sr0 |
| | 343 | }}} |
| | 344 | * 元のまま |
| | 345 | |
| | 346 | * /etc/udev/rules.d/10-fixed_hdd.rules |
| | 347 | {{{ |
| | 348 | # set device name for ST3500418AS 6VM9ABYD |
| | 349 | SUBSYSTEMS=="block", ATTR{size}=="976773168" , NAME="sdx%n" |
| | 350 | }}} |
| | 351 | * 同じエラー |
| | 352 | {{{ |
| | 353 | Waiting for /dev to be fully populated...udevd-work[353]: kernel-provided name ' |
| | 354 | sda' and NAME= 'sdx' disagree, please use SYMLINK+= or change the kernel to prov |
| | 355 | ide the proper name |
| | 356 | }}} |