162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci================================ 462306a36Sopenharmony_ciThe Linux NTFS filesystem driver 562306a36Sopenharmony_ci================================ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci.. Table of contents 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci - Overview 1162306a36Sopenharmony_ci - Web site 1262306a36Sopenharmony_ci - Features 1362306a36Sopenharmony_ci - Supported mount options 1462306a36Sopenharmony_ci - Known bugs and (mis-)features 1562306a36Sopenharmony_ci - Using NTFS volume and stripe sets 1662306a36Sopenharmony_ci - The Device-Mapper driver 1762306a36Sopenharmony_ci - The Software RAID / MD driver 1862306a36Sopenharmony_ci - Limitations when using the MD driver 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciOverview 2262306a36Sopenharmony_ci======== 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciLinux-NTFS comes with a number of user-space programs known as ntfsprogs. 2562306a36Sopenharmony_ciThese include mkntfs, a full-featured ntfs filesystem format utility, 2662306a36Sopenharmony_cintfsundelete used for recovering files that were unintentionally deleted 2762306a36Sopenharmony_cifrom an NTFS volume and ntfsresize which is used to resize an NTFS partition. 2862306a36Sopenharmony_ciSee the web site for more information. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ciTo mount an NTFS 1.2/3.x (Windows NT4/2000/XP/2003) volume, use the file 3162306a36Sopenharmony_cisystem type 'ntfs'. The driver currently supports read-only mode (with no 3262306a36Sopenharmony_cifault-tolerance, encryption or journalling) and very limited, but safe, write 3362306a36Sopenharmony_cisupport. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciFor fault tolerance and raid support (i.e. volume and stripe sets), you can 3662306a36Sopenharmony_ciuse the kernel's Software RAID / MD driver. See section "Using Software RAID 3762306a36Sopenharmony_ciwith NTFS" for details. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciWeb site 4162306a36Sopenharmony_ci======== 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ciThere is plenty of additional information on the linux-ntfs web site 4462306a36Sopenharmony_ciat http://www.linux-ntfs.org/ 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ciThe web site has a lot of additional information, such as a comprehensive 4762306a36Sopenharmony_ciFAQ, documentation on the NTFS on-disk format, information on the Linux-NTFS 4862306a36Sopenharmony_ciuserspace utilities, etc. 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciFeatures 5262306a36Sopenharmony_ci======== 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci- This is a complete rewrite of the NTFS driver that used to be in the 2.4 and 5562306a36Sopenharmony_ci earlier kernels. This new driver implements NTFS read support and is 5662306a36Sopenharmony_ci functionally equivalent to the old ntfs driver and it also implements limited 5762306a36Sopenharmony_ci write support. The biggest limitation at present is that files/directories 5862306a36Sopenharmony_ci cannot be created or deleted. See below for the list of write features that 5962306a36Sopenharmony_ci are so far supported. Another limitation is that writing to compressed files 6062306a36Sopenharmony_ci is not implemented at all. Also, neither read nor write access to encrypted 6162306a36Sopenharmony_ci files is so far implemented. 6262306a36Sopenharmony_ci- The new driver has full support for sparse files on NTFS 3.x volumes which 6362306a36Sopenharmony_ci the old driver isn't happy with. 6462306a36Sopenharmony_ci- The new driver supports execution of binaries due to mmap() now being 6562306a36Sopenharmony_ci supported. 6662306a36Sopenharmony_ci- The new driver supports loopback mounting of files on NTFS which is used by 6762306a36Sopenharmony_ci some Linux distributions to enable the user to run Linux from an NTFS 6862306a36Sopenharmony_ci partition by creating a large file while in Windows and then loopback 6962306a36Sopenharmony_ci mounting the file while in Linux and creating a Linux filesystem on it that 7062306a36Sopenharmony_ci is used to install Linux on it. 7162306a36Sopenharmony_ci- A comparison of the two drivers using:: 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci time find . -type f -exec md5sum "{}" \; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci run three times in sequence with each driver (after a reboot) on a 1.4GiB 7662306a36Sopenharmony_ci NTFS partition, showed the new driver to be 20% faster in total time elapsed 7762306a36Sopenharmony_ci (from 9:43 minutes on average down to 7:53). The time spent in user space 7862306a36Sopenharmony_ci was unchanged but the time spent in the kernel was decreased by a factor of 7962306a36Sopenharmony_ci 2.5 (from 85 CPU seconds down to 33). 8062306a36Sopenharmony_ci- The driver does not support short file names in general. For backwards 8162306a36Sopenharmony_ci compatibility, we implement access to files using their short file names if 8262306a36Sopenharmony_ci they exist. The driver will not create short file names however, and a 8362306a36Sopenharmony_ci rename will discard any existing short file name. 8462306a36Sopenharmony_ci- The new driver supports exporting of mounted NTFS volumes via NFS. 8562306a36Sopenharmony_ci- The new driver supports async io (aio). 8662306a36Sopenharmony_ci- The new driver supports fsync(2), fdatasync(2), and msync(2). 8762306a36Sopenharmony_ci- The new driver supports readv(2) and writev(2). 8862306a36Sopenharmony_ci- The new driver supports access time updates (including mtime and ctime). 8962306a36Sopenharmony_ci- The new driver supports truncate(2) and open(2) with O_TRUNC. But at present 9062306a36Sopenharmony_ci only very limited support for highly fragmented files, i.e. ones which have 9162306a36Sopenharmony_ci their data attribute split across multiple extents, is included. Another 9262306a36Sopenharmony_ci limitation is that at present truncate(2) will never create sparse files, 9362306a36Sopenharmony_ci since to mark a file sparse we need to modify the directory entry for the 9462306a36Sopenharmony_ci file and we do not implement directory modifications yet. 9562306a36Sopenharmony_ci- The new driver supports write(2) which can both overwrite existing data and 9662306a36Sopenharmony_ci extend the file size so that you can write beyond the existing data. Also, 9762306a36Sopenharmony_ci writing into sparse regions is supported and the holes are filled in with 9862306a36Sopenharmony_ci clusters. But at present only limited support for highly fragmented files, 9962306a36Sopenharmony_ci i.e. ones which have their data attribute split across multiple extents, is 10062306a36Sopenharmony_ci included. Another limitation is that write(2) will never create sparse 10162306a36Sopenharmony_ci files, since to mark a file sparse we need to modify the directory entry for 10262306a36Sopenharmony_ci the file and we do not implement directory modifications yet. 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ciSupported mount options 10562306a36Sopenharmony_ci======================= 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ciIn addition to the generic mount options described by the manual page for the 10862306a36Sopenharmony_cimount command (man 8 mount, also see man 5 fstab), the NTFS driver supports the 10962306a36Sopenharmony_cifollowing mount options: 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci======================= ======================================================= 11262306a36Sopenharmony_ciiocharset=name Deprecated option. Still supported but please use 11362306a36Sopenharmony_ci nls=name in the future. See description for nls=name. 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_cinls=name Character set to use when returning file names. 11662306a36Sopenharmony_ci Unlike VFAT, NTFS suppresses names that contain 11762306a36Sopenharmony_ci unconvertible characters. Note that most character 11862306a36Sopenharmony_ci sets contain insufficient characters to represent all 11962306a36Sopenharmony_ci possible Unicode characters that can exist on NTFS. 12062306a36Sopenharmony_ci To be sure you are not missing any files, you are 12162306a36Sopenharmony_ci advised to use nls=utf8 which is capable of 12262306a36Sopenharmony_ci representing all Unicode characters. 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ciutf8=<bool> Option no longer supported. Currently mapped to 12562306a36Sopenharmony_ci nls=utf8 but please use nls=utf8 in the future and 12662306a36Sopenharmony_ci make sure utf8 is compiled either as module or into 12762306a36Sopenharmony_ci the kernel. See description for nls=name. 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ciuid= 13062306a36Sopenharmony_cigid= 13162306a36Sopenharmony_ciumask= Provide default owner, group, and access mode mask. 13262306a36Sopenharmony_ci These options work as documented in mount(8). By 13362306a36Sopenharmony_ci default, the files/directories are owned by root and 13462306a36Sopenharmony_ci he/she has read and write permissions, as well as 13562306a36Sopenharmony_ci browse permission for directories. No one else has any 13662306a36Sopenharmony_ci access permissions. I.e. the mode on all files is by 13762306a36Sopenharmony_ci default rw------- and for directories rwx------, a 13862306a36Sopenharmony_ci consequence of the default fmask=0177 and dmask=0077. 13962306a36Sopenharmony_ci Using a umask of zero will grant all permissions to 14062306a36Sopenharmony_ci everyone, i.e. all files and directories will have mode 14162306a36Sopenharmony_ci rwxrwxrwx. 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_cifmask= 14462306a36Sopenharmony_cidmask= Instead of specifying umask which applies both to 14562306a36Sopenharmony_ci files and directories, fmask applies only to files and 14662306a36Sopenharmony_ci dmask only to directories. 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_cisloppy=<BOOL> If sloppy is specified, ignore unknown mount options. 14962306a36Sopenharmony_ci Otherwise the default behaviour is to abort mount if 15062306a36Sopenharmony_ci any unknown options are found. 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_cishow_sys_files=<BOOL> If show_sys_files is specified, show the system files 15362306a36Sopenharmony_ci in directory listings. Otherwise the default behaviour 15462306a36Sopenharmony_ci is to hide the system files. 15562306a36Sopenharmony_ci Note that even when show_sys_files is specified, "$MFT" 15662306a36Sopenharmony_ci will not be visible due to bugs/mis-features in glibc. 15762306a36Sopenharmony_ci Further, note that irrespective of show_sys_files, all 15862306a36Sopenharmony_ci files are accessible by name, i.e. you can always do 15962306a36Sopenharmony_ci "ls -l \$UpCase" for example to specifically show the 16062306a36Sopenharmony_ci system file containing the Unicode upcase table. 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_cicase_sensitive=<BOOL> If case_sensitive is specified, treat all file names as 16362306a36Sopenharmony_ci case sensitive and create file names in the POSIX 16462306a36Sopenharmony_ci namespace. Otherwise the default behaviour is to treat 16562306a36Sopenharmony_ci file names as case insensitive and to create file names 16662306a36Sopenharmony_ci in the WIN32/LONG name space. Note, the Linux NTFS 16762306a36Sopenharmony_ci driver will never create short file names and will 16862306a36Sopenharmony_ci remove them on rename/delete of the corresponding long 16962306a36Sopenharmony_ci file name. 17062306a36Sopenharmony_ci Note that files remain accessible via their short file 17162306a36Sopenharmony_ci name, if it exists. If case_sensitive, you will need 17262306a36Sopenharmony_ci to provide the correct case of the short file name. 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_cidisable_sparse=<BOOL> If disable_sparse is specified, creation of sparse 17562306a36Sopenharmony_ci regions, i.e. holes, inside files is disabled for the 17662306a36Sopenharmony_ci volume (for the duration of this mount only). By 17762306a36Sopenharmony_ci default, creation of sparse regions is enabled, which 17862306a36Sopenharmony_ci is consistent with the behaviour of traditional Unix 17962306a36Sopenharmony_ci filesystems. 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_cierrors=opt What to do when critical filesystem errors are found. 18262306a36Sopenharmony_ci Following values can be used for "opt": 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci ======== ========================================= 18562306a36Sopenharmony_ci continue DEFAULT, try to clean-up as much as 18662306a36Sopenharmony_ci possible, e.g. marking a corrupt inode as 18762306a36Sopenharmony_ci bad so it is no longer accessed, and then 18862306a36Sopenharmony_ci continue. 18962306a36Sopenharmony_ci recover At present only supported is recovery of 19062306a36Sopenharmony_ci the boot sector from the backup copy. 19162306a36Sopenharmony_ci If read-only mount, the recovery is done 19262306a36Sopenharmony_ci in memory only and not written to disk. 19362306a36Sopenharmony_ci ======== ========================================= 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci Note that the options are additive, i.e. specifying:: 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci errors=continue,errors=recover 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci means the driver will attempt to recover and if that 20062306a36Sopenharmony_ci fails it will clean-up as much as possible and 20162306a36Sopenharmony_ci continue. 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_cimft_zone_multiplier= Set the MFT zone multiplier for the volume (this 20462306a36Sopenharmony_ci setting is not persistent across mounts and can be 20562306a36Sopenharmony_ci changed from mount to mount but cannot be changed on 20662306a36Sopenharmony_ci remount). Values of 1 to 4 are allowed, 1 being the 20762306a36Sopenharmony_ci default. The MFT zone multiplier determines how much 20862306a36Sopenharmony_ci space is reserved for the MFT on the volume. If all 20962306a36Sopenharmony_ci other space is used up, then the MFT zone will be 21062306a36Sopenharmony_ci shrunk dynamically, so this has no impact on the 21162306a36Sopenharmony_ci amount of free space. However, it can have an impact 21262306a36Sopenharmony_ci on performance by affecting fragmentation of the MFT. 21362306a36Sopenharmony_ci In general use the default. If you have a lot of small 21462306a36Sopenharmony_ci files then use a higher value. The values have the 21562306a36Sopenharmony_ci following meaning: 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci ===== ================================= 21862306a36Sopenharmony_ci Value MFT zone size (% of volume size) 21962306a36Sopenharmony_ci ===== ================================= 22062306a36Sopenharmony_ci 1 12.5% 22162306a36Sopenharmony_ci 2 25% 22262306a36Sopenharmony_ci 3 37.5% 22362306a36Sopenharmony_ci 4 50% 22462306a36Sopenharmony_ci ===== ================================= 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci Note this option is irrelevant for read-only mounts. 22762306a36Sopenharmony_ci======================= ======================================================= 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ciKnown bugs and (mis-)features 23162306a36Sopenharmony_ci============================= 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci- The link count on each directory inode entry is set to 1, due to Linux not 23462306a36Sopenharmony_ci supporting directory hard links. This may well confuse some user space 23562306a36Sopenharmony_ci applications, since the directory names will have the same inode numbers. 23662306a36Sopenharmony_ci This also speeds up ntfs_read_inode() immensely. And we haven't found any 23762306a36Sopenharmony_ci problems with this approach so far. If you find a problem with this, please 23862306a36Sopenharmony_ci let us know. 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ciPlease send bug reports/comments/feedback/abuse to the Linux-NTFS development 24262306a36Sopenharmony_cilist at sourceforge: linux-ntfs-dev@lists.sourceforge.net 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ciUsing NTFS volume and stripe sets 24662306a36Sopenharmony_ci================================= 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ciFor support of volume and stripe sets, you can either use the kernel's 24962306a36Sopenharmony_ciDevice-Mapper driver or the kernel's Software RAID / MD driver. The former is 25062306a36Sopenharmony_cithe recommended one to use for linear raid. But the latter is required for 25162306a36Sopenharmony_ciraid level 5. For striping and mirroring, either driver should work fine. 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ciThe Device-Mapper driver 25562306a36Sopenharmony_ci------------------------ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ciYou will need to create a table of the components of the volume/stripe set and 25862306a36Sopenharmony_cihow they fit together and load this into the kernel using the dmsetup utility 25962306a36Sopenharmony_ci(see man 8 dmsetup). 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ciLinear volume sets, i.e. linear raid, has been tested and works fine. Even 26262306a36Sopenharmony_cithough untested, there is no reason why stripe sets, i.e. raid level 0, and 26362306a36Sopenharmony_cimirrors, i.e. raid level 1 should not work, too. Stripes with parity, i.e. 26462306a36Sopenharmony_ciraid level 5, unfortunately cannot work yet because the current version of the 26562306a36Sopenharmony_ciDevice-Mapper driver does not support raid level 5. You may be able to use the 26662306a36Sopenharmony_ciSoftware RAID / MD driver for raid level 5, see the next section for details. 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ciTo create the table describing your volume you will need to know each of its 26962306a36Sopenharmony_cicomponents and their sizes in sectors, i.e. multiples of 512-byte blocks. 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ciFor NT4 fault tolerant volumes you can obtain the sizes using fdisk. So for 27262306a36Sopenharmony_ciexample if one of your partitions is /dev/hda2 you would do:: 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci $ fdisk -ul /dev/hda 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci Disk /dev/hda: 81.9 GB, 81964302336 bytes 27762306a36Sopenharmony_ci 255 heads, 63 sectors/track, 9964 cylinders, total 160086528 sectors 27862306a36Sopenharmony_ci Units = sectors of 1 * 512 = 512 bytes 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci Device Boot Start End Blocks Id System 28162306a36Sopenharmony_ci /dev/hda1 * 63 4209029 2104483+ 83 Linux 28262306a36Sopenharmony_ci /dev/hda2 4209030 37768814 16779892+ 86 NTFS 28362306a36Sopenharmony_ci /dev/hda3 37768815 46170809 4200997+ 83 Linux 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ciAnd you would know that /dev/hda2 has a size of 37768814 - 4209030 + 1 = 28662306a36Sopenharmony_ci33559785 sectors. 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ciFor Win2k and later dynamic disks, you can for example use the ldminfo utility 28962306a36Sopenharmony_ciwhich is part of the Linux LDM tools (the latest version at the time of 29062306a36Sopenharmony_ciwriting is linux-ldm-0.0.8.tar.bz2). You can download it from: 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci http://www.linux-ntfs.org/ 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ciSimply extract the downloaded archive (tar xvjf linux-ldm-0.0.8.tar.bz2), go 29562306a36Sopenharmony_ciinto it (cd linux-ldm-0.0.8) and change to the test directory (cd test). You 29662306a36Sopenharmony_ciwill find the precompiled (i386) ldminfo utility there. NOTE: You will not be 29762306a36Sopenharmony_ciable to compile this yourself easily so use the binary version! 29862306a36Sopenharmony_ci 29962306a36Sopenharmony_ciThen you would use ldminfo in dump mode to obtain the necessary information:: 30062306a36Sopenharmony_ci 30162306a36Sopenharmony_ci $ ./ldminfo --dump /dev/hda 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ciThis would dump the LDM database found on /dev/hda which describes all of your 30462306a36Sopenharmony_cidynamic disks and all the volumes on them. At the bottom you will see the 30562306a36Sopenharmony_ciVOLUME DEFINITIONS section which is all you really need. You may need to look 30662306a36Sopenharmony_cifurther above to determine which of the disks in the volume definitions is 30762306a36Sopenharmony_ciwhich device in Linux. Hint: Run ldminfo on each of your dynamic disks and 30862306a36Sopenharmony_cilook at the Disk Id close to the top of the output for each (the PRIVATE HEADER 30962306a36Sopenharmony_cisection). You can then find these Disk Ids in the VBLK DATABASE section in the 31062306a36Sopenharmony_ci<Disk> components where you will get the LDM Name for the disk that is found in 31162306a36Sopenharmony_cithe VOLUME DEFINITIONS section. 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ciNote you will also need to enable the LDM driver in the Linux kernel. If your 31462306a36Sopenharmony_cidistribution did not enable it, you will need to recompile the kernel with it 31562306a36Sopenharmony_cienabled. This will create the LDM partitions on each device at boot time. You 31662306a36Sopenharmony_ciwould then use those devices (for /dev/hda they would be /dev/hda1, 2, 3, etc) 31762306a36Sopenharmony_ciin the Device-Mapper table. 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ciYou can also bypass using the LDM driver by using the main device (e.g. 32062306a36Sopenharmony_ci/dev/hda) and then using the offsets of the LDM partitions into this device as 32162306a36Sopenharmony_cithe "Start sector of device" when creating the table. Once again ldminfo would 32262306a36Sopenharmony_cigive you the correct information to do this. 32362306a36Sopenharmony_ci 32462306a36Sopenharmony_ciAssuming you know all your devices and their sizes things are easy. 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ciFor a linear raid the table would look like this (note all values are in 32762306a36Sopenharmony_ci512-byte sectors):: 32862306a36Sopenharmony_ci 32962306a36Sopenharmony_ci # Offset into Size of this Raid type Device Start sector 33062306a36Sopenharmony_ci # volume device of device 33162306a36Sopenharmony_ci 0 1028161 linear /dev/hda1 0 33262306a36Sopenharmony_ci 1028161 3903762 linear /dev/hdb2 0 33362306a36Sopenharmony_ci 4931923 2103211 linear /dev/hdc1 0 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ciFor a striped volume, i.e. raid level 0, you will need to know the chunk size 33662306a36Sopenharmony_ciyou used when creating the volume. Windows uses 64kiB as the default, so it 33762306a36Sopenharmony_ciwill probably be this unless you changes the defaults when creating the array. 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ciFor a raid level 0 the table would look like this (note all values are in 34062306a36Sopenharmony_ci512-byte sectors):: 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ci # Offset Size Raid Number Chunk 1st Start 2nd Start 34362306a36Sopenharmony_ci # into of the type of size Device in Device in 34462306a36Sopenharmony_ci # volume volume stripes device device 34562306a36Sopenharmony_ci 0 2056320 striped 2 128 /dev/hda1 0 /dev/hdb1 0 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ciIf there are more than two devices, just add each of them to the end of the 34862306a36Sopenharmony_ciline. 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ciFinally, for a mirrored volume, i.e. raid level 1, the table would look like 35162306a36Sopenharmony_cithis (note all values are in 512-byte sectors):: 35262306a36Sopenharmony_ci 35362306a36Sopenharmony_ci # Ofs Size Raid Log Number Region Should Number Source Start Target Start 35462306a36Sopenharmony_ci # in of the type type of log size sync? of Device in Device in 35562306a36Sopenharmony_ci # vol volume params mirrors Device Device 35662306a36Sopenharmony_ci 0 2056320 mirror core 2 16 nosync 2 /dev/hda1 0 /dev/hdb1 0 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ciIf you are mirroring to multiple devices you can specify further targets at the 35962306a36Sopenharmony_ciend of the line. 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ciNote the "Should sync?" parameter "nosync" means that the two mirrors are 36262306a36Sopenharmony_cialready in sync which will be the case on a clean shutdown of Windows. If the 36362306a36Sopenharmony_cimirrors are not clean, you can specify the "sync" option instead of "nosync" 36462306a36Sopenharmony_ciand the Device-Mapper driver will then copy the entirety of the "Source Device" 36562306a36Sopenharmony_cito the "Target Device" or if you specified multiple target devices to all of 36662306a36Sopenharmony_cithem. 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ciOnce you have your table, save it in a file somewhere (e.g. /etc/ntfsvolume1), 36962306a36Sopenharmony_ciand hand it over to dmsetup to work with, like so:: 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci $ dmsetup create myvolume1 /etc/ntfsvolume1 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ciYou can obviously replace "myvolume1" with whatever name you like. 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ciIf it all worked, you will now have the device /dev/device-mapper/myvolume1 37662306a36Sopenharmony_ciwhich you can then just use as an argument to the mount command as usual to 37762306a36Sopenharmony_cimount the ntfs volume. For example:: 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci $ mount -t ntfs -o ro /dev/device-mapper/myvolume1 /mnt/myvol1 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci(You need to create the directory /mnt/myvol1 first and of course you can use 38262306a36Sopenharmony_cianything you like instead of /mnt/myvol1 as long as it is an existing 38362306a36Sopenharmony_cidirectory.) 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ciIt is advisable to do the mount read-only to see if the volume has been setup 38662306a36Sopenharmony_cicorrectly to avoid the possibility of causing damage to the data on the ntfs 38762306a36Sopenharmony_civolume. 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ciThe Software RAID / MD driver 39162306a36Sopenharmony_ci----------------------------- 39262306a36Sopenharmony_ci 39362306a36Sopenharmony_ciAn alternative to using the Device-Mapper driver is to use the kernel's 39462306a36Sopenharmony_ciSoftware RAID / MD driver. For which you need to set up your /etc/raidtab 39562306a36Sopenharmony_ciappropriately (see man 5 raidtab). 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ciLinear volume sets, i.e. linear raid, as well as stripe sets, i.e. raid level 39862306a36Sopenharmony_ci0, have been tested and work fine (though see section "Limitations when using 39962306a36Sopenharmony_cithe MD driver with NTFS volumes" especially if you want to use linear raid). 40062306a36Sopenharmony_ciEven though untested, there is no reason why mirrors, i.e. raid level 1, and 40162306a36Sopenharmony_cistripes with parity, i.e. raid level 5, should not work, too. 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ciYou have to use the "persistent-superblock 0" option for each raid-disk in the 40462306a36Sopenharmony_ciNTFS volume/stripe you are configuring in /etc/raidtab as the persistent 40562306a36Sopenharmony_cisuperblock used by the MD driver would damage the NTFS volume. 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ciWindows by default uses a stripe chunk size of 64k, so you probably want the 40862306a36Sopenharmony_ci"chunk-size 64k" option for each raid-disk, too. 40962306a36Sopenharmony_ci 41062306a36Sopenharmony_ciFor example, if you have a stripe set consisting of two partitions /dev/hda5 41162306a36Sopenharmony_ciand /dev/hdb1 your /etc/raidtab would look like this:: 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci raiddev /dev/md0 41462306a36Sopenharmony_ci raid-level 0 41562306a36Sopenharmony_ci nr-raid-disks 2 41662306a36Sopenharmony_ci nr-spare-disks 0 41762306a36Sopenharmony_ci persistent-superblock 0 41862306a36Sopenharmony_ci chunk-size 64k 41962306a36Sopenharmony_ci device /dev/hda5 42062306a36Sopenharmony_ci raid-disk 0 42162306a36Sopenharmony_ci device /dev/hdb1 42262306a36Sopenharmony_ci raid-disk 1 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ciFor linear raid, just change the raid-level above to "raid-level linear", for 42562306a36Sopenharmony_cimirrors, change it to "raid-level 1", and for stripe sets with parity, change 42662306a36Sopenharmony_ciit to "raid-level 5". 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ciNote for stripe sets with parity you will also need to tell the MD driver 42962306a36Sopenharmony_ciwhich parity algorithm to use by specifying the option "parity-algorithm 43062306a36Sopenharmony_ciwhich", where you need to replace "which" with the name of the algorithm to 43162306a36Sopenharmony_ciuse (see man 5 raidtab for available algorithms) and you will have to try the 43262306a36Sopenharmony_cidifferent available algorithms until you find one that works. Make sure you 43362306a36Sopenharmony_ciare working read-only when playing with this as you may damage your data 43462306a36Sopenharmony_ciotherwise. If you find which algorithm works please let us know (email the 43562306a36Sopenharmony_cilinux-ntfs developers list linux-ntfs-dev@lists.sourceforge.net or drop in on 43662306a36Sopenharmony_ciIRC in channel #ntfs on the irc.freenode.net network) so we can update this 43762306a36Sopenharmony_cidocumentation. 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ciOnce the raidtab is setup, run for example raid0run -a to start all devices or 44062306a36Sopenharmony_ciraid0run /dev/md0 to start a particular md device, in this case /dev/md0. 44162306a36Sopenharmony_ci 44262306a36Sopenharmony_ciThen just use the mount command as usual to mount the ntfs volume using for 44362306a36Sopenharmony_ciexample:: 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci mount -t ntfs -o ro /dev/md0 /mnt/myntfsvolume 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ciIt is advisable to do the mount read-only to see if the md volume has been 44862306a36Sopenharmony_cisetup correctly to avoid the possibility of causing damage to the data on the 44962306a36Sopenharmony_cintfs volume. 45062306a36Sopenharmony_ci 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ciLimitations when using the Software RAID / MD driver 45362306a36Sopenharmony_ci----------------------------------------------------- 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ciUsing the md driver will not work properly if any of your NTFS partitions have 45662306a36Sopenharmony_cian odd number of sectors. This is especially important for linear raid as all 45762306a36Sopenharmony_cidata after the first partition with an odd number of sectors will be offset by 45862306a36Sopenharmony_cione or more sectors so if you mount such a partition with write support you 45962306a36Sopenharmony_ciwill cause massive damage to the data on the volume which will only become 46062306a36Sopenharmony_ciapparent when you try to use the volume again under Windows. 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ciSo when using linear raid, make sure that all your partitions have an even 46362306a36Sopenharmony_cinumber of sectors BEFORE attempting to use it. You have been warned! 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ciEven better is to simply use the Device-Mapper for linear raid and then you do 46662306a36Sopenharmony_cinot have this problem with odd numbers of sectors. 467