★ linux 디바이스장치 종류

1) Device Mapper 장치 (dm-X) 
    - 물리 블록장치를 가상 블록장치로 매핑하는 리눅스 커널 기능
    - LVM, S/W RAID, multipath, 파티션 암호화 등에 사용됨
    - 디바이스위치 : /dev/dm-X
    - mapper 장치는, 물리디스크 장치는 아닌것 같으며, 볼륨이나 multipath를 만들면 자동으로 dm-X로 매핑되고, 생성된 직접 dm-X 디바이스를 사용하지 않고, 심볼릭링크파일을 이용한다.
※ ls -al /dev/block --> dm-X, sd-X 디스크의 major, minor 넘버파일확인가능 (vgdisplay -v VG명에서 보이는 block device명이 이 숫자로 되어 있음)

2) sda, sdb... : SATA/SAS 디스크
   vda, vdb... : 가상서버 디스크
   hda, hdb.. : IDE방식 디스크
    - 디바이스 위치 : /dev/sdX
    - /dev/disk/by-id 하위파일에서 물리디스크의 scsi ID, WWN 확인가능

3) multipath 디바이스 (mpathX)
    - 디바이스 위치 : /dev/mapper/mpathX 
    - 구성확인 : multipath -l
    - mpathX는 /dev/dm-X 로 symbolic link 
    ※ mapthX로 잡아서 볼륨 생성한다

4) UUID
   : 디스크, 디스크컨트롤러가 변경될때, 디스크 드라이브명 바뀌는 경우를 피하기 위하기 고유한 UUID값으로 매핑하여 /etc/fstab에 등록한다
   : 확인방법 # blkid
                # ls -al /dev/disk/by-uuid/

5) OS SW 미러 (/dev/md
https://btyy.tistory.com/entry/LINUX-23%EC%9D%BC%EC%B0%A8-CentOS-RAID-%EA%B5%AC%EC%84%B1LinearStripeMirror-RAID-%EC%83%9D%EC%84%B1

※ 파일시스템 마운트 예 
예) 
/dev/mapper/rootvg-root_lv  50G   13G   35G  27% /					---> 실제볼륨은 rootvg의 root_lv 이며, /dev/mapper 아래에 rootvg-root_lv 이름으로 된 파일이 dm-X로 심볼릭 link되었음. (/dev/rootvg/root_lv도 존재하지만, 이것으로 마운트 하지는 않았음)
/dev/mapper/bkupvg-bkup_lv001 275G   37G  225G  14% /bkup001
/dev/sda1             477M   84M  369M  19% /boot					---> UUID로 마운트함(/etc/fstab)
/dev/mapper/VSP_357_VG002-engn_lv002  20G  1.5G   18G   8% /engn002

※ lsblk로 전체적인 디바이스 구성 설명
sdX로 시작하는 디바이스는 실제 물리 디스크
sdX하위로 만들어진 볼륨, 멀티패스 device 는 dm-X라는 device명도 함께 생성됨.
sda1경우는 sda1하위로 만들어진 장치가 없기 때문에, dm-X라는 device명이 존재하지 않고, # ls -al /dev/disk/by-uuid --> sda1파일만이 물리디스크로 유일하게 존재하고, sda1로 디바이스로 직접 마운트 등의 사용을 함 (다른 디바이스는 모두 dm-X)
※ /dev/block/dm-X/slaves ---> 하위디렉토리 들어가보면 해당, dm-X랑 매핑되는 상위 ---> sdX디스크 또는 dm-X디스크 넘버를 확인 가능
   --> 예) /sys/class/block/dm-7/slaves 를 보면, multipath 디바이스인 dm-2가 보임

NAME                                MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                   8:0    0 278.9G  0 disk
|-sda1                                8:1    0   500M  0 part  /boot
`-sda2                                8:2    0 278.4G  0 part
  |-rootvg-swap_lv (dm-0)           253:0    0    16G  0 lvm   [SWAP]
  `-rootvg-root_lv (dm-1)           253:1    0    50G  0 lvm   /
sdb                                   8:16   0 278.9G  0 disk
`-sdb1                                8:17   0 278.9G  0 part
  `-bkupvg-bkup_lv001 (dm-4)        253:4    0 278.9G  0 lvm   /bkup001
sdc                                   8:32   0 261.4G  0 disk
`-mpathc (dm-2)                     253:2    0 261.4G  0 mpath
  |-VSP_357_VG002-engn_lv002 (dm-7) 253:7    0    20G  0 lvm   /engn002
  `-VSP_357_VG002-logs_lv002 (dm-8) 253:8    0   240G  0 lvm   /logs002
sdd                                   8:48   0 261.4G  0 disk
`-mpathc (dm-2)                     253:2    0 261.4G  0 mpath
  |-VSP_357_VG002-engn_lv002 (dm-7) 253:7    0    20G  0 lvm   /engn002
  `-VSP_357_VG002-logs_lv002 (dm-8) 253:8    0   240G  0 lvm   /logs002
sde                                   8:64   0 273.3G  0 disk
`-mpathe (dm-3)                     253:3    0 273.3G  0 mpath
  |-VSP_357_VG003-engn_lv003 (dm-5) 253:5    0    20G  0 lvm   /engn003
  `-VSP_357_VG003-logs_lv003 (dm-6) 253:6    0   240G  0 lvm   /logs003
sdf                                   8:80   0 273.3G  0 disk
`-mpathe (dm-3)                     253:3    0 273.3G  0 mpath
  |-VSP_357_VG003-engn_lv003 (dm-5) 253:5    0    20G  0 lvm   /engn003
  `-VSP_357_VG003-logs_lv003 (dm-6) 253:6    0   240G  0 lvm   /logs003

★ 부팅디스크 설정 및 udev 정리해보자

sda---> 이렇게 나가는 디스크가 local될수도 hba가 될수도 있음
         (보통부팅시.... pci부터 읽기 때문에, hba가 먼저 잡힘)
그렇게 때문에 관리상 부팅순서를 강제로 바꿔, 로컬디스크를 sda로 보이게 하던지, udev로 alias

-- 실환경에서 명령어 모음들 ----

# sudo multipath -l
mpathe (360060e801660f500000160f50000021e) dm-3 HITACHI,OPEN-V*14
size=273G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=0 status=active
  |- 12:0:0:1 sde 8:64 active undef running
  `- 14:0:0:1 sdf 8:80 active undef running
mpathc (360060e801660f500000160f500001bc9) dm-2 HITACHI,OPEN-V*19
size=261G features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=0 status=active
  |- 12:0:0:0 sdc 8:32 active undef running
  `- 14:0:0:0 sdd 8:48 active undef running

# ls -al /dev/VSP_357_VG002
lrwxrwxrwx  1 root root    7 Jan 13  2018 engn_lv002 -> ../dm-7
lrwxrwxrwx  1 root root    7 Jan 13  2018 logs_lv002 -> ../dm-8

# ls -al /dev/mapper
lrwxrwxrwx  1 root root      7 Jan 13  2018 VSP_357_VG002-engn_lv002 -> ../dm-7
lrwxrwxrwx  1 root root      7 Jan 13  2018 VSP_357_VG002-logs_lv002 -> ../dm-8
lrwxrwxrwx  1 root root      7 Jan 13  2018 VSP_357_VG003-engn_lv003 -> ../dm-5
lrwxrwxrwx  1 root root      7 Jan 13  2018 VSP_357_VG003-logs_lv003 -> ../dm-6
lrwxrwxrwx  1 root root      7 Jan 13  2018 bkupvg-bkup_lv001 -> ../dm-4
crw-rw----  1 root root 10, 58 Jan 14  2018 control
lrwxrwxrwx  1 root root      7 Jan 13  2018 mpathc -> ../dm-2
lrwxrwxrwx  1 root root      7 Jan 13  2018 mpathe -> ../dm-3
lrwxrwxrwx  1 root root      7 Jan 13  2018 rootvg-root_lv -> ../dm-1
lrwxrwxrwx  1 root root      7 Jan 13  2018 rootvg-swap_lv -> ../dm-0

