CAFE

filesystem/disk

왜 SAN, ISCSI 등으로 붙은 디스크들의 이름이 바뀔까?

작성자이누기|작성시간09.11.20|조회수1,732 목록 댓글 1

왜 SAN, ISCSI 등으로 붙은 디스크들의 이름이 바뀔까?

그리고 어떻게 이를 고정이름으로 바꿀까?

 

이러한 이유는 디스크가 OS에 올라오는 순서가 딱히 정해진 룰이 없기 때문이다. 물론 내부적인 룰이 있으나 충분히 디스크의 이름이 바뀔 수 있는 상황이 있다.

이를  위해서 udev  의 rule을 통해서 고정이름으로 설정할 수 있다.

 

 

Limitation:

 

udev rules은 RHEL5에서만 동작할 것이다.udev 문법은 RHEL4와 RHEL5의 버젼간에 달라질 수 있다.

관련된 문서는 아래의 URL을 참고해라.: How can persistent names be created for SCSI devices in Red Hat Enterprise Linux 4 and 5?

http://kbase.redhat.com/faq/docs/DOC-4202

 

 

  1. 가장 먼저 필요한 것이 SCSI장치의  WWID 이다. 이 WWID를 얻기위해서 아래와 같은 명령을 통해 가능하다.예를 들어  /dev/sdc, 에 대한 wwid를 얻기위한 명령은 아래와 같다:

    # scsi_id -g -u -s /block/sdc

    결과는 아래와 같이 확인된다.: 
     
     

    [root@rhel5 rules.d]# scsi_id -g -u -s /block/sdc 3600a0b800013275100000015427b625e

    The scsi_id command issues a SCSI INQUIRY command to the device to access the vital product data (VPD) page 0x83 data, which contains, amongst other information, the device WWID, or page 0x80 data, which contains the unit serial number. 
     
      The result of the scsi_id command (the long string of characters) is the WWID of the device that is currently mapped to /dev/sdc (/sys/block/sdc). This WWID will be the same for each path to the device and for each partition on the device. The WWID will not change if other devices are added to or removed from the system. However the mapping of the device to /dev/sdc could change. This is why there is a need to create a static device name. The WWID is what the udev device names will be keyed off of. 
     

  2. Rules는 반드시 장치의 이름에 대해사 만들어져야 된다.  /etc/udev/rules.d/20-names.rules 파일을 만들어라. 
     이 파일로 , 이름 규칙이 추가될 것이다. 규칙은 아래의 포맷과 같을 것이다: 
     
     

    KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="WWID",   SYMLINK+="devicename%n"

    이것은 /dev/sd*로 매칭되는 모든 SCSI장치를 체크하고, 주어진 wwid에 대해서 체크될 것이다.매칭되는 장치가 발견되면, 이것은 /dev/devicename으로 만들것이다. 만약 장치에 다른 파티션이 있다면, 첫번째 파티션에 대해서 /dev/devicename1 로 만들어 질것이고, 두번째는 /dev/devicename2 으로 만들어 질것이고, 계속 그렇게 진행 될 것이다. 이제 실제 사용하는 규칙은 ,위의  stringsWWID 와 장치 이름 대신 아래와 같이 바꿔 사용하면 될 것이다. 아래는 실제 사용한 예이다.: 
     
     

  3. KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="3600a0b800013275100000015427b625e",   SYMLINK+="mydevice%n"

    이 규칙은 WWID가 3600a0b800013275100000015427b625e인 장치를 /dev/mydevice 장치로 (심볼릭 링크) 만든다. 이 장치에 파티션은 이제 /dev/mydevice1, /dev/mydevice2 등이 할당될 것이다.
     

  4. 이 룰을 테스트하기 위해서는  udevtest 명령을 아래와 같이 사용하면 된다.

    [root@rhel5 rules.d]# udevtest /block/sdc | grep mydevice udev_rules_get_name: add symlink 'mydevice' udev_node_add: creating symlink '/dev/mydevice' to 'sdc'

    만약 /dev/sdc 가 이 파티션을 가지면, 이 명령을 내리는 것은  /dev/sdc1 장치를 만들것이다. : 

    [root@rhel5 rules.d]# udevtest /block/sdc/sdc1 | grep mydevice udev_rules_get_name: add symlink 'mydevice1' udev_node_add: creating symlink '/dev/mydevice1' to 'sdc1'

     

  5. 마지막으로 ,udev가 있는 장치들을 만들기 위해서 start_udev 명령을 실행해라: 

    start_udev

     /dev/mydevice* 가  /dev/sdc* 심볼릭 링크로 만들어 졌는지 확인해라.  
      
     As long as the device with WWID 3600a0b800013275100000015427b625e is attached/visible to Red Hat Enterprise Linux, it will always be statically bound to the name /dev/mydevice by udev. 
     

 

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자이누기 작성자 본인 여부 작성자 | 작성시간 09.11.24 http://kbase.redhat.com/faq/docs/DOC-4202
    http://kbase.redhat.com/faq/docs/DOC-7319
    http://kbase.redhat.com/faq/docs/DOC-5544
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