This discussion is archived
2 Replies Latest reply: Oct 8, 2012 6:17 PM by Dude! RSS

BtrFS and Device Mapper (DM)

Dude! Guru
Currently Being Moderated
Hello,

I learned from a previous thread here that BtrFS should not be put on a LVM volume as both provide similar technologies that compete with each other. What about Device Mapper (DM) and BtrFS under Oracle Linux 6.3? I guess both share similar technologies as well, like Snapshot. Albeit DM is probably less sophisticated. However, I was wondering whether BtrFS and Device Mapper should be used together.

According to https://www.suse.com/documentation/sles11/singlehtml/stor_admin/stor_admin.html. +"You can create BtrFS on Multiple Devices (MD) and Device Mapper (DM) storage configurations by using the YaST2 Partitioner."+ So this tells me that DM and BtrFS can be used together. And I guess one example might be disk encryption using cryptsetup, which uses device mapper. Is this correct?

If I'm not mistaken, then Device Mapper support is in the Linux 2.6 kernel, and /dev/mapper devices are typcially setup by LVM and cryptsetup, but I can also create them using dmsetup. Let's say I have e.g. /dev/sda2 and I want to map it to a DM virtual device named root, then initialize it using BtrFS:

<pre>
dmsetup create root table "0 $(blockdev getsz /dev/sda2) linear /dev/sda2 0"
mkfs.btrfs /dev/mapper/root
</pre>

The command works, but I might doing something wrong, because /dev/mapper/root does not survive a system restart. Unfortunately I have not found anything useful about it in Google yet. Anyway, does this make any sense?

Thanks!
  • 1. Re: BtrFS and Device Mapper (DM)
    Avi Miller Guru
    Currently Being Moderated
    Dude wrote:
    I learned from a previous thread here that BtrFS should not be put on a LVM volume as both provide similar technologies that compete with each other. What about Device Mapper (DM) and BtrFS under Oracle Linux 6.3?
    btrfs doesn't do multipathing, so if you have multiple paths, you would still need to use it. There are plenty of messages on the btrfs-devel mailing list about getting btrfs to work with cryptsetup and such, so I suggest you check the archives there as well. You may need a newer kernel, though -- I can't remember exactly how the setup worked.
  • 2. Re: BtrFS and Device Mapper (DM)
    Dude! Guru
    Currently Being Moderated
    I was actually aware of Multipath, but wasn't aware until recently that DM-Crypt, DM-Multipath and LVM2 are all using the same type of Device Mapper function that is provided by the kernel. That's probably why it's called DM Multipath ;-)

    Apparently the system startup of any such physical to virtual mapped devices is a challenge for the boot process. The system BIOS or adapter firmware does not understand nor generate any of the special devices that Linux consruct and requires by software. Hence the business of initrd and initramfs, which are mini startup systems to provide the necessary drivers to find peripheral or to create the Linux devices and environment.

    I read that there are 2 ways for Linux to find the root device: Either by modifying the startup script inside the initrd or initramfs system, or to supply kernel boot parameters. The later will obviously need kernel builtin support.

    Why I started to wonder about Device Mapper? Please see the below kernel boot parameters:

    OL5: root=/dev/VolGroup00/LogVol00
    OL6: root=/dev/mapper/vg_vm004-lv_root

    So it seems that starting with OL6, the configuration uses a Device Mapper device name also for the LVM groups and volumes. Is this DM Multipath or just basic Device Mapper?

    I have not found any conclusive information yet but my guess is that there must be something scanning for LVM devices during startup and constructing the /dev/mapper device based on the info received.

    I also wonder what I would have to do to use /dev/mapper for BtrFS, not necessarily using Multipath. Apparently no one is doing it or I cannot find the information. Perhaps I would have to modify the startup script inside the initrd startup disk?

    I think the whole thing about the system startup and how to implement boot support for various devices under Linux is quite complex and not very transparent.

    Edited by: Dude on Oct 8, 2012 6:17 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points