#  ls -al  /dev/block
[ap80850@LGEHCOM402 block]$ ls -al
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:0 -> ../dm-0
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:1 -> ../dm-1
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:2 -> ../dm-2
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:3 -> ../dm-3
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:4 -> ../dm-4
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:5 -> ../dm-5
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:6 -> ../dm-6
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:7 -> ../dm-7
lrwxrwxrwx  1 root root    7 Jan 13  2018 253:8 -> ../dm-8
lrwxrwxrwx  1 root root    6 Jan 13  2018 8:0 -> ../sda
lrwxrwxrwx  1 root root    7 Jan 13  2018 8:1 -> ../sda1
lrwxrwxrwx  1 root root    6 Jan 13  2018 8:16 -> ../sdb
lrwxrwxrwx  1 root root    7 Jan 13  2018 8:17 -> ../sdb1
lrwxrwxrwx  1 root root    7 Jan 13  2018 8:2 -> ../sda2
lrwxrwxrwx  1 root root    6 Jan 13  2018 8:32 -> ../sdc
lrwxrwxrwx  1 root root    6 Jan 13  2018 8:48 -> ../sdd
lrwxrwxrwx  1 root root    6 Jan 13  2018 8:64 -> ../sde

# ls -al /sys/class/block/dm-0/slaves
lrwxrwxrwx 1 root root 0 Feb  6 16:02 sda2 -> ../../../../pci0000:00/0000:00:01.0/0000:03:00.0/host10/target10:2:0/10:2:0:0/block/sda/sda2

# blkid
/dev/mapper/rootvg-root_lv: UUID="e3f649a3-efc7-4d89-bfc1-b25b2aa3d93f" TYPE="ext4"
/dev/mapper/bkupvg-bkup_lv001: UUID="468ce32e-e562-4904-acf2-f99e72b679c9" TYPE="ext4"
/dev/mapper/rootvg-swap_lv: UUID="33004f6f-162d-4a0d-8dee-70bf515008ee" TYPE="swap"
/dev/mapper/VSP_357_VG002-engn_lv002: UUID="0daf4037-6258-4120-985f-92f1764709e1" TYPE="ext4"
/dev/mapper/VSP_357_VG002-logs_lv002: UUID="aadf7d38-c419-4c4c-8bbe-496d2c3a042f" TYPE="ext4"
/dev/mapper/VSP_357_VG003-engn_lv003: UUID="31be09a2-115c-4b54-bcfb-c2360e025644" TYPE="ext4"
/dev/mapper/VSP_357_VG003-logs_lv003: UUID="880ca18d-c738-47b3-b60d-af5da23c25c7" TYPE="ext4"
/dev/sda1: UUID="a5fbe53f-dc0f-402e-bdd5-aa96632933cf" TYPE="ext4"
/dev/sda2: UUID="8Y6a0b-gtip-KFrP-RMmF-QAYQ-es2j-nV1586" TYPE="LVM2_member"
/dev/sdb1: UUID="2iMvlY-f5Zu-BAP3-Jnp9-67RJ-GWev-NUGiK2" TYPE="LVM2_member"
/dev/sdc: UUID="wbFbM8-sCGu-6pkA-C3jK-FL2C-0G1O-Lle8Z0" TYPE="LVM2_member"
/dev/sdd: UUID="wbFbM8-sCGu-6pkA-C3jK-FL2C-0G1O-Lle8Z0" TYPE="LVM2_member"
/dev/sde: UUID="fZYL6X-3l6B-K5DT-YYyX-wwfl-2818-9Vr0r9" TYPE="LVM2_member"
/dev/sdf: UUID="fZYL6X-3l6B-K5DT-YYyX-wwfl-2818-9Vr0r9" TYPE="LVM2_member"
/dev/mapper/mpathc: UUID="wbFbM8-sCGu-6pkA-C3jK-FL2C-0G1O-Lle8Z0" TYPE="LVM2_member"
/dev/mapper/mpathe: UUID="fZYL6X-3l6B-K5DT-YYyX-wwfl-2818-9Vr0r9" TYPE="LVM2_member"

