使用 Linux 还原 Windows 跨区磁盘 (LDM)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8427372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows Spanned Disks (LDM) restoration with Linux?
提问by Thomas
Is it possible to read Windows 2008 LDM partitions in Linux?
是否可以在 Linux 中读取 Windows 2008 LDM 分区?
We have five 512GB LUNS exported through ISCSI to a dead Windows 2008 and this box doesn't want them anymore. Windows believes they are now raw devices... So I'd like to read the partitions with Linux. I am using the latest Ubuntu to try to save at least some of the data. The problem is that all documentation I've found so far seems to be obsolete (often talking about w2k or XP Logical Disk Manager (LDM). But I think now it's different with 2008.
我们有五个 512GB LUN 通过 ISCSI 导出到死机的 Windows 2008,这个盒子不再需要它们了。Windows 认为它们现在是原始设备......所以我想用 Linux 读取分区。我正在使用最新的 Ubuntu 来尝试至少保存一些数据。问题是到目前为止我发现的所有文档似乎都过时了(经常谈论 w2k 或 XP 逻辑磁盘管理器(LDM)。但我认为现在它与 2008 不同。
Testdisk [0] gives me the following output
Testdisk [0] 给了我以下输出
testdisk /list LUN01
TestDisk 6.11, Data Recovery Utility, April 2009
Christophe GRENIER <[email protected]>
http://www.cgsecurity.org
Please wait...
Disk LUN01 - 536 GB / 500 GiB - CHS 65271 255 63, sector size=512
Disk LUN01 - 536 GB / 500 GiB - CHS 65271 255 63
Partition Start End Size in sectors
1 P MS LDM MetaData 34 2081 2048 [LDM metadata partition]
No FAT, NTFS, EXT2, JFS, Reiser, cramfs or XFS marker
2 P MS Reserved 2082 262177 260096 [Microsoft reserved partition]
2 P MS Reserved 2082 262177 260096 [Microsoft reserved partition]
3 P MS LDM Data 262178 1048576966 1048314789 [LDM data partition]
Note: Each of the 5 LUN has the same partition table.
注意:5 个 LUN 中的每一个都有相同的分区表。
In many documentations like cgssecurityand kernel.org, they talk about ldminfo which doesn't return any useful information. I suspect that it's now obsolete, just because it was very hard to find :) And because it does not work I guess windows 2008 uses a different format.
在cgssecurity和kernel.org等许多文档中,他们谈到 ldminfo ,它不返回任何有用的信息。我怀疑它现在已经过时了,只是因为它很难找到:) 而且因为它不起作用我猜 Windows 2008 使用了不同的格式。
# ldminfo LUN01
Something went wrong, skipping device 'LUN01'
# losetup /dev/loop1 LUN01
# losetup -a
/dev/loop1: [fd00]:14 (/mnt/LUN01)
# ldminfo /dev/loop1
Something went wrong, skipping device '/dev/loop1'
Then, I tried to concat them with dmsetup but again no luck. That's how I used dmsetup :
然后,我尝试用 dmsetup 连接它们,但还是没有运气。这就是我使用 dmsetup 的方式:
# losetup /dev/loop1 LUN01
# losetup /dev/loop2 LUN02
# losetup /dev/loop3 LUN03
# losetup /dev/loop4 LUN04
# losetup /dev/loop5 LUN05
# blockdev --getsize /dev/loop1
1048577000
# cat > w2008.mapping
# Offset into Size of this Raid type Device Start sector
# volume device of device
0 1048577000 linear /dev/loop1 0
1048577000 1048577000 linear /dev/loop2 0
2097154000 1048577000 linear /dev/loop3 0
3145731000 1048577000 linear /dev/loop4 0
4194308000 1048577000 linear /dev/loop5 0
# dmsetup create myfs w2008.mapping
# mount -t ntfs /dev/mapper/myfs /mnt/final
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
# echo Poo.
So still no NTFS filesystem :)
所以仍然没有 NTFS 文件系统 :)
Does anyone have any ideas about how I can extract the data from there or give me some pointers?
有没有人对我如何从那里提取数据或给我一些指示有任何想法?
采纳答案by Thomas
Allright, I will reply to my own question to avoid the same pain to others.
好吧,我会回答我自己的问题,以免给别人带来同样的痛苦。
0. WARNING
0. 警告
In case you are doing a recovery, ALWAYS COPY YOUR DATA and work on the copy. Do NOT alter the original 'broken' data. That thing said, keep reading.
如果您正在进行恢复,请始终复制您的数据并处理副本。不要更改原始的“损坏”数据。那件事说,继续阅读。
1. Your partition looks like ...
1.你的分区看起来像...
Install sleuth kit and testdisk. Hopefully there will packages for your distro :)
安装侦探套件和测试盘。希望有适合您的发行版的软件包:)
# mmls -t gpt LUN01
GUID Partition Table (EFI)
Offset Sector: 0
Units are in 512-byte sectors
Slot Start End Length Description
00: Meta 0000000000 0000000000 0000000001 Safety Table
01: ----- 0000000000 0000000033 0000000034 Unallocated
02: Meta 0000000001 0000000001 0000000001 GPT Header
03: Meta 0000000002 0000000033 0000000032 Partition Table
04: 00 0000000034 0000002081 0000002048 LDM metadata partition
05: 01 0000002082 0000262177 0000260096 Microsoft reserved partition
06: 02 0000262178 1048576966 1048314789 LDM data partition
07: ----- 1048576967 1048576999 0000000033 Unallocated
Note: testdisk will give you the same info with less details # testdisk /list LUN01
注意:testdisk 将为您提供相同的信息,但细节较少 # testdisk /list LUN01
2. Extract disks metadata
2. 提取磁盘元数据
All information about the disk order, data size and other ciphered attributes about the partition will be found in the LDM metadata partition. W2k8 has not changed so much since this document [2] albeit some sizes are different and some attributes are new (and obviously unknown)...
所有关于磁盘顺序、数据大小和其他加密属性的信息都可以在 LDM 元数据分区中找到。W2k8 自本文档 [2] 以来并没有太大变化,尽管有些大小不同,有些属性是新的(显然是未知的)...
# dd if=LUN01 skip=33 count=2048 |xxd -a > lun01.metadata
# less lun01.metadata
At line 0002410 you should see the name of the server. Reassuring ? But we are after the disks order and disk ID. Scroll down.
在第 0002410 行,您应该会看到服务器的名称。放心吗?但是我们是在磁盘顺序和磁盘 ID 之后。向下滚动。
2.1. Disks Order
2.1. 磁盘顺序
At line 0003210 you should see 'Disk1' followed by a long string.
在第 0003210 行,您应该看到 'Disk1' 后跟一个长字符串。
0003200: 5642 4c4b 0000 001c 0000 0006 0000 0001 VBLK............
0003210: 0000 0034 0000 003a 0102 0544 6973 6b31 ...4...:...Disk1
0003220: 2437 3965 3830 3239 332d 3665 6231 2d31 e80293-6eb1-1
0003230: 3164 662d 3838 6463 2d30 3032 3662 3938 1df-88dc-0026b98
0003240: 3335 6462 3300 0000 0040 0000 0000 0000 35db3....@......
0003250: 0048 0000 0000 0000 0000 0000 0000 0000 .H..............
This means that the first disk of this Volume is identfied by the following Unique ID (UID) : 79e80293-6eb1-11df-88dc-0026b9835db3 But at the moment, we don't know which of the disk has this UID ! So move to the Disk2 entry and take note of its UID and so on for all the disks you had in your volume. Note: Based on my experience only the first 8 characters are changing, the rest stays the same. Indeed, W2k8 seems to increment the ID by 6. $ is a separator.
这意味着此卷的第一个磁盘由以下唯一 ID (UID) 标识: 79e80293-6eb1-11df-88dc-0026b9835db3 但目前,我们不知道哪个磁盘具有此 UID!因此,移至 Disk2 条目并记下它的 UID 等,以了解您卷中的所有磁盘。注意:根据我的经验,只有前 8 个字符发生了变化,其余保持不变。实际上,W2k8 似乎将 ID 增加了 6。$ 是一个分隔符。
Eg. :
例如。:
Windows Disk1 UID : 79e80293-6eb1-11df-88dc-0026b9835db3
Windows Disk2 UID : 79e80299-...
Windows Disk3 UID : 79e8029f-...
2.2. Find Disk UID
2.2. 查找磁盘 UID
Go to line 00e8200 (lun01.metadata). You should find 'PRIVHEAD'.
转到第 00e8200 行(lun01.metadata)。你应该找到'PRIVHEAD'。
00e8200: 5052 4956 4845 4144 0000 2c41 0002 000c PRIVHEAD..,A....
00e8210: 01cc 6d37 2a3f c84e 0000 0000 0000 0007 ..m7*?.N........
00e8220: 0000 0000 0000 07ff 0000 0000 0000 0740 ...............@
00e8230: 3739 6538 3032 3939 2d36 6562 312d 3131 79e80299-6eb1-11
00e8240: 6466 2d38 3864 632d 3030 3236 6239 3833 df-88dc-0026b983
00e8250: 3564 6233 0000 0000 0000 0000 0000 0000 5db3............
00e8260: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00e8270: 3162 3737 6461 3230 2d63 3731 372d 3131 1b77da20-c717-11
00e8280: 6430 2d61 3562 652d 3030 6130 6339 3164 d0-a5be-00a0c91d
00e8290: 6237 3363 0000 0000 0000 0000 0000 0000 b73c............
00e82a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00e82b0: 3839 3164 3065 3866 2d64 3932 392d 3131 891d0e8f-d929-11
00e82c0: 6530 2d61 3861 372d 3030 3236 6239 3833 e0-a8a7-0026b983
00e82d0: 3564 6235 0000 0000 0000 0000 0000 0000 5db5............
00e82e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
What we are after is the disk UID of this particular disk. We see: - Disk Id : 79e80299-6eb1-11df-88dc-0026b9835db3 - Host Id : 1b77da20-c717-11d0-a5be-00a0c91db73c - Disk Group Id : 891d0e8f-d929-11e0-a8a7-0026b9835db5
我们所追求的是这个特定磁盘的磁盘 UID。我们看到: - 磁盘 ID:79e80299-6eb1-11df-88dc-0026b9835db3 - 主机 ID:1b77da20-c717-11d0-a5be-00a0c91db73c - 磁盘组 Id:89161d-db30e-891d-b30e-d
So this disk with the UID 79e80299-... is Windows Disk2 but for us it was Physical Disk 1. Indeed find this UID in the disk order you found above. Note: There is no logical order. I mean Windows decide how to setup the disk order not you. So there is NO human logic and don't expect your first disk to be Disk1.
所以这个 UID 为 79e80299-... 的磁盘是 Windows Disk2,但对我们来说它是物理磁盘 1。确实在上面找到的磁盘顺序中找到这个 UID。注意:没有逻辑顺序。我的意思是 Windows 决定如何设置磁盘顺序而不是你。所以没有人为逻辑,不要指望你的第一个磁盘是 Disk1。
So don't assume that the order above is going to follow any human logic. I recommend you to go through all the LDM data of your disks and extract their UID. (You can use the following command to just extract the PRIVHEAD info: dd if=LUNXX skip=1890 count=1 |xxd -a)
所以不要假设上面的顺序会遵循任何人类逻辑。我建议您检查磁盘的所有 LDM 数据并提取它们的 UID。(您可以使用以下命令来提取 PRIVHEAD 信息:dd if=LUNXX skip=1890 count=1 |xxd -a)
e.g:
例如:
(Windows) Disk1 : 79e80293-... == Physical disk 2
(Windows) Disk2 : 79e80299-... == Physical disk 1
(Windows) Disk3 : 79e8029f-... == Physical disk 3
I am sure that somewhere in the LDM metadata you can find the type of Volume (spanned, RAID0, RAIDX, and the associated stripe sizes) However, I haven't dug it. I used a 'try and retry' method to find my data. So if you know how you setup your configuration before the drama, you will save yourself a lot of time.
我确信在 LDM 元数据的某个地方您可以找到卷的类型(跨区、RAID0、RAIDX 和相关的条带大小)但是,我还没有挖掘它。我使用了“尝试和重试”方法来查找我的数据。因此,如果您知道如何在戏剧之前设置配置,您将节省大量时间。
3. Find the NTFS filesystem and your data
3. 找到 NTFS 文件系统和您的数据
Now we are interested in the big chunk of data we want to restore. In my case it's ~512GB of data so we won't convert the whole in ASCII. I haven't really search how Windows find the beginning of its NTFS partition. But what I found is that it logically starts with the following keyword : R.NTFS. Let's find this and find the offset we will have to apply later to see our NTFS FS.
现在我们对要恢复的大块数据感兴趣。就我而言,它是 ~512GB 的数据,因此我们不会将整个数据转换为 ASCII。我还没有真正搜索 Windows 如何找到其 NTFS 分区的开头。但我发现它在逻辑上以以下关键字开头:R.NTFS。让我们找到它并找到稍后我们必须应用的偏移量才能看到我们的 NTFS FS。
06: 02 0000262178 1048576966 1048314789 LDM data partition
In this example, the data starts at 262178 and is 1048314789 sectors long
在本例中,数据从 262178 开始,长度为 1048314789 个扇区
We found above that Disk1 (of the volume group) is actually the 2nd physical disk. We will extract some of its information to find where the NTFS partition start.
我们在上面发现 Disk1(卷组的)实际上是第二个物理磁盘。我们将提取它的一些信息来找到 NTFS 分区的开始位置。
# dd if=LUN02 skip=262178 count=4096 |xxd -a > lun02.DATASTART-4k
# less lun02.DATASTART-4k
0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
00fbc00: eb52 904e 5446 5320 2020 2000 0208 0000 .R.NTFS .....
00fbc10: 0000 0000 00f8 0000 3f00 ff00 0008 0400 ........?.......
00fbc20: 0000 0000 8000 8000 ffaf d770 0200 0000 ...........p....
Here we can see that NTFS starts at 00fbc00. So knowing that we can start to extract our data from sector 262178 + 00fbc00 bytes. Let's do a bit of hexadecimal to decimal conversion with bytes to sector conversion as well.
在这里我们可以看到 NTFS 从 00fbc00 开始。所以知道我们可以开始从扇区 262178 + 00fbc00 字节中提取我们的数据。让我们做一些十六进制到十进制的转换以及字节到扇区的转换。
0xfbc00 bytes = 1031168 bytes = 1031168/512 sectors = 2014 sectors
0xfbc00 字节 = 1031168 字节 = 1031168/512 个扇区 = 2014 个扇区
So our NTFS partition starts at 262178 + 2014 = 264192 sectors. This value is going to be an offset we will use later on all disks. Let's called it the NTFS offset. Obviously the total size is shrinked by the offset. So the new size is: 1048314789 - 2014 = 1048312775 sectors
所以我们的 NTFS 分区从 262178 + 2014 = 264192 个扇区开始。该值将是我们稍后将在所有磁盘上使用的偏移量。我们称之为 NTFS 偏移量。显然,总大小被偏移量缩小了。所以新的大小是:1048314789 - 2014 = 1048312775 个扇区
4. Try to mount/see the data
4.尝试挂载/查看数据
From now on, either it will work out of the box because your NTFS partition is healthy or it won't because you're doing this to recover some data. The following process is the same whatever is your status. All the following is based on [1] (see Links at the bottom)
从现在开始,它要么开箱即用,因为您的 NTFS 分区是健康的,要么因为您这样做是为了恢复一些数据而无法使用。无论您处于何种状态,以下过程都是相同的。以下所有内容均基于 [1](请参阅底部的链接)
A spanned volume, will fill a volume after another. Where as a striped (RAID0) will copy chunk of data over many disks (a.k.a a file is spread across many disks). In my case, I didn't know if it was a spanned or striped volume. The easiest way to know, if your volume is not full is to check if you have a lot of zeroes at then end of all your volumes. If that's the case then it's striped. Because if it's spanned, if will fill the first disk, then the second. I am not 100% sure of that but that's what I observed. So dd a bunch of sectors from the end of the LDM data partition.
一个跨越的卷,将一个接一个地填满。条带化 (RAID0) 将在许多磁盘上复制数据块(即文件分布在许多磁盘上)。就我而言,我不知道它是跨区卷还是条带卷。知道如果您的卷未满的最简单方法是检查所有卷的末尾是否有很多零。如果是这样,那么它是条纹的。因为如果它被跨越,如果会填满第一个磁盘,那么第二个。我不是 100% 肯定,但这就是我观察到的。所以从LDM数据分区的末尾添加一堆扇区。
4.0 Preparations to access your data
4.0 准备访问您的数据
First mount your dd file or your device through a loopback device with the NTFS offset and the size we calculated above. However the offset and size must be in bytes not in sectors to be used with losetup. offset = 264192*512 = 135266304 size = 1048312775*512 = 536736140800
首先通过具有 NTFS 偏移量和我们上面计算的大小的环回设备挂载您的 dd 文件或您的设备。但是,偏移量和大小必须以字节为单位,而不是在要与 Lostup 一起使用的扇区中。偏移量 = 264192*512 = 135266304 大小 = 1048312775*512 = 536736140800
# losetup /dev/loop2 DDFILE_OR_DEVICE -o 135266304 --size 536736140800
# blockdev --getsize /dev/loop2
1048312775 <---- total size in sectors, same number than before
Note: you can add '-r' to mount in Read-Only mode.
注意:您可以添加“-r”以只读模式挂载。
Do the above for all the physical disks part of your volume. Display the result with: losetup -a Note: If you don't have enough loop devices you can easily create more with : # mknod -m0660 /dev/loopNUMBER b 7 NUMBER && chown root.disk /dev/loopNUMBER
对卷的所有物理磁盘部分执行上述操作。使用以下命令显示结果:losetup -a 注意:如果您没有足够的循环设备,您可以使用以下命令轻松创建更多设备:# mknod -m0660 /dev/loopNUMBER b 7 NUMBER && chown root.disk /dev/loopNUMBER
Check your alignment by opening the first Disk of the group (eg: Disk2) to see if the first line is R.NTFS. If not then your alignment is wrong. Verify your calculations above and try again. Or you are not looking at the 1st Windows Disk
通过打开组的第一个磁盘(例如:Disk2)来检查您的对齐方式,看看第一行是否是 R.NTFS。如果不是,那么您的对齐方式是错误的。验证上面的计算并重试。或者你不是在看第一个 Windows 磁盘
e.g:
例如:
First disk of the volume has been mounted on /dev/loop2
# xxd /dev/loop2 |head
0000000: eb52 904e 5446 5320 2020 2000 0208 0000 .R.NTFS .....
0000010: 0000 0000 00f8 0000 3f00 ff00 0008 0400 ........?.......
All good. Let's move to the annoying part :)
都好。让我们转到烦人的部分:)
4.1 Spanned
4.1 跨越
Spanned disks are actually a chain of disks. You fill the first then you use the second one and so and so forth. Create a file which look like this, eg :
跨区磁盘实际上是一个磁盘链。您填写第一个,然后使用第二个,依此类推。创建一个看起来像这样的文件,例如:
# Offset into Size of this Raid type Device Start sector
# volume device of device
0 1048312775 linear /dev/loop2 0
1048312775 1048312775 linear /dev/loop1 0
2096625550 1048312775 linear /dev/loop3 0
Notes: - Remember to use the good disk order (you found before). eg: Physical Disk2 followed by Physical Disk1 and Physical Disk3 - 2096625550 = 2*1048312775 and obviously if you have a fourth disk it's gonna be 3 times the size for the offset for the 4th disk.
注意: - 请记住使用良好的磁盘顺序(您之前已找到)。例如:Physical Disk2 后跟 Physical Disk1 和 Physical Disk3 - 2096625550 = 2*1048312775 显然,如果您有第四个磁盘,它的大小将是第四个磁盘的偏移量的 3 倍。
4.2 Striped
4.2 条纹
The problem with striped mode (aka RAID0) is you must know what is your stripe size. Apparently by default it is 64k (in my case it was 128k but I dunno if it was tuned by the Windows sysadmin:). Anyway if you don't know it, you just have to try all the possible standard values and see which one gives you a possible viable NTFS filesystem.
条带模式(又名 RAID0)的问题是您必须知道您的条带大小是多少。显然默认情况下它是 64k(在我的情况下是 128k,但我不知道它是否由 Windows 系统管理员调整:)。无论如何,如果您不知道,您只需要尝试所有可能的标准值,然后看看哪一个为您提供了可行的 NTFS 文件系统。
Create a file like the following for 3 disks with a 128k chunk size
为 128k 块大小的 3 个磁盘创建如下文件
.---+--> 3 chunks of 128k
0 3144938240 striped 3 128 /dev/loop2 0 /dev/loop3 0 /dev/loop1 0
`---> total size of the volume `----------+-----------+---> disk order
/!\ : Size of the volume is not exactly the size we calculated before. dmsetup needs a volume size divisible by the chunk size (aka stripe size) AND by the number of disks in the volume. So in our case. We have 3 disks of 1048312775 sectors So the 'normal' size is 1048312775*3=3144938325 sectors but due to the above contraint we will recalculate the size and round it # echo "3144938325/128*128" | bc 3144938240 sectors
/!\ :卷的大小与我们之前计算的大小不完全相同。dmsetup 需要一个可被块大小(又名条带大小)和卷中的磁盘数整除的卷大小。所以在我们的情况下。我们有 3 个 1048312775 个扇区的磁盘所以“正常”大小是 1048312775*3=3144938325 个扇区,但由于上述限制,我们将重新计算大小并将其舍入 # echo "3144938325/128*128" | bc 3144938240 扇区
So 3144938240 is the size of your volume in a striped scenario with 3 disk and
128 chunks (aka stripes)
4.3 Mount it.
4.3 安装。
Now lets aggregate everything together with dmsetup :
现在让我们使用 dmsetup 将所有内容聚合在一起:
# dmsetup create myldm /path/myconfigfile
# dmsetup ls
myldm (253, 1)
# mount -t ntfs -o ro /dev/mapper/myldm /mnt
If it does not mount. Then you can use testdisk :
如果没有挂载。然后你可以使用 testdisk :
# testdisk /dev/mapper/myldm
--> Analyse
----> Quick search
------> You should see the volume name (if any). If not it seems compromised :)
--------> Press 'P' to see files and copy with 'c'
5. Conclusion
5. 结论
The above worked for me. Your mileage may vary. And there is maybe a better and easier way to do it. If so, share it so nobody else will have to go through this hassle :) Also, it may look hard but it is not. As long as you copy your data somewhere, just try and retry until you can see something. It took me 3 days to understand how to put all the bits together. Hopefully the above will help you to not waste 3 days.
以上对我有用。你的旅费可能会改变。也许有更好、更简单的方法来做到这一点。如果是这样,请分享它,这样其他人就不必经历这个麻烦:) 此外,它可能看起来很难,但事实并非如此。只要您将数据复制到某处,只需尝试重试,直到看到某些内容。我花了 3 天的时间才明白如何将所有的部分放在一起。希望以上内容可以帮助您不要浪费 3 天。
Note: All examples above have been made up. There is maybe some inconsistencies between the examples despite my thoroughness ;)
注:以上所有例子都是编造出来的。尽管我很周到,但示例之间可能存在一些不一致之处;)
Good luck.
祝你好运。
6. Links
6. 链接
回答by BadBiki
Windows Dynamic Volume 5x disk, spanned, 8TB total.
Windows 动态卷 5x 磁盘,跨区,共 8TB。
This is what i've gathered from the answer above, and by referencing [1] and [2].
这是我从上面的答案中收集到的,并参考了 [1] 和 [2]。
What I discovered is that there is more than just the, disk order GUID, infomation in the metadata partition. There is a clear structure that contains size, offset and offset within spanned volumne.
我发现元数据分区中不仅仅是磁盘顺序 GUID 信息。有一个清晰的结构,包含跨越卷内的大小、偏移量和偏移量。
Use the answer above section {2.1} and {2.2} to determine the order of drives.
使用上面{2.1} 和{2.2} 部分的答案来确定驱动器的顺序。
My 4x disks are exported as 4x 2tb chunks and 1x smaller chunk from a single RAID5 array from a 3ware 9650se controller. Each disk is in the format of;
我的 4x 磁盘从 3ware 9650se 控制器的单个 RAID5 阵列导出为 4x 2tb 块和 1x 较小块。每个磁盘的格式为;
/dev/sdX1 = LDM metadata partition (~1mb)
/dev/sdX2 = Reserved msoft partition (~100mb)
/dev/sdX1 = LDM data partition (~1.99TB/20GB)
from a 'xxd -a -l 65535 /dev/sdd1 | more' I get
来自 'xxd -a -l 65535 /dev/sdd1 | 更多'我得到
0002800: 5642 4c4b 0000 000c 0000 000e 0000 0001 VBLK............
0002810: 0000 4033 0000 0031 0109 0844 6973 6b31 [email protected]
0002820: 2d30 3100 0000 0000 0000 0000 0000 0b00 -01.............
0002830: 0000 0000 0007 de00 0000 0000 0000 0004 ................
^---^ Note 07 de (offset)
0002840: fffb f000 0108 0102 0000 0000 0000 0000 ................
^-------^ Note fffb f000 (size)
0002850: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
0002880: 5642 4c4b 0000 000d 0000 000f 0000 0001 VBLK............
0002890: 0000 4033 0000 0031 010a 0844 6973 6b32 [email protected]
00028a0: 2d30 3100 0000 0000 0000 0000 0000 0b00 -01.............
00028b0: 0000 0000 0007 de00 0000 00ff fbf0 0004 ................
^---^ Offset ^--------^ Now see spanned offset
00028c0: fffb f000 0108 0103 0000 0000 0000 0000 ................
^-------^ note size again!
00028d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
0002900: 5642 4c4b 0000 000e 0000 0010 0000 0001 VBLK............
0002910: 0000 4033 0000 0031 010b 0844 6973 6b33 [email protected]
0002920: 2d30 3100 0000 0000 0000 0000 0000 0b00 -01.............
0002930: 0000 0000 0007 de00 0000 01ff f7e0 0004 ................
^---^ Offset ^--------^ Now see spanned offset
0002940: fffb f000 0108 0104 0000 0000 0000 0000 ................
^-------^ note size again!
0002950: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
0002980: 5642 4c4b 0000 000f 0000 0011 0000 0001 VBLK............
0002990: 0000 4033 0000 0031 010c 0844 6973 6b34 [email protected]
00029a0: 2d30 3100 0000 0000 0000 0000 0000 0b00 -01.............
00029b0: 0000 0000 0007 de00 0000 02ff f3d0 0004 ................
^---^ Offset ^--------^ Now see spanned offset
00029c0: fffb f000 0108 0105 0000 0000 0000 0000 ................
^-------^ note size again!
00029d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
0002a00: 5642 4c4b 0000 0010 0000 0012 0000 0001 VBLK............
0002a10: 0000 4033 0000 0031 010d 0844 6973 6b35 [email protected]
0002a20: 2d30 3100 0000 0000 0000 0000 0000 0b00 -01.............
0002a30: 0000 0000 0007 de00 0000 03ff efc0 0004 ................
^---^ Offset ^--------^ Now see spanned offset
0002a40: 17b7 d000 0108 0106 0000 0000 0000 0000 ................
^-------^ And my final drive is the smallest
0002a50: 0000 0000 0000 0000 0000 0000 0000 0000 ................
So, from above you can clearly see the size of the data section, offset within partition and the offset within the spanned volume. So lets do the maths;
因此,从上面可以清楚地看到数据段的大小、分区内的偏移量和跨区中的偏移量。所以让我们做数学;
Disk1:
Size of block = fffb f000 = 4294701056
Start offset = 07 de = 2014
Partition offset = 00 0000 00 = 0
Disk2:
Size of block = fffb f000 = 4294701056
Start offset = 07 de = 2014
Partition offset = 00ff fbf0 00 = 4294701056
Disk3:
Size of block = fffb f000 = 4294701056
Start offset = 07 de = 2014
Partition offset = 01ff fbf0 00 = 8589402112
Disk4:
Size of block = fffb f000 = 4294701056
Start offset = 07 de = 2014
Partition offset = 02ff fbf0 00 = 12884103168
Disk5:
Size of block = 17b7 d000 = 397922304
Start offset = 07 de = 2014
Partition offset = 03ff fbf0 00 = 17178804224
*Note: Use Excel, hex2dec() function*
This translated with dmraid to:
这与 dmraid 转换为:
# File /etc/ntfsvolume
#offset into Size of this Raid Device Start sector
# volume type in volume
0 4294701056 linear /dev/sdd3 2014
4294701056 4294701056 linear /dev/sdc3 2014
8589402112 4294701056 linear /dev/sdf3 2014
12884103168 4294701056 linear /dev/sde3 2014
17178804224 397922304 linear /dev/sdg3 2014
which can then be directly mounted via:
然后可以通过以下方式直接安装:
$ dmsetup create myvolume /etc/ntfsvolume
$ sudo mkdir /media/volume/
$ mount -t ntfs-3g /dev/mapper/myvolume /media/volume
$ sudo mount -t ntfs-3g -o ro /dev/mapper/myvolume /media/volume (mount read-only)
which requires modules:
这需要模块:
dmraid
ntfs-3g
WARNING!
警告!
Be absolutely sure that you have all offsets, size on disk and spann offsets correct before mounting read-write. ntfs-3g will mount if the offsets are wrong, and your file contents will not be correct.
在安装读写之前,请绝对确保所有偏移量、磁盘大小和跨度偏移量都正确。如果偏移量错误,ntfs-3g 将挂载,并且您的文件内容将不正确。
A good double check is to use windows check disk and loop at the extra information at the end. Note the total number of allocated units, multiple that by the block size (mine was 4096) then divide that by 512 (normal sector size). this should match to the windows reported size.
一个好的双重检查是使用 windows 检查磁盘并在最后的额外信息处循环。请注意分配单元的总数,乘以块大小(我的是 4096)然后除以 512(正常扇区大小)。这应该与报告的窗口大小相匹配。
My partition size reports wrong by 4096 bytes smaller than the size indicated by the above metadata tables. I'm assuming that the partition size rounds to an even number. I calculate 2197090816, windows says 2197090815, 4096 byte blocks..
我的分区大小报告错误,比上述元数据表指示的大小小 4096 字节。我假设分区大小四舍五入为偶数。我计算了 2197090816,windows 说 2197090815,4096 字节块..
References
参考
- List item [1] : http://people.freebsd.org/~ae/LDM/g_part_ldm.c
- List item [2] : http://bigli.ch/howto-access-windows-spanned-dynamic-disks-with-ubuntu/
回答by Christian Hudon
Here's the (much easier) answer, now that ldmtool
exists.
这是(更简单的)答案,现在已经ldmtool
存在。
ldmtool
reads LDM (aka Windows Dynamic Disks) metadata, and (among other things) creates device-mapper entries for the corresponding drives, partitions, and RAID arrays, allowing you afterwards to access and mount them just like other block devices in Linux.
ldmtool
读取 LDM(又名 Windows 动态磁盘)元数据,并(除其他外)为相应的驱动器、分区和 RAID 阵列创建设备映射条目,允许您之后像 Linux 中的其他块设备一样访问和安装它们。
The program does have a few limitations, mostly borne from the fact that it does not modify LDM metadata at all. So you cannot create LDM disks in Linux (use Windows for that), and you should not mount in read-write mode RAID volumes that have disks missing. (ldmtool
won't modify the metadata to reflect that this happened, and the next time Windows assembles the RAID array, problems will ensue, as not all the drives will be in sync.)
该程序确实有一些限制,主要是因为它根本不修改 LDM 元数据。因此,您无法在 Linux 中创建 LDM 磁盘(为此使用 Windows),并且您不应以读写模式挂载缺少磁盘的 RAID 卷。(ldmtool
不会修改元数据以反映发生了这种情况,下次 Windows 组装 RAID 阵列时,会出现问题,因为并非所有驱动器都将同步。)
Here are the steps to follow:
以下是要遵循的步骤:
- To install
ldmtool
on Debian and Ubuntu systems, typeapt-get install ldmtool
. It should be similarly easy on most other recent Linux distributions. - Run
ldmtool create all
. - You should now have a bunch of new entries in /dev/mapper. Locate the right one (in my case, a RAID1 array, so
/dev/mapper/ldm_vol_VOLNAMEHERE-Dg0_Volume2
), and just mount it with something likemount -t ntfs /dev/mapper/ldm_vol_VOLNAMEHERE-Dg0_Volume2
.
- 要
ldmtool
在 Debian 和 Ubuntu 系统上安装,请键入apt-get install ldmtool
. 在大多数其他最近的 Linux 发行版上应该同样容易。 - 运行
ldmtool create all
。 - 您现在应该在 /dev/mapper 中有一堆新条目。找到正确的(在我的例子中是 RAID1 阵列,所以
/dev/mapper/ldm_vol_VOLNAMEHERE-Dg0_Volume2
),然后用类似mount -t ntfs /dev/mapper/ldm_vol_VOLNAMEHERE-Dg0_Volume2
.
To have this done automatically at boot time, you will likely need to insert a call to ldm create all
at the right point in the boot sequence, before the contents of /etc/fstab
is mounted. A good way of doing the call would be:
要在启动时自动完成此操作,您可能需要ldm create all
在/etc/fstab
安装的内容之前在启动序列中的正确位置插入调用。打电话的一个好方法是:
[ -x /usr/bin/ldmtool ] && ldmtool create all >/dev/null || true
But how to get this snippet to run at the right time during boot will vary a lot depending on the distribution you are using. For Ubuntu 13.10, I inserted said line in /etc/init/mountall.conf
, right before the exec mountall ...
call at the end of the script section. And I can now mount my Windows LDM RAID1 partition in /etc/fstab
. Enjoy!
但是如何让这个片段在引导期间在正确的时间运行会因您使用的发行版而有很大差异。对于 Ubuntu 13.10,我在脚本部分末尾/etc/init/mountall.conf
的exec mountall ...
调用之前插入了该行。我现在可以将我的 Windows LDM RAID1 分区挂载到/etc/fstab
. 享受!