mdbooth / libldm

GNU General Public License v3.0
28 stars 15 forks source link

Windows span volume will not always have partition information in order #9

Closed diwu1989 closed 4 years ago

diwu1989 commented 6 years ago

Windows span volume will not always have the partitions in the correct order There's a bug around https://github.com/mdbooth/libldm/blob/master/src/ldm.c#L2790 where it expects the partitions from vol->parts to be in sequential order

The partitions should be sorted by their part->vol_offset first before constructing the dm targets.

Unmoon commented 5 years ago

Hi @diwu1989, in case you are still having this issue, I believe I fixed this over on my fork (https://github.com/Unmoon/libldm/commit/ce3ff319f83e1ae5e49c7dd373c85de37ba7315c). I couldn't confirm if the issue is fixed, as my problem was just an user error.

guysmoilov commented 4 years ago

Had the same problem, @Unmoon will try your solution and update

guysmoilov commented 4 years ago

Just to explain the problem:

root@guy-Z87M-D3H:/media/guy# ldmtool create all
Unable to create volume Volume2 in disk group f5224a77-1e90-11ea-a70e-94de806bfce3: Partition 
volume offset does not match sizes of preceding partitions
root@guy-Z87M-D3H:/media/guy# ldmtool show volume f5224a77-1e90-11ea-a70e-94de806bfce3 Volume2
{
  "name" : "Volume2",
  "type" : "spanned",
  "size" : 976762880,
  "chunk-size" : 0,
  "hint" : "H:",
  "partitions" : [
    "Disk1-01",
    "Disk1-02",
    "Disk1-03"
  ]
}
root@guy-Z87M-D3H:/media/guy# ldmtool show partition f5224a77-1e90-11ea-a70e-94de806bfce3 Disk1-01
{
  "name" : "Disk1-01",
  "start" : 1985,
  "size" : 1021952,
  "disk" : "Disk1"
}
root@guy-Z87M-D3H:/media/guy# ldmtool show partition f5224a77-1e90-11ea-a70e-94de806bfce3 Disk1-02
{
  "name" : "Disk1-02",
  "start" : 322977729,
  "size" : 653791232,
  "disk" : "Disk1"
}
root@guy-Z87M-D3H:/media/guy# ldmtool show partition f5224a77-1e90-11ea-a70e-94de806bfce3 Disk1-03
{
  "name" : "Disk1-03",
  "start" : 1025985,
  "size" : 321949696,
  "disk" : "Disk1"
}

Note how the correct order according to the offsets is Disk1-01 -> Disk1-03 -> Disk1-02

guysmoilov commented 4 years ago

I can confirm that this worked for me, created a PR: #15

glaslos commented 4 years ago

Hey, I'm currently experiencing the same issue with libldm on Ubuntu (version 0.2.4-3). Pulled the source and did ./autogen.sh && ./configure && make && make install but then get the error : ldmtool: symbol lookup error: ldmtool: undefined symbol: ldm_volume_dm_get_device. I'm not too familiar but I assume I missed a step somewhere?

rwmjones commented 4 years ago

You can't really just do make install as it will put the libraries in /usr/local but the existing tool is looking at the Ubuntu-installed libraries in /usr/lib (this is a general point, nothing specific to do with ldm). You could adjust LD_LIBRARY_PATH, but really the best way is not to have run make install in the first place ...

glaslos commented 4 years ago

Ah, thanks, that was easy :) I used the new binary directly and managed to mount the volume 👍