# ls -al /dev/disk
by-id  by-path  by-uuid

# ls -al /dev/disk/by-path
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:03:00.0-scsi-0:2:0:0 -> ../../sda
lrwxrwxrwx 1 root root  10 Jan 13  2018 pci-0000:03:00.0-scsi-0:2:0:0-part1 -> ../../sda1
lrwxrwxrwx 1 root root  10 Jan 13  2018 pci-0000:03:00.0-scsi-0:2:0:0-part2 -> ../../sda2
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:03:00.0-scsi-0:2:1:0 -> ../../sdb
lrwxrwxrwx 1 root root  10 Jan 13  2018 pci-0000:03:00.0-scsi-0:2:1:0-part1 -> ../../sdb1
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:05:00.1-fc-0x50060e801660f522-lun-0 -> ../../sdc
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:05:00.1-fc-0x50060e801660f522-lun-1 -> ../../sde
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:06:00.1-fc-0x50060e801660f532-lun-0 -> ../../sdd
lrwxrwxrwx 1 root root   9 Jan 13  2018 pci-0000:06:00.1-fc-0x50060e801660f532-lun-1 -> ../../sdf

# ls -al /dev/disk/by-uuid
lrwxrwxrwx 1 root root  10 Jan 13  2018 0daf4037-6258-4120-985f-92f1764709e1 -> ../../dm-7
lrwxrwxrwx 1 root root  10 Jan 13  2018 31be09a2-115c-4b54-bcfb-c2360e025644 -> ../../dm-5
lrwxrwxrwx 1 root root  10 Jan 13  2018 33004f6f-162d-4a0d-8dee-70bf515008ee -> ../../dm-0
lrwxrwxrwx 1 root root  10 Jan 13  2018 468ce32e-e562-4904-acf2-f99e72b679c9 -> ../../dm-4
lrwxrwxrwx 1 root root  10 Jan 13  2018 880ca18d-c738-47b3-b60d-af5da23c25c7 -> ../../dm-6
lrwxrwxrwx 1 root root  10 Jan 13  2018 a5fbe53f-dc0f-402e-bdd5-aa96632933cf -> ../../sda1
lrwxrwxrwx 1 root root  10 Jan 13  2018 aadf7d38-c419-4c4c-8bbe-496d2c3a042f -> ../../dm-8
lrwxrwxrwx 1 root root  10 Jan 13  2018 e3f649a3-efc7-4d89-bfc1-b25b2aa3d93f -> ../../dm-1

