Here is the documentation for using device-mapper linear: https://www.kernel.org/doc/Documentation/device-mapper/linear.txt
I am trying to understand this documentation. It says it takes 2 parameters: dev path and offset. Yet all the examples I find show other stuff both in front of and after linear
. You can see examples in the documentation and here: http://pig.made-it.com/devicemapper.html
Here is an example from that last link:
echo 0 $(blockdev --getsize /dev/loop1) linear /dev/loop1 0 > /tmp/onedisk
SIZE1=$(blockdev --getsize /dev/loop1)
SIZE2=$(blockdev --getsize /dev/loop2)
echo ${SIZE1} ${SIZE2} linear /dev/loop2 0 >> /tmp/onedisk
dmsetup create twoasone /tmp/onedisk
As far as I can tell, the first line is taking the output of some stuff and putting it into /tmp/onedisk. Why is there stuff in front of linear, and what does it do?
Ok, I have been looking at this a for a while now. My guess is that this is basically three parameters to echo.
0
$(blockdev --getsize /dev/loop1)
linear /dev/loop1 0
The output of echo is then stored in /tmp/onedisk. The contends of tmp/ondisk eventually become a parameter for dmsetup create. Is that correct, and am I correct in thinking that really I need to be looking at the documentation for dmsetup create if I want to understand why a 0 and size are being stored at the beginning of /tmp/onedisk?