dm-x (Device Mapper) 장치의 실제 장치명 찾는 방법
리눅스에서 Device Mapper는 LVM, 소프트웨어레이드, multipath, 파티션암호화 등에 사용된다.
운영중인 서버가 갑작스런 정전으로 인해 EXT3 파일시스템의 문제 발생으로 아래와 같은 커널로그가 로깅되었고 부팅에 장애 발생.
문재가 발생한 device가 어떤것인지 명확하게 나오지 않고, dm-1(DeviceMapper-1)으로만 표기되었다.
참고로 해당 시스템의 커널은 2.6.9-78.0.22.ELsmp i686 이다.

로그 확인하기
[root@Sample-local ~]# cat /var/log/messages
Feb 26 11:17:31 Sample-local kernel: EXT3-fs warning (device dm-1): ext3_unlink: Deleting nonexistent file (111493861), 0
Feb 26 11:17:31 Sample-local kernel: EXT3-fs warning (device dm-1): ext3_unlink: Deleting nonexistent file (111493860), 0
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407252
Feb 26 11:17:31 Sample-local kernel: Aborting journal on device dm-1.
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407253
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407254
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407255
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407256
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407257
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407258
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407259
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_free_blocks_sb: bit already cleared for block 224407260
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_reserve_inode_write: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_truncate: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_reserve_inode_write: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_orphan_del: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_reserve_inode_write: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in ext3_delete_inode: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: ext3_abort called.
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1): ext3_journal_start_sb: Detected aborted journal
Feb 26 11:17:31 Sample-local kernel: Remounting filesystem read-only
Feb 26 11:17:31 Sample-local kernel: EXT3-fs error (device dm-1) in start_transaction: Journal has aborted
Feb 26 11:17:31 Sample-local kernel: __journal_remove_journal_head: freeing b_committed_data
.
.
.
Feb 26 14:02:11 Sample-local kernel: EXT3-fs: INFO: recovery required on readonly filesystem.
Feb 26 14:02:11 Sample-local kernel: EXT3-fs: write access will be enabled during recovery.

현재 이 시스템의 Device Mapper에 의해 마운트되는 장치는 LVM 볼륨 두가지가 있다.
문제의 장치는 둘중에 하나다. 그런데 아래와 같이 봐선 위 로그를 바탕으로 장치 매칭이 불가능하다.
[root@Sample-local ~]# lvscan
  ACTIVE            '/dev/lvm_1/data1' [3.64 TB] inherit
  ACTIVE            '/dev/lvm_0/home' [3.63 TB] inherit
[root@Sample-local ~]# ls -la /dev/dm-*
brw-r-----  1 root root 253, 0  2월 26 14:02 /dev/dm-0
brw-r-----  1 root root 253, 1  2월 26 14:02 /dev/dm-1

/dev/dm-1 장치가 어떤 장치인지 확인하기. 확인하는 방법은 두가지가 있다.
1) 첫번째 방법 - Block device와 LV 장치 값을 빼내 매칭 시킨다.
[root@Sample-local ~]# lvdisplay|awk '/LV Name/{n=$3} /Block device/{d=$3; sub(".*:","dm-",d); print d,n;}'
dm-0 /dev/lvm_1/data1
dm-1 /dev/lvm_0/home  --> 이 볼륨의 파일시스템에서 문제가 발생한 것이다.

위 결과값은 lvdisplay 정보값에서 awk를 이용하여 재조합한것일 뿐이다.
[root@Sample-local ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/lvm_1/data1
  VG Name                lvm_1
  LV UUID                iy1ePF-VCh9-DuRA-WI09-Zkru-s9SV-MuoKqG
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.64 TB
  Current LE             953863
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

 

  --- Logical volume ---
  LV Name                /dev/lvm_0/home
  VG Name                lvm_0
  LV UUID                ajT6EZ-byCf-Z19B-tH0n-V7r2-sypr-OwU1UH
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.63 TB
  Current LE             952737
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

즉, 아래와 같다.
Block device           253:0   --> dm-0 (/dev/lvm_1/data1)
Block device           253:1   --> dm-1 (/dev/lvm_0/home)
--> 253:x와 dm-x의 x가 매칭된다.

2) 두번째 방법 - 마운트를 해서 디렉토리나 파일내용을 확인
[root@Sample-local ~]# mount -text3 /dev/dm-1 /mnt
[root@Sample-local ~]# ls -la /mnt

/dev/lvm_0/home 을 마운트 하는 방법 3가지
[root@Sample-local ~]# mount /dev/lvm_0/home /home
[root@Sample-local ~]# mount /dev/mapper/lvm_0-home /home
[root@Sample-local ~]# mount /dev/dm-1 /home

이것과 관련된 기타 명령어들
[root@Sample-local ~]# lvmdiskscan
[root@Sample-local ~]# blockdev --report
[root@Sample-local ~]# dmsetup table
[root@Sample-local ~]# dmsetup status
[root@Sample-local ~]# dmsetup ls

/dev/dm-0 /dev/dm-1 장치 매칭

/dev/dm-0 /dev/dm-1 장치 매칭”에 대한 1개의 생각

  • 2018년 4월 18일 2:22 오후
    고유주소

    저 dm-X를 유동적으로 바뀌지 않게 하려면 어떻게 해야되요?

    응답

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다