Changes between Version 4 and Version 5 of TipAndDoc/Linux


Ignore:
Timestamp:
Apr 16, 2012 5:26:13 PM (13 years ago)
Author:
mitty
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TipAndDoc/Linux

    v4 v5  
    5050 * [http://www37.atwiki.jp/centos-homeserver/pages/20.html CentOSでホームサーバを作ろう - データ用HDDの準備] 
    5151 * [http://d.hatena.ne.jp/qpSHiNqp/20110214/1297651801 udevによるデバイスの命名の固定化 - しんたろの日記] 
     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{{{ 
     66P: /devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda 
     67N: sda 
     68S: block/8:0 
     69S: disk/by-id/scsi-SATA_ST3500418AS_6VM9ABYD 
     70S: disk/by-id/ata-ST3500418AS_6VM9ABYD 
     71S: disk/by-id/wwn-0x5000c5001eda26f9 
     72S: disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 
     73E: UDEV_LOG=3 
     74E: DEVPATH=/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0/block/sda 
     75E: MAJOR=8 
     76E: MINOR=0 
     77E: DEVNAME=/dev/sda 
     78E: DEVTYPE=disk 
     79E: SUBSYSTEM=block 
     80E: ID_ATA=1 
     81E: ID_TYPE=disk 
     82E: ID_BUS=ata 
     83E: ID_MODEL=ST3500418AS 
     84E: 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 
     85E: ID_REVISION=CC38 
     86E: ID_SERIAL=ST3500418AS_6VM9ABYD 
     87E: ID_SERIAL_SHORT=6VM9ABYD 
     88E: ID_ATA_WRITE_CACHE=1 
     89E: ID_ATA_WRITE_CACHE_ENABLED=1 
     90E: ID_ATA_FEATURE_SET_HPA=1 
     91E: ID_ATA_FEATURE_SET_HPA_ENABLED=1 
     92E: ID_ATA_FEATURE_SET_PM=1 
     93E: ID_ATA_FEATURE_SET_PM_ENABLED=1 
     94E: ID_ATA_FEATURE_SET_SECURITY=1 
     95E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 
     96E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=82 
     97E: ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=82 
     98E: ID_ATA_FEATURE_SET_SECURITY_FROZEN=1 
     99E: ID_ATA_FEATURE_SET_SMART=1 
     100E: ID_ATA_FEATURE_SET_SMART_ENABLED=1 
     101E: ID_ATA_FEATURE_SET_AAM=1 
     102E: ID_ATA_FEATURE_SET_AAM_ENABLED=1 
     103E: ID_ATA_FEATURE_SET_AAM_VENDOR_RECOMMENDED_VALUE=254 
     104E: ID_ATA_FEATURE_SET_AAM_CURRENT_VALUE=254 
     105E: ID_ATA_DOWNLOAD_MICROCODE=1 
     106E: ID_ATA_SATA=1 
     107E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1 
     108E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1 
     109E: ID_ATA_ROTATION_RATE_RPM=7200 
     110E: ID_WWN=0x5000c5001eda26f9 
     111E: ID_WWN_WITH_EXTENSION=0x5000c5001eda26f9 
     112E: ID_SCSI_COMPAT=SATA_ST3500418AS_6VM9ABYD 
     113E: ID_PATH=pci-0000:00:1f.2-scsi-0:0:0:0 
     114E: ID_PART_TABLE_TYPE=dos 
     115E: UDISKS_PRESENTATION_NOPOLICY=0 
     116E: UDISKS_PARTITION_TABLE=1 
     117E: UDISKS_PARTITION_TABLE_SCHEME=mbr 
     118E: UDISKS_PARTITION_TABLE_COUNT=2 
     119E: UDISKS_ATA_SMART_IS_AVAILABLE=1 
     120E: 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 
     127Udevadm info starts with the device specified by the devpath and then 
     128walks up the chain of parent devices. It prints for every device 
     129found, all possible attributes in the udev rules key format. 
     130A rule to match, can be composed by the attributes of the device 
     131and 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{{{ 
     21335000c5001eda26f9 
     214}}} 
     215 * mitty@walken:~$ sudo /lib/udev/scsi_id -g -u --device /dev/sda 
     216{{{ 
     21735000c5001eda26f9 
     218}}} 
     219 
     220 * mitty@walken:~$ ls -l /sys/block/ 
     221{{{ 
     222total 0 
     223lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop0 -> ../devices/virtual/block/loop0 
     224lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop1 -> ../devices/virtual/block/loop1 
     225lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop2 -> ../devices/virtual/block/loop2 
     226lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop3 -> ../devices/virtual/block/loop3 
     227lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop4 -> ../devices/virtual/block/loop4 
     228lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop5 -> ../devices/virtual/block/loop5 
     229lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop6 -> ../devices/virtual/block/loop6 
     230lrwxrwxrwx 1 root root 0 Apr 16 15:09 loop7 -> ../devices/virtual/block/loop7 
     231lrwxrwxrwx 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 
     232lrwxrwxrwx 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 
     239SUBSYSTEMS=="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 
     246SUBSYSTEMS=="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{{{ 
     250run_command: calling: test 
     251udevadm_test: version 164 
     252This program is for debugging only, it does not run any program, 
     253specified by a RUN key. It may show incorrect results, because 
     254some values may be different, or not available at a simulation run. 
     255 
     256parse_file: reading '/etc/udev/rules.d/10-fixed_hdd.rules' as rules file 
     257parse_file: reading '/lib/udev/rules.d/40-hplip.rules' as rules file 
     258 
     259(snip) 
     260 
     261udev_rules_new: rules use 231672 bytes tokens (19306 * 12 bytes), 35564 bytes buffer 
     262udev_rules_new: temporary index used 60940 bytes (3047 * 20 bytes) 
     263udev_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' 
     264udev_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' 
     265udev_device_read_db: device 0x7f1093f7cee0 filled with db file data 
     266udev_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 
     267util_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 
     268util_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 
     269udev_device_new_from_syspath: device 0x7f1093f7c5c0 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0/2:0:0:0' 
     270udev_device_new_from_syspath: device 0x7f1093f77e30 has devpath '/devices/pci0000:00/0000:00:1f.2/host2/target2:0:0' 
     271udev_device_new_from_syspath: device 0x7f1093f78160 has devpath '/devices/pci0000:00/0000:00:1f.2/host2' 
     272udev_device_new_from_syspath: device 0x7f1093f78480 has devpath '/devices/pci0000:00/0000:00:1f.2' 
     273udev_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{{{ 
     279Apr 16 16:17:48 walken scsi_id[4773]: custom logging function 0x7f3411a38010 registered 
     280Apr 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 
     281Apr 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 
     289SUBSYSTEMS=="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{{{ 
     293Waiting for /dev to be fully populated...udevd-work[353]: kernel-provided name ' 
     294sda' and NAME= 'sdx' disagree, please use SYMLINK+= or change the kernel to prov 
     295ide the proper name 
     296}}} 
     297  * mitty@walken:~$ ls -l /dev/sd* 
     298{{{ 
     299brw------- 1 root root 8, 0 Apr 16 16:30 /dev/sda 
     300brw-rw---- 1 root disk 8, 1 Apr 16 16:30 /dev/sda1 
     301brw-rw---- 1 root disk 8, 2 Apr 16 16:30 /dev/sda2 
     302brw-rw---- 1 root disk 8, 0 Apr 16 16:30 /dev/sdx 
     303}}} 
     304  * mitty@walken:~$ sudo fdisk -lu /dev/sda 
     305{{{ 
     306Disk /dev/sda: 500.1 GB, 500107862016 bytes 
     307255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors 
     308Units = sectors of 1 * 512 = 512 bytes 
     309Sector size (logical/physical): 512 bytes / 512 bytes 
     310I/O size (minimum/optimal): 512 bytes / 512 bytes 
     311Disk 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{{{ 
     319Disk /dev/sdx: 500.1 GB, 500107862016 bytes 
     320255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors 
     321Units = sectors of 1 * 512 = 512 bytes 
     322Sector size (logical/physical): 512 bytes / 512 bytes 
     323I/O size (minimum/optimal): 512 bytes / 512 bytes 
     324Disk 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{{{ 
     332total 0 
     333lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop0 -> ../devices/virtual/block/loop0 
     334lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop1 -> ../devices/virtual/block/loop1 
     335lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop2 -> ../devices/virtual/block/loop2 
     336lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop3 -> ../devices/virtual/block/loop3 
     337lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop4 -> ../devices/virtual/block/loop4 
     338lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop5 -> ../devices/virtual/block/loop5 
     339lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop6 -> ../devices/virtual/block/loop6 
     340lrwxrwxrwx 1 root root 0 Apr 16 16:51 loop7 -> ../devices/virtual/block/loop7 
     341lrwxrwxrwx 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 
     342lrwxrwxrwx 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 
     349SUBSYSTEMS=="block", ATTR{size}=="976773168" , NAME="sdx%n" 
     350}}} 
     351  * 同じエラー 
     352{{{ 
     353Waiting for /dev to be fully populated...udevd-work[353]: kernel-provided name ' 
     354sda' and NAME= 'sdx' disagree, please use SYMLINK+= or change the kernel to prov 
     355ide the proper name 
     356}}}