📄 ntfs.txt
字号:
You will need to create a table of the components of the volume/stripe set andhow they fit together and load this into the kernel using the dmsetup utility(see man 8 dmsetup).Linear volume sets, i.e. linear raid, has been tested and works fine. Eventhough untested, there is no reason why stripe sets, i.e. raid level 0, andmirrors, i.e. raid level 1 should not work, too. Stripes with parity, i.e.raid level 5, unfortunately cannot work yet because the current version of theDevice-Mapper driver does not support raid level 5. You may be able to use theSoftware RAID / MD driver for raid level 5, see the next section for details.To create the table describing your volume you will need to know each of itscomponents and their sizes in sectors, i.e. multiples of 512-byte blocks.For NT4 fault tolerant volumes you can obtain the sizes using fdisk. So forexample if one of your partitions is /dev/hda2 you would do:$ fdisk -ul /dev/hdaDisk /dev/hda: 81.9 GB, 81964302336 bytes255 heads, 63 sectors/track, 9964 cylinders, total 160086528 sectorsUnits = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 63 4209029 2104483+ 83 Linux /dev/hda2 4209030 37768814 16779892+ 86 NTFS /dev/hda3 37768815 46170809 4200997+ 83 LinuxAnd you would know that /dev/hda2 has a size of 37768814 - 4209030 + 1 =33559785 sectors.For Win2k and later dynamic disks, you can for example use the ldminfo utilitywhich is part of the Linux LDM tools (the latest version at the time ofwriting is linux-ldm-0.0.8.tar.bz2). You can download it from: http://linux-ntfs.sourceforge.net/downloads.htmlSimply extract the downloaded archive (tar xvjf linux-ldm-0.0.8.tar.bz2), gointo it (cd linux-ldm-0.0.8) and change to the test directory (cd test). Youwill find the precompiled (i386) ldminfo utility there. NOTE: You will not beable to compile this yourself easily so use the binary version!Then you would use ldminfo in dump mode to obtain the necessary information:$ ./ldminfo --dump /dev/hdaThis would dump the LDM database found on /dev/hda which describes all of yourdynamic disks and all the volumes on them. At the bottom you will see theVOLUME DEFINITIONS section which is all you really need. You may need to lookfurther above to determine which of the disks in the volume definitions iswhich device in Linux. Hint: Run ldminfo on each of your dynamic disks andlook at the Disk Id close to the top of the output for each (the PRIVATE HEADERsection). You can then find these Disk Ids in the VBLK DATABASE section in the<Disk> components where you will get the LDM Name for the disk that is found inthe VOLUME DEFINITIONS section.Note you will also need to enable the LDM driver in the Linux kernel. If yourdistribution did not enable it, you will need to recompile the kernel with itenabled. This will create the LDM partitions on each device at boot time. Youwould then use those devices (for /dev/hda they would be /dev/hda1, 2, 3, etc)in the Device-Mapper table.You can also bypass using the LDM driver by using the main device (e.g./dev/hda) and then using the offsets of the LDM partitions into this device asthe "Start sector of device" when creating the table. Once again ldminfo wouldgive you the correct information to do this.Assuming you know all your devices and their sizes things are easy.For a linear raid the table would look like this (note all values are in512-byte sectors):--- cut here ---# Offset into Size of this Raid type Device Start sector# volume device of device0 1028161 linear /dev/hda1 01028161 3903762 linear /dev/hdb2 04931923 2103211 linear /dev/hdc1 0--- cut here ---For a striped volume, i.e. raid level 0, you will need to know the chunk sizeyou used when creating the volume. Windows uses 64kiB as the default, so itwill probably be this unless you changes the defaults when creating the array.For a raid level 0 the table would look like this (note all values are in512-byte sectors):--- cut here ---# Offset Size Raid Number Chunk 1st Start 2nd Start# into of the type of size Device in Device in# volume volume stripes device device0 2056320 striped 2 128 /dev/hda1 0 /dev/hdb1 0--- cut here ---If there are more than two devices, just add each of them to the end of theline.Finally, for a mirrored volume, i.e. raid level 1, the table would look likethis (note all values are in 512-byte sectors):--- cut here ---# Ofs Size Raid Log Number Region Should Number Source Start Target Start# in of the type type of log size sync? of Device in Device in# vol volume params mirrors Device Device0 2056320 mirror core 2 16 nosync 2 /dev/hda1 0 /dev/hdb1 0--- cut here ---If you are mirroring to multiple devices you can specify further targets at theend of the line.Note the "Should sync?" parameter "nosync" means that the two mirrors arealready in sync which will be the case on a clean shutdown of Windows. If themirrors are not clean, you can specify the "sync" option instead of "nosync"and the Device-Mapper driver will then copy the entirety of the "Source Device"to the "Target Device" or if you specified multipled target devices to all ofthem.Once you have your table, save it in a file somewhere (e.g. /etc/ntfsvolume1),and hand it over to dmsetup to work with, like so:$ dmsetup create myvolume1 /etc/ntfsvolume1You can obviously replace "myvolume1" with whatever name you like.If it all worked, you will now have the device /dev/device-mapper/myvolume1which you can then just use as an argument to the mount command as usual tomount the ntfs volume. For example:$ mount -t ntfs -o ro /dev/device-mapper/myvolume1 /mnt/myvol1(You need to create the directory /mnt/myvol1 first and of course you can useanything you like instead of /mnt/myvol1 as long as it is an existingdirectory.)It is advisable to do the mount read-only to see if the volume has been setupcorrectly to avoid the possibility of causing damage to the data on the ntfsvolume.The Software RAID / MD driver-----------------------------An alternative to using the Device-Mapper driver is to use the kernel'sSoftware RAID / MD driver. For which you need to set up your /etc/raidtabappropriately (see man 5 raidtab).Linear volume sets, i.e. linear raid, as well as stripe sets, i.e. raid level0, have been tested and work fine (though see section "Limitations when usingthe MD driver with NTFS volumes" especially if you want to use linear raid).Even though untested, there is no reason why mirrors, i.e. raid level 1, andstripes with parity, i.e. raid level 5, should not work, too.You have to use the "persistent-superblock 0" option for each raid-disk in theNTFS volume/stripe you are configuring in /etc/raidtab as the persistentsuperblock used by the MD driver would damage the NTFS volume.Windows by default uses a stripe chunk size of 64k, so you probably want the"chunk-size 64k" option for each raid-disk, too.For example, if you have a stripe set consisting of two partitions /dev/hda5and /dev/hdb1 your /etc/raidtab would look like this:raiddev /dev/md0 raid-level 0 nr-raid-disks 2 nr-spare-disks 0 persistent-superblock 0 chunk-size 64k device /dev/hda5 raid-disk 0 device /dev/hdb1 raid-disk 1For linear raid, just change the raid-level above to "raid-level linear", formirrors, change it to "raid-level 1", and for stripe sets with parity, changeit to "raid-level 5".Note for stripe sets with parity you will also need to tell the MD driverwhich parity algorithm to use by specifying the option "parity-algorithmwhich", where you need to replace "which" with the name of the algorithm touse (see man 5 raidtab for available algorithms) and you will have to try thedifferent available algorithms until you find one that works. Make sure youare working read-only when playing with this as you may damage your dataotherwise. If you find which algorithm works please let us know (email thelinux-ntfs developers list linux-ntfs-dev@lists.sourceforge.net or drop in onIRC in channel #ntfs on the irc.freenode.net network) so we can update thisdocumentation.Once the raidtab is setup, run for example raid0run -a to start all devices orraid0run /dev/md0 to start a particular md device, in this case /dev/md0.Then just use the mount command as usual to mount the ntfs volume using forexample: mount -t ntfs -o ro /dev/md0 /mnt/myntfsvolumeIt is advisable to do the mount read-only to see if the md volume has beensetup correctly to avoid the possibility of causing damage to the data on thentfs volume.Limitations when using the Software RAID / MD driver-----------------------------------------------------Using the md driver will not work properly if any of your NTFS partitions havean odd number of sectors. This is especially important for linear raid as alldata after the first partition with an odd number of sectors will be offset byone or more sectors so if you mount such a partition with write support youwill cause massive damage to the data on the volume which will only becomeapparent when you try to use the volume again under Windows.So when using linear raid, make sure that all your partitions have an evennumber of sectors BEFORE attempting to use it. You have been warned!Even better is to simply use the Device-Mapper for linear raid and then you donot have this problem with odd numbers of sectors.ChangeLog=========Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.2.1.29: - Fix a deadlock when mounting read-write.2.1.28: - Fix a deadlock.2.1.27: - Implement page migration support so the kernel can move memory used by NTFS files and directories around for management purposes. - Add support for writing to sparse files created with Windows XP SP2. - Many minor improvements and bug fixes.2.1.26: - Implement support for sector sizes above 512 bytes (up to the maximum supported by NTFS which is 4096 bytes). - Enhance support for NTFS volumes which were supported by Windows but not by Linux due to invalid attribute list attribute flags. - A few minor updates and bug fixes.2.1.25: - Write support is now extended with write(2) being able to both overwrite existing file data and to extend files. Also, if a write to a sparse region occurs, write(2) will fill in the hole. Note,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -