17
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LVM の dm-0 とかの表示をデバイス名に読み替える

Last updated at Posted at 2013-01-31

参考 → linux - What is this dm-0 device? - Super User

# lvdisplay|awk  '/LV Name/{n=$3} /Block device/{d=$3; sub(".*:","dm-",d); print d,n;}'
dm-0 /dev/vg00/lv_root
dm-1 /dev/vg00/lv_swap

lvdisplay の応答が遅くてもっさりするので dmsetup ls を使うように変更。

# dmsetup ls | perl -ne 'print "dm-$2\t$1\n" if /^(\S+)\s+\(\d+[:,]\s*(\d+)\)$/'
dm-1	vg00-lv_swap
dm-0	vg00-lv_root

あるいは dmsetup ls --tree でも可。

# dmsetup ls --tree | perl -ne 'print "dm-$2\t$1\n" if /^(\S+)\s+\(\d+:(\d+)\)$/'
dm-1	vg00-lv_swap
dm-0	vg00-lv_root

CentOS6 なら /sys/block/dm-*/dm/name を見るだけでOK。

# for i in $(ls -d /sys/block/dm-*); do echo -e "$(basename $i)\t$(cat $i/dm/name)"; done
dm-0	vg00-lv_root
dm-1    vg00-lv_swap

@satoh_fumiyasu さんに指摘いただいて追記。RHEL6 や CentOS6 なら ls -l /dev/mapper/ だけで人が見る分には十分。

# ls -l /dev/mapper/
lrwxrwxrwx 1 root root      7 11月 12 20:08 2012 vg00-lv_root -> ../dm-0
lrwxrwxrwx 1 root root      7 11月 12 20:08 2012 vg00-lv_swap -> ../dm-1
17
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?