[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: understanding dmsetup



On 17 August 2013 19:44, Anders Ingemann <anders@ingemann.de> wrote:
On 17 August 2013 17:47, Anders Ingemann <anders@ingemann.de> wrote:
So right now I am trying to install grub the proper way on a loop device.
To that end I am following this guide: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
I understand pretty much everything with the exception of the last '0' in the table info that is passed to `dmsetup create hda'.
As far as I can see the table consists of the following:
echo '0 20971520 linear 7:0 0' | sudo dmsetup create hda
      |    |       |    | | |
      |    |       |    | | +--- ???
      |    |       |    | +--- minor device number
      |    |       |    +--- major device number
      |    |       +--- target type
      |    +--- num sectors
      +---start sector


What does the last '0' do?!

Anders

Ah, I figured it out myself. It's the "start sector". The first '0' is the "logical" start sector.
That answer poses another question, what the hell is the difference between the "logical start sector" and the "start sector"?
The latter seems to be somehow associated with the linear target_type.


Aaand, I figured out the last one myself as well :-)
I thought I would post my findings hear just in case somebody stumbles over the archives in a web search.

The logical start sector is the sector at which a mapped volume should start at in the new volume (it's the first argument in the above example, incorrectly labeled start sector).
So if that value is, say, 4, the first 4 sectors of the new volume will be unmapped and you will find sector 0 of the mapped volume at sector 4 in the new volume.

The start sector does the same thing just reversed. It describes at which sector in the mapped volume the new volume should begin.
So if you set that to 8 (and keep the logical start sector at 0), the new volume will begin 8 sectors into the mapped volume.

The dmsetup man page actually explains this, I initially just had some trouble understanding it:
# A table to join two disks together
0 1028160 linear /dev/hda 0
1028160 3903762 linear /dev/hdb 0

Here we simply map two disks from beginning to end into one volume with hda in the beginning and hdb in the end.
Also, as you can see, there's no need to actually use the major and minor device numbers, you can just use the device path.

Kind regards
Anders Ingemann

Reply to: