我无法弄清楚不同逻辑和物理块设备名称之间的映射。 “cat /proc/diskstats”的输出是:
104 0 cciss/c0d0 ...
104 1 cciss/c0d0p1 ...
104 2 cciss/c0d0p2 ...
104 16 cciss/c0d1 ...
253 0 dm-0 ...
253 1 dm-1 ...
253 2 dm-2 ...
253 3 dm-3 ...
“df -h”的输出是:
/dev/cciss/c0d0p1 99M 39M 56M 42% /boot
/dev/mapper/VolGroup01-LogVol02 908G 760G 103G 89% /home
/dev/mapper/VolGroup01-LogVol03 193G 181G 2.6G 99% /opt
/dev/mapper/VolGroup00-LogVol00 54G 11G 41G 21% /
在哪里可以找到 "cciss" 、 "dm-#" 和 "VolGroup##" 之间的映射?
谢谢
答案1
有方便的dmsetup ls --tree
和lsblk
实用的。
答案2
我刚刚遇到这个问题,所以我将在这里记录对我有帮助的内容。
dmsetup ls --tree
poise 的答案是正确的,如果您知道如何解释输出, 您可以从中获取所需的所有信息。
cciss 是设备名称,即您的实际磁盘。这手册页说得很好,但我将在这里复制相关部分:
Device nodes
The device naming scheme is as follows:
Major numbers:
104 cciss0
105 cciss1
106 cciss2
105 cciss3
108 cciss4
109 cciss5
110 cciss6
111 cciss7
Minor numbers:
b7 b6 b5 b4 b3 b2 b1 b0
|----+----| |----+----|
| |
| +-------- Partition ID (0=wholedev, 1-15 partition)
|
+-------------------- Logical Volume number
The device naming scheme is:
/dev/cciss/c0d0 Controller 0, disk 0, whole device
/dev/cciss/c0d0p1 Controller 0, disk 0, partition 1
/dev/cciss/c0d0p2 Controller 0, disk 0, partition 2
/dev/cciss/c0d0p3 Controller 0, disk 0, partition 3
/dev/cciss/c1d1 Controller 1, disk 1, whole device
/dev/cciss/c1d1p1 Controller 1, disk 1, partition 1
/dev/cciss/c1d1p2 Controller 1, disk 1, partition 2
/dev/cciss/c1d1p3 Controller 1, disk 1, partition 3
“dm-#”是设备映射器编号。映射 DM 编号的最简单方法是运行lvdisplay
,它会显示逻辑卷名称、所属卷组以及块设备。在“块设备”行中,冒号后面列出的值是 DM 编号。
root@centos:/dev > lvdisplay /dev/vg0/opt
--- Logical volume ---
LV Name /dev/vg0/opt
VG Name vg0
LV UUID ObffAT-txIn-5Rwy-bW5s-gekn-VLZv-71mDZi
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5
这很好地映射回了输出dmsetup ls --tree
vg0-opt (253:5)
└─ (104:3)
您还可以通过运行查看 DM 号码映射ls -lrt /dev/mapper
。
root@centos:/dev > ls -lrt /dev/mapper
total 0
crw------- 1 root root 10, 60 Aug 29 2013 control
brw-rw---- 1 root disk 253, 0 Aug 29 2013 vg0-root
brw-rw---- 1 root disk 253, 1 Aug 29 2013 vg0-usr
brw-rw---- 1 root disk 253, 2 Aug 29 2013 vg0-tmp
brw-rw---- 1 root disk 253, 3 Aug 29 2013 vg0-var
brw-rw---- 1 root disk 253, 4 Aug 29 2013 vg0-home
brw-rw---- 1 root disk 253, 5 Aug 29 2013 vg0-opt
第六列列出了 DM 编号。因此,对于我的服务器,vg0-opt 安装在 /opt 上,并映射回 DM-5。
答案3
使用dmsetup ls --tree -o blkdevname
。
[root@redhat7 Packages]# dmsetup ls --tree -o blkdevname
rhel-swap <dm-1> (253:1)
└─ <sda2> (8:2)
rhel-root <dm-0> (253:0)
└─ <sda2> (8:2)
oraclevg-oraclelv <dm-2> (253:2)
└─ <sdb> (8:16)
答案4
@Jon Buys 和 @poige 的答案是正确的,但至少在具有相对较新内核的系统上,它甚至更简单。
中的条目/dev/mapper
只是指向dm-x
中的设备的软链接/dev
,因此您应该需要的是:
ls -l /dev/mapper
例如,在我的系统上,这显示:
# ls -l /dev/mapper/
total 0
crw-------. 1 root root 10, 236 Dec 12 10:11 control
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_cache_pool_home_cdata -> ../dm-3
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_cache_pool_home_cmeta -> ../dm-4
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_cache_pool_var_cdata -> ../dm-7
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_cache_pool_var_cmeta -> ../dm-8
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_home -> ../dm-6
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_home_corig -> ../dm-5
lrwxrwxrwx. 1 root root 8 Dec 12 10:11 vg_raid10-lv_var -> ../dm-10
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_raid10-lv_var_corig -> ../dm-9
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_ssd-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Dec 12 10:11 vg_ssd-lv_swap -> ../dm-1
lrwxrwxrwx. 1 root root 8 Dec 27 20:00 vg_ssd_sata-docker--pool -> ../dm-13
lrwxrwxrwx. 1 root root 8 Dec 27 20:00 vg_ssd_sata-docker--pool_tdata -> ../dm-12
lrwxrwxrwx. 1 root root 8 Dec 27 20:00 vg_ssd_sata-docker--pool_tmeta -> ../dm-11
lrwxrwxrwx. 1 root root 7 Dec 27 20:00 vg_ssd_sata-lv_scratch -> ../dm-2
lrwxrwxrwx. 1 root root 8 Dec 27 20:00 vg_ssd_sata-lv_vms -> ../dm-14
如果您ls
没有帮助并且不显示软链接,请尝试以下操作:
for x in /dev/mapper/*; do echo "$(realpath $x) -> $x"; done;
应该输出类似:
/dev/mapper/control -> /dev/mapper/control
/dev/dm-3 -> /dev/mapper/vg_raid10-lv_cache_pool_home_cdata
/dev/dm-4 -> /dev/mapper/vg_raid10-lv_cache_pool_home_cmeta
...
如果您想找到特定的映射,例如dm-6
:
# (for x in /dev/mapper/*; do echo "$(realpath $x) -> $x"; done;) | grep dm-6
/dev/dm-6 -> /dev/mapper/vg_raid10-lv_home