# ls -al /dev/disk/by-id 
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-VSP_357_VG002-engn_lv002 -> ../../dm-7
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-VSP_357_VG002-logs_lv002 -> ../../dm-8
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-VSP_357_VG003-engn_lv003 -> ../../dm-5
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-VSP_357_VG003-logs_lv003 -> ../../dm-6
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-bkupvg-bkup_lv001 -> ../../dm-4
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-mpathc -> ../../dm-2
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-mpathe -> ../../dm-3
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-rootvg-root_lv -> ../../dm-1
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-name-rootvg-swap_lv -> ../../dm-0
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-3PtrluQktByMYtXp1AMhf6GENNLIfg8WTVBH4Nh5XO61sWgVD4WBpB2J0sIlIbND -> ../../dm-7
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-3PtrluQktByMYtXp1AMhf6GENNLIfg8Wd5jomXUJqhF3QVSizAs3iIGZNTl0LkAO -> ../../dm-8
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-AMVRD41VzxD41ieHK6HVuk4iUiT2Q2dD6rC9dx7ixaEcWFNdlIR3R51a6GDJ2dyP -> ../../dm-4
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-DS33bEvCfdsuEnZlXzPYMMqxF20kP4FnIaMBC222Nrm3iNRYl0hFUbGoppSRJYqS -> ../../dm-6
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-DS33bEvCfdsuEnZlXzPYMMqxF20kP4FnNsHsGwS2odkgtF8ygaGlc3yp77YLPxfJ -> ../../dm-5
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-vjSBjIKCiD4jFWMc2UCaNax8v6eYo1ZV8TYrFBEsxwWV3BG6gRVmil7OFMQLl7eO -> ../../dm-1
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-LVM-vjSBjIKCiD4jFWMc2UCaNax8v6eYo1ZVc4XEP3Okd1Ewpw6jvBeVd5H28M0YuhAh -> ../../dm-0
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-mpath-360060e801660f500000160f50000021e -> ../../dm-3
lrwxrwxrwx 1 root root  10 Jan 13  2018 dm-uuid-mpath-360060e801660f500000160f500001bc9 -> ../../dm-2
lrwxrwxrwx 1 root root  10 Jan 13  2018 lvm-pv-uuid-2iMvlY-f5Zu-BAP3-Jnp9-67RJ-GWev-NUGiK2 -> ../../sdb1
lrwxrwxrwx 1 root root  10 Jan 13  2018 lvm-pv-uuid-8Y6a0b-gtip-KFrP-RMmF-QAYQ-es2j-nV1586 -> ../../sda2
lrwxrwxrwx 1 root root  10 Jan 13  2018 lvm-pv-uuid-fZYL6X-3l6B-K5DT-YYyX-wwfl-2818-9Vr0r9 -> ../../dm-3
lrwxrwxrwx 1 root root  10 Jan 13  2018 lvm-pv-uuid-wbFbM8-sCGu-6pkA-C3jK-FL2C-0G1O-Lle8Z0 -> ../../dm-2
lrwxrwxrwx 1 root root   9 Jan 13  2018 scsi-360060e801660f500000160f50000021e -> ../../sde
lrwxrwxrwx 1 root root   9 Jan 13  2018 scsi-360060e801660f500000160f500001bc9 -> ../../sdd
lrwxrwxrwx 1 root root   9 Jan 13  2018 scsi-361866da07e0d7a001fc081ee02ff3743 -> ../../sda
lrwxrwxrwx 1 root root  10 Jan 13  2018 scsi-361866da07e0d7a001fc081ee02ff3743-part1 -> ../../sda1
lrwxrwxrwx 1 root root  10 Jan 13  2018 scsi-361866da07e0d7a001fc081ee02ff3743-part2 -> ../../sda2
lrwxrwxrwx 1 root root   9 Jan 13  2018 scsi-361866da07e0d7a001fc082e90534693b -> ../../sdb
lrwxrwxrwx 1 root root  10 Jan 13  2018 scsi-361866da07e0d7a001fc082e90534693b-part1 -> ../../sdb1
lrwxrwxrwx 1 root root   9 Jan 13  2018 wwn-0x60060e801660f500000160f50000021e -> ../../sde
lrwxrwxrwx 1 root root   9 Jan 13  2018 wwn-0x60060e801660f500000160f500001bc9 -> ../../sdd
lrwxrwxrwx 1 root root   9 Jan 13  2018 wwn-0x61866da07e0d7a001fc081ee02ff3743 -> ../../sda
lrwxrwxrwx 1 root root  10 Jan 13  2018 wwn-0x61866da07e0d7a001fc081ee02ff3743-part1 -> ../../sda1
lrwxrwxrwx 1 root root  10 Jan 13  2018 wwn-0x61866da07e0d7a001fc081ee02ff3743-part2 -> ../../sda2
lrwxrwxrwx 1 root root   9 Jan 13  2018 wwn-0x61866da07e0d7a001fc082e90534693b -> ../../sdb
lrwxrwxrwx 1 root root  10 Jan 13  2018 wwn-0x61866da07e0d7a001fc082e90534693b-part1 -> ../../sdb1