Device Mapper learning in Linux, devicemapper

Source: Internet
Author: User

Device Mapper learning in Linux, devicemapper

In linux, when you use some commands (such as nmon and iostat), you may see some devices named dm-xx. What exactly are these devices, what is the relationship with the disk? I was wondering when I didn't know it before. in fact, dm is the abbreviation of Device Mapper. Device Mapper is a ing Framework mechanism provided in the Linux 2.6 kernel from a logical Device to a physical Device. Under this mechanism, users can easily develop storage resource management policies based on their own needs. Currently, logical Volume Manager in Linux is popular, such as LVM2 (Linux Volume Manager 2 version) and EVMS (Enterprise Volume Management System) and dmraid (Device Mapper Raid Tool) are all implemented based on this mechanism. The most comprehensive information about Device Mapper is the Device Mapper mechanism in IBM Linux kernel.

The theoretical knowledge is only for those who have reached a certain height and depth and want to study it in depth. Let's take a look at some questions and problems encountered in simple operations, as shown in, what are the mappings between dm-0, dm-1, dm-xx, and those disks? What do they mean? First let's look at the dm-0, dm-1, dm-2, the three file Devices

[root@mylnx01 ~]# ls /dev/dm*
/dev/dm-0  /dev/dm-1  /dev/dm-2
[root@mylnx01 ~]# ll /dev/dm*
brw-rw---- 1 root root 253, 0 Dec  7 16:45 /dev/dm-0
brw-rw---- 1 root root 253, 1 Dec  7 16:45 /dev/dm-1
brw-rw---- 1 root root 253, 2 Dec  7 16:45 /dev/dm-2
[root@mylnx01 ~]# 

Or you can see it using the fdisk-l command.

[root@mylnx01 ~]# fdisk -l
 
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        6788    54420187+  8e  Linux LVM
/dev/sda3            6789       10443    29358787+  83  Linux
 
.....................................................................
.....................................................................
 
Disk /dev/dm-0: 107.2 GB, 107206410240 bytes
255 heads, 63 sectors/track, 13033 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-0 doesn't contain a valid partition table
 
Disk /dev/dm-1: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-1 doesn't contain a valid partition table
 
Disk /dev/dm-2: 30.0 GB, 30031216640 bytes
255 heads, 63 sectors/track, 3651 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-2 doesn't contain a valid partition table

Although/dev/below there's no so-called dm-3, dm-4 ...., generally, you can use commands such as nmon and iostat. In fact, you can also view the devices corresponding to these DMSs, which are generally located under/dev/mapper.

[root@mylnx01 VolGroup01]# ls -l /dev/mapper
total 0
crw------- 1 root root  10, 62 Dec  7 16:45 control
brw-rw---- 1 root disk 253,  0 Dec  7 16:45 VolGroup00-LogVol00
brw-rw---- 1 root disk 253,  2 Dec  7 16:45 VolGroup00-LogVol00--PS--user--snapshot
brw-rw---- 1 root disk 253,  1 Dec  7 16:45 VolGroup00-LogVol01
brw-rw---- 1 root disk 253, 11 Dec  7 16:45 VolGroup01-LogVol00
brw-rw---- 1 root disk 253, 12 Dec  7 16:45 VolGroup01-LogVol00--PS--user--snapshot
brw-rw---- 1 root disk 253,  9 Dec  7 16:45 VolGroup02-LogVol00
brw-rw---- 1 root disk 253, 10 Dec  7 16:45 VolGroup02-LogVol00--PS--user--snapshot
brw-rw---- 1 root disk 253,  7 Dec  7 16:45 VolGroup03-LogVol00
brw-rw---- 1 root disk 253,  8 Dec  7 16:45 VolGroup03-LogVol00--PS--user--snapshot
brw-rw---- 1 root disk 253,  5 Dec  7 16:45 VolGroup04-LogVol00
brw-rw---- 1 root disk 253,  6 Dec  7 16:45 VolGroup04-LogVol00--PS--user--snapshot
brw-rw---- 1 root disk 253,  3 Dec  7 16:45 VolGroup05-LogVol00
brw-rw---- 1 root disk 253,  4 Dec  7 16:45 VolGroup05-LogVol00--PS--user--snapshot
 
[root@mylnx01 ~]# ls /dev/VolGroup*
/dev/VolGroup00:
LogVol00  LogVol00-PS-user-snapshot  LogVol01
 
/dev/VolGroup01:
LogVol00  LogVol00-PS-user-snapshot
 
/dev/VolGroup02:
LogVol00  LogVol00-PS-user-snapshot
 
/dev/VolGroup03:
LogVol00  LogVol00-PS-user-snapshot
 
/dev/VolGroup04:
LogVol00  LogVol00-PS-user-snapshot
 
/dev/VolGroup05:
LogVol00  LogVol00-PS-user-snapshot
[root@mylnx01 ~]# 
 
[root@mylnx01 ~]# cd /dev/VolGroup01
[root@mylnx01 VolGroup01]# ll
total 0
lrwxrwxrwx 1 root root 31 Dec  7 16:45 LogVol00 -> /dev/mapper/VolGroup01-LogVol00
lrwxrwxrwx 1 root root 51 Dec  7 16:45 LogVol00-PS-user-snapshot -> /dev/mapper/VolGroup01-LogVol00--PS--user--snapshot
[root@mylnx01 VolGroup01]# 

In fact we can use the command dmsetup ls to view the dm-0, dm-1, dm-x corresponding to the device, where the number after dm corresponds to the number after (253, xx. As shown below

[root@mylnx01 ~]# dmsetup ls 
VolGroup03-LogVol00--PS--user--snapshot (253, 8)
VolGroup00-LogVol00--PS--user--snapshot (253, 2)
VolGroup05-LogVol00     (253, 3)
VolGroup04-LogVol00     (253, 5)
VolGroup05-LogVol00--PS--user--snapshot (253, 4)
VolGroup03-LogVol00     (253, 7)
VolGroup02-LogVol00--PS--user--snapshot (253, 10)
VolGroup02-LogVol00     (253, 9)
VolGroup01-LogVol00     (253, 11)
VolGroup00-LogVol01     (253, 1)
VolGroup04-LogVol00--PS--user--snapshot (253, 6)
VolGroup00-LogVol00     (253, 0)
VolGroup01-LogVol00--PS--user--snapshot (253, 12)
[root@mylnx01 ~]#

The number after 253 corresponds to the number after dm. If you want to view the specific information, you can use the command dmsetup info to see the following details.

[root@mylnx01 ~]# more /etc/fstab 
/dev/VolGroup00/LogVol00 /                      ext3    defaults        1 1
/dev/VolGroup01/LogVol00 /u01                   ext3    defaults        1 1
/dev/VolGroup02/LogVol00 /u02                   ext3    defaults        1 1
/dev/VolGroup03/LogVol00 /u03                   ext3    defaults        1 1
/dev/VolGroup04/LogVol00 /u04                   ext3    defaults        1 1
/dev/VolGroup05/LogVol00 /u05                   ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

With the above information we can know dm-0, dm-1, dm-2 corresponding to some of the following equipment respectively

Dm-0 corresponds to VolGroup00-LogVol00 corresponding to LVM root directory/

Dm-1 for LVM VolGroup00-LogVol01 for swap

Dm-2 for LMV VolGroup00-LogVol00 -- PS -- user -- snapshot

........................................ .................

References:

Http://www.ibm.com/developerworks/cn/linux/l-devmapper/index.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.