iostat与df -h,dm-0的对应关系

张芳涛 2015-08-19

[root@master~]#cd/dev/mapper/

[root@master/dev/mapper]#ll

总用量0

crw-rw----1rootroot10,587月2317:52control

lrwxrwxrwx1rootroot77月2309:52vg_master-lv_home->../dm-2

lrwxrwxrwx1rootroot77月2309:52vg_master-lv_root->../dm-0

lrwxrwxrwx1rootroot77月2309:52vg_master-lv_swap->../dm-1

[root@master/dev/mapper]#dmsetupls

vg_master-lv_swap(253:1)

vg_master-lv_root(253:0)

vg_master-lv_home(253:2)

Youhavenewmailin/var/spool/mail/root

[root@master/dev/mapper]#cd/dev/vg_master/

[root@master/dev/vg_master]#ll

总用量0

lrwxrwxrwx1rootroot77月2309:52lv_home->../dm-2

lrwxrwxrwx1rootroot77月2309:52lv_root->../dm-0

lrwxrwxrwx1rootroot77月2309:52lv_swap->../dm-1

[root@master/dev/vg_master]#df-Plh

文件系统容量已用可用已用%%挂载点

/dev/mapper/vg_master-lv_root50G7.5G40G16%/

tmpfs24G024G0%/dev/shm

/dev/sda2485M37M423M8%/boot

/dev/sda1200M264K200M1%/boot/efi

/dev/mapper/vg_master-lv_home201G188M191G1%/home

/dev/sdb1916G208G663G24%/r2

从以下可以看到,dm-0对应根目录/,dm-2对应homed目录

#处理dm,虚拟卷
    local dm_content=`dmsetup ls | grep -v 'No devices' |awk '{print $1,$2}'`
    #vg_master-lv_swap (253:1)
    #vg_master-lv_root (253:0)
    #vg_master-lv_home (253:2)
    declare -A map_dm
    IFS=$'\n'
    for line in $dm_content
    do
        IFS=$' '
        local dms=($line)
        local dir_name=${dms[0]}
        local dm_str=${dms[1]}
        dm_str="dm-"`echo "$dm_str" | awk -F':' '{print $2}' | awk -F')' '{print $1}'`
        #echo "$dir_name -> $dm_str"
        map_dm[$dm_str]=$dir_name
    done

相关推荐