Http://www.ibm.com/developerworks/cn/linux/l-devmapper/index.html
This page introduces some principles. You can take a look.
Dmsetup command
Displays information about the current device mapper.
Dmsetup ls
Dmsetup info
Dmsetup status
Display Device Dependencies
Dmsetup deps
Sda4_crypt: 1 dependencies: (8, 4)
Vg_richard-lv_home: 1 dependencies: (253, 0)
Vg_richard-lv_swap: 1 dependencies: (253, 0)
Vg_richard-lv_root: 1 dependencies: (253, 0)
Let's take a look at the files under/dev.
Brw-rw ---- 1 root disk 8, 4 2012-09-03 09:16 sda4
Brw-rw ---- 1 root disk 253, 0 2012-09-03 dm-0
Brw-rw ---- 1 root disk 253, 1 2012-09-03 dm-1
Brw-rw ---- 1 root disk 253, 2 2012-09-03 dm-2
Brw-rw ---- 1 root disk 253, 3 2012-09-03 dm-3
That is, sda4_crypt depends on sda4.
Vg_ricard-lv_home depends on dm-0
Show table information
Dmsetup table
Create a linear device
Dmsetup create dm-name dm-table
Dm-name is the name of the device to be created. If it succeeds, the file with this name will be generated in the/dev/mapper/directory.
Dm-table stores the mapping table of the map device.
An example of a Simple dm-table is as follows:
Number of start slice slices linearly map the start slice on the target device
0 1025 linear/dev/sdb2 0
1025 1025 linear/dev/sdc2 0
The sector size of a block can be obtained using blockdev -- getsize/dev/sdb2.
If the disk is just partitioned, use partprobe to update it.
View the write sequence of the linear device
Create a file system for the newly generated device and mount it to a directory.
Cd to this directory, run
Dd if =/dev/zero of = test
This command will run until the disk is fully written.
Run before running
Watch-n 1 iostat/dev/sdb2/dev/sdc2
To observe the disk read/write status.
It can be found that the write process is: first write to/dev/sdb2, then write to/dev/sdc2.
This process is consistent with the concept of linear.