Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between dm and md in Linux kernel?

Tags:

linux-kernel

What is the difference between dm (dmsetup) and md (mdadm) modules in Linux kernel ? [both seems to be a logical volume manager] oh yeah and there is lvm (lvm) also. What are the difference between all this ?

like image 547
user3513655 Avatar asked Apr 19 '14 00:04

user3513655


1 Answers

md is multiple devices. It's a RAID implementation in Linux kernel available since kernel release 2.0. It allows you to create RAID level 0, 10, 4, 5 and 6. It has various optimizations like utilizing SSE and MMX instructions. It's a standart software RAID in Linux.

dm is device mapper. It's Linux kernel framework that allows you to, well, map one device on another devices (one or many). This works as creating virtual device (mapped device) that you can access in /dev/mapper directory. All I/O to that device will be mapped to other devices. Reasons for device mapper is that there are many cases where you need to map devices, but you would like to reuse code.

There are several drivers (called dm targets) utilizing device mapper, for example:

  • dm-linear - map one device to another linearly. That means your new device will translate I/O requests to underlying device with some LBA shift. For example, when you read at LBA 1000 from /dev/mapper/linear your read will be done at LBA 1050 from /dev/sdd.
  • dm-stripe - map one device to multiple devices as in RAID 0.

Difference between dm-stripe and md RAID level 0 is not that big - it's just different implementations, but I believe that md RAID has better performance.

And finally, lvm is userspace toolset that provide logical volume management facilities on linux. It uses device mapper to map volume groups and logical volumes to physical devices.

And there is a special confusing case - dm-raid, you can read about it here

like image 129
Alexander Dzyoba Avatar answered Sep 30 '22 21:09

Alexander Dzyoba