18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci================================
48c2ecf20Sopenharmony_ciThe Linux NTFS filesystem driver
58c2ecf20Sopenharmony_ci================================
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci.. Table of contents
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci   - Overview
118c2ecf20Sopenharmony_ci   - Web site
128c2ecf20Sopenharmony_ci   - Features
138c2ecf20Sopenharmony_ci   - Supported mount options
148c2ecf20Sopenharmony_ci   - Known bugs and (mis-)features
158c2ecf20Sopenharmony_ci   - Using NTFS volume and stripe sets
168c2ecf20Sopenharmony_ci     - The Device-Mapper driver
178c2ecf20Sopenharmony_ci     - The Software RAID / MD driver
188c2ecf20Sopenharmony_ci     - Limitations when using the MD driver
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciOverview
228c2ecf20Sopenharmony_ci========
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciLinux-NTFS comes with a number of user-space programs known as ntfsprogs.
258c2ecf20Sopenharmony_ciThese include mkntfs, a full-featured ntfs filesystem format utility,
268c2ecf20Sopenharmony_cintfsundelete used for recovering files that were unintentionally deleted
278c2ecf20Sopenharmony_cifrom an NTFS volume and ntfsresize which is used to resize an NTFS partition.
288c2ecf20Sopenharmony_ciSee the web site for more information.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciTo mount an NTFS 1.2/3.x (Windows NT4/2000/XP/2003) volume, use the file
318c2ecf20Sopenharmony_cisystem type 'ntfs'.  The driver currently supports read-only mode (with no
328c2ecf20Sopenharmony_cifault-tolerance, encryption or journalling) and very limited, but safe, write
338c2ecf20Sopenharmony_cisupport.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciFor fault tolerance and raid support (i.e. volume and stripe sets), you can
368c2ecf20Sopenharmony_ciuse the kernel's Software RAID / MD driver.  See section "Using Software RAID
378c2ecf20Sopenharmony_ciwith NTFS" for details.
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciWeb site
418c2ecf20Sopenharmony_ci========
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciThere is plenty of additional information on the linux-ntfs web site
448c2ecf20Sopenharmony_ciat http://www.linux-ntfs.org/
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciThe web site has a lot of additional information, such as a comprehensive
478c2ecf20Sopenharmony_ciFAQ, documentation on the NTFS on-disk format, information on the Linux-NTFS
488c2ecf20Sopenharmony_ciuserspace utilities, etc.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciFeatures
528c2ecf20Sopenharmony_ci========
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci- This is a complete rewrite of the NTFS driver that used to be in the 2.4 and
558c2ecf20Sopenharmony_ci  earlier kernels.  This new driver implements NTFS read support and is
568c2ecf20Sopenharmony_ci  functionally equivalent to the old ntfs driver and it also implements limited
578c2ecf20Sopenharmony_ci  write support.  The biggest limitation at present is that files/directories
588c2ecf20Sopenharmony_ci  cannot be created or deleted.  See below for the list of write features that
598c2ecf20Sopenharmony_ci  are so far supported.  Another limitation is that writing to compressed files
608c2ecf20Sopenharmony_ci  is not implemented at all.  Also, neither read nor write access to encrypted
618c2ecf20Sopenharmony_ci  files is so far implemented.
628c2ecf20Sopenharmony_ci- The new driver has full support for sparse files on NTFS 3.x volumes which
638c2ecf20Sopenharmony_ci  the old driver isn't happy with.
648c2ecf20Sopenharmony_ci- The new driver supports execution of binaries due to mmap() now being
658c2ecf20Sopenharmony_ci  supported.
668c2ecf20Sopenharmony_ci- The new driver supports loopback mounting of files on NTFS which is used by
678c2ecf20Sopenharmony_ci  some Linux distributions to enable the user to run Linux from an NTFS
688c2ecf20Sopenharmony_ci  partition by creating a large file while in Windows and then loopback
698c2ecf20Sopenharmony_ci  mounting the file while in Linux and creating a Linux filesystem on it that
708c2ecf20Sopenharmony_ci  is used to install Linux on it.
718c2ecf20Sopenharmony_ci- A comparison of the two drivers using::
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	time find . -type f -exec md5sum "{}" \;
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci  run three times in sequence with each driver (after a reboot) on a 1.4GiB
768c2ecf20Sopenharmony_ci  NTFS partition, showed the new driver to be 20% faster in total time elapsed
778c2ecf20Sopenharmony_ci  (from 9:43 minutes on average down to 7:53).  The time spent in user space
788c2ecf20Sopenharmony_ci  was unchanged but the time spent in the kernel was decreased by a factor of
798c2ecf20Sopenharmony_ci  2.5 (from 85 CPU seconds down to 33).
808c2ecf20Sopenharmony_ci- The driver does not support short file names in general.  For backwards
818c2ecf20Sopenharmony_ci  compatibility, we implement access to files using their short file names if
828c2ecf20Sopenharmony_ci  they exist.  The driver will not create short file names however, and a
838c2ecf20Sopenharmony_ci  rename will discard any existing short file name.
848c2ecf20Sopenharmony_ci- The new driver supports exporting of mounted NTFS volumes via NFS.
858c2ecf20Sopenharmony_ci- The new driver supports async io (aio).
868c2ecf20Sopenharmony_ci- The new driver supports fsync(2), fdatasync(2), and msync(2).
878c2ecf20Sopenharmony_ci- The new driver supports readv(2) and writev(2).
888c2ecf20Sopenharmony_ci- The new driver supports access time updates (including mtime and ctime).
898c2ecf20Sopenharmony_ci- The new driver supports truncate(2) and open(2) with O_TRUNC.  But at present
908c2ecf20Sopenharmony_ci  only very limited support for highly fragmented files, i.e. ones which have
918c2ecf20Sopenharmony_ci  their data attribute split across multiple extents, is included.  Another
928c2ecf20Sopenharmony_ci  limitation is that at present truncate(2) will never create sparse files,
938c2ecf20Sopenharmony_ci  since to mark a file sparse we need to modify the directory entry for the
948c2ecf20Sopenharmony_ci  file and we do not implement directory modifications yet.
958c2ecf20Sopenharmony_ci- The new driver supports write(2) which can both overwrite existing data and
968c2ecf20Sopenharmony_ci  extend the file size so that you can write beyond the existing data.  Also,
978c2ecf20Sopenharmony_ci  writing into sparse regions is supported and the holes are filled in with
988c2ecf20Sopenharmony_ci  clusters.  But at present only limited support for highly fragmented files,
998c2ecf20Sopenharmony_ci  i.e. ones which have their data attribute split across multiple extents, is
1008c2ecf20Sopenharmony_ci  included.  Another limitation is that write(2) will never create sparse
1018c2ecf20Sopenharmony_ci  files, since to mark a file sparse we need to modify the directory entry for
1028c2ecf20Sopenharmony_ci  the file and we do not implement directory modifications yet.
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciSupported mount options
1058c2ecf20Sopenharmony_ci=======================
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciIn addition to the generic mount options described by the manual page for the
1088c2ecf20Sopenharmony_cimount command (man 8 mount, also see man 5 fstab), the NTFS driver supports the
1098c2ecf20Sopenharmony_cifollowing mount options:
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci======================= =======================================================
1128c2ecf20Sopenharmony_ciiocharset=name		Deprecated option.  Still supported but please use
1138c2ecf20Sopenharmony_ci			nls=name in the future.  See description for nls=name.
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cinls=name		Character set to use when returning file names.
1168c2ecf20Sopenharmony_ci			Unlike VFAT, NTFS suppresses names that contain
1178c2ecf20Sopenharmony_ci			unconvertible characters.  Note that most character
1188c2ecf20Sopenharmony_ci			sets contain insufficient characters to represent all
1198c2ecf20Sopenharmony_ci			possible Unicode characters that can exist on NTFS.
1208c2ecf20Sopenharmony_ci			To be sure you are not missing any files, you are
1218c2ecf20Sopenharmony_ci			advised to use nls=utf8 which is capable of
1228c2ecf20Sopenharmony_ci			representing all Unicode characters.
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciutf8=<bool>		Option no longer supported.  Currently mapped to
1258c2ecf20Sopenharmony_ci			nls=utf8 but please use nls=utf8 in the future and
1268c2ecf20Sopenharmony_ci			make sure utf8 is compiled either as module or into
1278c2ecf20Sopenharmony_ci			the kernel.  See description for nls=name.
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ciuid=
1308c2ecf20Sopenharmony_cigid=
1318c2ecf20Sopenharmony_ciumask=			Provide default owner, group, and access mode mask.
1328c2ecf20Sopenharmony_ci			These options work as documented in mount(8).  By
1338c2ecf20Sopenharmony_ci			default, the files/directories are owned by root and
1348c2ecf20Sopenharmony_ci			he/she has read and write permissions, as well as
1358c2ecf20Sopenharmony_ci			browse permission for directories.  No one else has any
1368c2ecf20Sopenharmony_ci			access permissions.  I.e. the mode on all files is by
1378c2ecf20Sopenharmony_ci			default rw------- and for directories rwx------, a
1388c2ecf20Sopenharmony_ci			consequence of the default fmask=0177 and dmask=0077.
1398c2ecf20Sopenharmony_ci			Using a umask of zero will grant all permissions to
1408c2ecf20Sopenharmony_ci			everyone, i.e. all files and directories will have mode
1418c2ecf20Sopenharmony_ci			rwxrwxrwx.
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cifmask=
1448c2ecf20Sopenharmony_cidmask=			Instead of specifying umask which applies both to
1458c2ecf20Sopenharmony_ci			files and directories, fmask applies only to files and
1468c2ecf20Sopenharmony_ci			dmask only to directories.
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_cisloppy=<BOOL>		If sloppy is specified, ignore unknown mount options.
1498c2ecf20Sopenharmony_ci			Otherwise the default behaviour is to abort mount if
1508c2ecf20Sopenharmony_ci			any unknown options are found.
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cishow_sys_files=<BOOL>	If show_sys_files is specified, show the system files
1538c2ecf20Sopenharmony_ci			in directory listings.  Otherwise the default behaviour
1548c2ecf20Sopenharmony_ci			is to hide the system files.
1558c2ecf20Sopenharmony_ci			Note that even when show_sys_files is specified, "$MFT"
1568c2ecf20Sopenharmony_ci			will not be visible due to bugs/mis-features in glibc.
1578c2ecf20Sopenharmony_ci			Further, note that irrespective of show_sys_files, all
1588c2ecf20Sopenharmony_ci			files are accessible by name, i.e. you can always do
1598c2ecf20Sopenharmony_ci			"ls -l \$UpCase" for example to specifically show the
1608c2ecf20Sopenharmony_ci			system file containing the Unicode upcase table.
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cicase_sensitive=<BOOL>	If case_sensitive is specified, treat all file names as
1638c2ecf20Sopenharmony_ci			case sensitive and create file names in the POSIX
1648c2ecf20Sopenharmony_ci			namespace.  Otherwise the default behaviour is to treat
1658c2ecf20Sopenharmony_ci			file names as case insensitive and to create file names
1668c2ecf20Sopenharmony_ci			in the WIN32/LONG name space.  Note, the Linux NTFS
1678c2ecf20Sopenharmony_ci			driver will never create short file names and will
1688c2ecf20Sopenharmony_ci			remove them on rename/delete of the corresponding long
1698c2ecf20Sopenharmony_ci			file name.
1708c2ecf20Sopenharmony_ci			Note that files remain accessible via their short file
1718c2ecf20Sopenharmony_ci			name, if it exists.  If case_sensitive, you will need
1728c2ecf20Sopenharmony_ci			to provide the correct case of the short file name.
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cidisable_sparse=<BOOL>	If disable_sparse is specified, creation of sparse
1758c2ecf20Sopenharmony_ci			regions, i.e. holes, inside files is disabled for the
1768c2ecf20Sopenharmony_ci			volume (for the duration of this mount only).  By
1778c2ecf20Sopenharmony_ci			default, creation of sparse regions is enabled, which
1788c2ecf20Sopenharmony_ci			is consistent with the behaviour of traditional Unix
1798c2ecf20Sopenharmony_ci			filesystems.
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_cierrors=opt		What to do when critical filesystem errors are found.
1828c2ecf20Sopenharmony_ci			Following values can be used for "opt":
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci			  ========  =========================================
1858c2ecf20Sopenharmony_ci			  continue  DEFAULT, try to clean-up as much as
1868c2ecf20Sopenharmony_ci				    possible, e.g. marking a corrupt inode as
1878c2ecf20Sopenharmony_ci				    bad so it is no longer accessed, and then
1888c2ecf20Sopenharmony_ci				    continue.
1898c2ecf20Sopenharmony_ci			  recover   At present only supported is recovery of
1908c2ecf20Sopenharmony_ci				    the boot sector from the backup copy.
1918c2ecf20Sopenharmony_ci				    If read-only mount, the recovery is done
1928c2ecf20Sopenharmony_ci				    in memory only and not written to disk.
1938c2ecf20Sopenharmony_ci			  ========  =========================================
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci			Note that the options are additive, i.e. specifying::
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci			   errors=continue,errors=recover
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci			means the driver will attempt to recover and if that
2008c2ecf20Sopenharmony_ci			fails it will clean-up as much as possible and
2018c2ecf20Sopenharmony_ci			continue.
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_cimft_zone_multiplier=	Set the MFT zone multiplier for the volume (this
2048c2ecf20Sopenharmony_ci			setting is not persistent across mounts and can be
2058c2ecf20Sopenharmony_ci			changed from mount to mount but cannot be changed on
2068c2ecf20Sopenharmony_ci			remount).  Values of 1 to 4 are allowed, 1 being the
2078c2ecf20Sopenharmony_ci			default.  The MFT zone multiplier determines how much
2088c2ecf20Sopenharmony_ci			space is reserved for the MFT on the volume.  If all
2098c2ecf20Sopenharmony_ci			other space is used up, then the MFT zone will be
2108c2ecf20Sopenharmony_ci			shrunk dynamically, so this has no impact on the
2118c2ecf20Sopenharmony_ci			amount of free space.  However, it can have an impact
2128c2ecf20Sopenharmony_ci			on performance by affecting fragmentation of the MFT.
2138c2ecf20Sopenharmony_ci			In general use the default.  If you have a lot of small
2148c2ecf20Sopenharmony_ci			files then use a higher value.  The values have the
2158c2ecf20Sopenharmony_ci			following meaning:
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci			      =====	    =================================
2188c2ecf20Sopenharmony_ci			      Value	     MFT zone size (% of volume size)
2198c2ecf20Sopenharmony_ci			      =====	    =================================
2208c2ecf20Sopenharmony_ci				1		12.5%
2218c2ecf20Sopenharmony_ci				2		25%
2228c2ecf20Sopenharmony_ci				3		37.5%
2238c2ecf20Sopenharmony_ci				4		50%
2248c2ecf20Sopenharmony_ci			      =====	    =================================
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci			Note this option is irrelevant for read-only mounts.
2278c2ecf20Sopenharmony_ci======================= =======================================================
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ciKnown bugs and (mis-)features
2318c2ecf20Sopenharmony_ci=============================
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci- The link count on each directory inode entry is set to 1, due to Linux not
2348c2ecf20Sopenharmony_ci  supporting directory hard links.  This may well confuse some user space
2358c2ecf20Sopenharmony_ci  applications, since the directory names will have the same inode numbers.
2368c2ecf20Sopenharmony_ci  This also speeds up ntfs_read_inode() immensely.  And we haven't found any
2378c2ecf20Sopenharmony_ci  problems with this approach so far.  If you find a problem with this, please
2388c2ecf20Sopenharmony_ci  let us know.
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ciPlease send bug reports/comments/feedback/abuse to the Linux-NTFS development
2428c2ecf20Sopenharmony_cilist at sourceforge: linux-ntfs-dev@lists.sourceforge.net
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ciUsing NTFS volume and stripe sets
2468c2ecf20Sopenharmony_ci=================================
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ciFor support of volume and stripe sets, you can either use the kernel's
2498c2ecf20Sopenharmony_ciDevice-Mapper driver or the kernel's Software RAID / MD driver.  The former is
2508c2ecf20Sopenharmony_cithe recommended one to use for linear raid.  But the latter is required for
2518c2ecf20Sopenharmony_ciraid level 5.  For striping and mirroring, either driver should work fine.
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ciThe Device-Mapper driver
2558c2ecf20Sopenharmony_ci------------------------
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ciYou will need to create a table of the components of the volume/stripe set and
2588c2ecf20Sopenharmony_cihow they fit together and load this into the kernel using the dmsetup utility
2598c2ecf20Sopenharmony_ci(see man 8 dmsetup).
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ciLinear volume sets, i.e. linear raid, has been tested and works fine.  Even
2628c2ecf20Sopenharmony_cithough untested, there is no reason why stripe sets, i.e. raid level 0, and
2638c2ecf20Sopenharmony_cimirrors, i.e. raid level 1 should not work, too.  Stripes with parity, i.e.
2648c2ecf20Sopenharmony_ciraid level 5, unfortunately cannot work yet because the current version of the
2658c2ecf20Sopenharmony_ciDevice-Mapper driver does not support raid level 5.  You may be able to use the
2668c2ecf20Sopenharmony_ciSoftware RAID / MD driver for raid level 5, see the next section for details.
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ciTo create the table describing your volume you will need to know each of its
2698c2ecf20Sopenharmony_cicomponents and their sizes in sectors, i.e. multiples of 512-byte blocks.
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ciFor NT4 fault tolerant volumes you can obtain the sizes using fdisk.  So for
2728c2ecf20Sopenharmony_ciexample if one of your partitions is /dev/hda2 you would do::
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci    $ fdisk -ul /dev/hda
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci    Disk /dev/hda: 81.9 GB, 81964302336 bytes
2778c2ecf20Sopenharmony_ci    255 heads, 63 sectors/track, 9964 cylinders, total 160086528 sectors
2788c2ecf20Sopenharmony_ci    Units = sectors of 1 * 512 = 512 bytes
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	Device Boot      Start         End      Blocks   Id  System
2818c2ecf20Sopenharmony_ci	/dev/hda1   *          63     4209029     2104483+  83  Linux
2828c2ecf20Sopenharmony_ci	/dev/hda2         4209030    37768814    16779892+  86  NTFS
2838c2ecf20Sopenharmony_ci	/dev/hda3        37768815    46170809     4200997+  83  Linux
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ciAnd you would know that /dev/hda2 has a size of 37768814 - 4209030 + 1 =
2868c2ecf20Sopenharmony_ci33559785 sectors.
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ciFor Win2k and later dynamic disks, you can for example use the ldminfo utility
2898c2ecf20Sopenharmony_ciwhich is part of the Linux LDM tools (the latest version at the time of
2908c2ecf20Sopenharmony_ciwriting is linux-ldm-0.0.8.tar.bz2).  You can download it from:
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	http://www.linux-ntfs.org/
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ciSimply extract the downloaded archive (tar xvjf linux-ldm-0.0.8.tar.bz2), go
2958c2ecf20Sopenharmony_ciinto it (cd linux-ldm-0.0.8) and change to the test directory (cd test).  You
2968c2ecf20Sopenharmony_ciwill find the precompiled (i386) ldminfo utility there.  NOTE: You will not be
2978c2ecf20Sopenharmony_ciable to compile this yourself easily so use the binary version!
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ciThen you would use ldminfo in dump mode to obtain the necessary information::
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci    $ ./ldminfo --dump /dev/hda
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ciThis would dump the LDM database found on /dev/hda which describes all of your
3048c2ecf20Sopenharmony_cidynamic disks and all the volumes on them.  At the bottom you will see the
3058c2ecf20Sopenharmony_ciVOLUME DEFINITIONS section which is all you really need.  You may need to look
3068c2ecf20Sopenharmony_cifurther above to determine which of the disks in the volume definitions is
3078c2ecf20Sopenharmony_ciwhich device in Linux.  Hint: Run ldminfo on each of your dynamic disks and
3088c2ecf20Sopenharmony_cilook at the Disk Id close to the top of the output for each (the PRIVATE HEADER
3098c2ecf20Sopenharmony_cisection).  You can then find these Disk Ids in the VBLK DATABASE section in the
3108c2ecf20Sopenharmony_ci<Disk> components where you will get the LDM Name for the disk that is found in
3118c2ecf20Sopenharmony_cithe VOLUME DEFINITIONS section.
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ciNote you will also need to enable the LDM driver in the Linux kernel.  If your
3148c2ecf20Sopenharmony_cidistribution did not enable it, you will need to recompile the kernel with it
3158c2ecf20Sopenharmony_cienabled.  This will create the LDM partitions on each device at boot time.  You
3168c2ecf20Sopenharmony_ciwould then use those devices (for /dev/hda they would be /dev/hda1, 2, 3, etc)
3178c2ecf20Sopenharmony_ciin the Device-Mapper table.
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ciYou can also bypass using the LDM driver by using the main device (e.g.
3208c2ecf20Sopenharmony_ci/dev/hda) and then using the offsets of the LDM partitions into this device as
3218c2ecf20Sopenharmony_cithe "Start sector of device" when creating the table.  Once again ldminfo would
3228c2ecf20Sopenharmony_cigive you the correct information to do this.
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ciAssuming you know all your devices and their sizes things are easy.
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ciFor a linear raid the table would look like this (note all values are in
3278c2ecf20Sopenharmony_ci512-byte sectors)::
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci    # Offset into	Size of this	Raid type	Device		Start sector
3308c2ecf20Sopenharmony_ci    # volume	device						of device
3318c2ecf20Sopenharmony_ci    0		1028161		linear		/dev/hda1	0
3328c2ecf20Sopenharmony_ci    1028161		3903762		linear		/dev/hdb2	0
3338c2ecf20Sopenharmony_ci    4931923		2103211		linear		/dev/hdc1	0
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ciFor a striped volume, i.e. raid level 0, you will need to know the chunk size
3368c2ecf20Sopenharmony_ciyou used when creating the volume.  Windows uses 64kiB as the default, so it
3378c2ecf20Sopenharmony_ciwill probably be this unless you changes the defaults when creating the array.
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ciFor a raid level 0 the table would look like this (note all values are in
3408c2ecf20Sopenharmony_ci512-byte sectors)::
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci    # Offset   Size	    Raid     Number   Chunk  1st        Start	2nd	  Start
3438c2ecf20Sopenharmony_ci    # into     of the   type     of	      size   Device	in	Device	  in
3448c2ecf20Sopenharmony_ci    # volume   volume	     stripes			device		  device
3458c2ecf20Sopenharmony_ci    0	   2056320  striped  2	      128    /dev/hda1	0	/dev/hdb1 0
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ciIf there are more than two devices, just add each of them to the end of the
3488c2ecf20Sopenharmony_ciline.
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ciFinally, for a mirrored volume, i.e. raid level 1, the table would look like
3518c2ecf20Sopenharmony_cithis (note all values are in 512-byte sectors)::
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci    # Ofs Size   Raid   Log  Number Region Should Number Source  Start Target Start
3548c2ecf20Sopenharmony_ci    # in  of the type   type of log size   sync?  of     Device  in    Device in
3558c2ecf20Sopenharmony_ci    # vol volume		 params		     mirrors	     Device	  Device
3568c2ecf20Sopenharmony_ci    0    2056320 mirror core 2	16     nosync 2	   /dev/hda1 0   /dev/hdb1 0
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ciIf you are mirroring to multiple devices you can specify further targets at the
3598c2ecf20Sopenharmony_ciend of the line.
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ciNote the "Should sync?" parameter "nosync" means that the two mirrors are
3628c2ecf20Sopenharmony_cialready in sync which will be the case on a clean shutdown of Windows.  If the
3638c2ecf20Sopenharmony_cimirrors are not clean, you can specify the "sync" option instead of "nosync"
3648c2ecf20Sopenharmony_ciand the Device-Mapper driver will then copy the entirety of the "Source Device"
3658c2ecf20Sopenharmony_cito the "Target Device" or if you specified multiple target devices to all of
3668c2ecf20Sopenharmony_cithem.
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ciOnce you have your table, save it in a file somewhere (e.g. /etc/ntfsvolume1),
3698c2ecf20Sopenharmony_ciand hand it over to dmsetup to work with, like so::
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci    $ dmsetup create myvolume1 /etc/ntfsvolume1
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ciYou can obviously replace "myvolume1" with whatever name you like.
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ciIf it all worked, you will now have the device /dev/device-mapper/myvolume1
3768c2ecf20Sopenharmony_ciwhich you can then just use as an argument to the mount command as usual to
3778c2ecf20Sopenharmony_cimount the ntfs volume.  For example::
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci    $ mount -t ntfs -o ro /dev/device-mapper/myvolume1 /mnt/myvol1
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci(You need to create the directory /mnt/myvol1 first and of course you can use
3828c2ecf20Sopenharmony_cianything you like instead of /mnt/myvol1 as long as it is an existing
3838c2ecf20Sopenharmony_cidirectory.)
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ciIt is advisable to do the mount read-only to see if the volume has been setup
3868c2ecf20Sopenharmony_cicorrectly to avoid the possibility of causing damage to the data on the ntfs
3878c2ecf20Sopenharmony_civolume.
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ciThe Software RAID / MD driver
3918c2ecf20Sopenharmony_ci-----------------------------
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ciAn alternative to using the Device-Mapper driver is to use the kernel's
3948c2ecf20Sopenharmony_ciSoftware RAID / MD driver.  For which you need to set up your /etc/raidtab
3958c2ecf20Sopenharmony_ciappropriately (see man 5 raidtab).
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ciLinear volume sets, i.e. linear raid, as well as stripe sets, i.e. raid level
3988c2ecf20Sopenharmony_ci0, have been tested and work fine (though see section "Limitations when using
3998c2ecf20Sopenharmony_cithe MD driver with NTFS volumes" especially if you want to use linear raid).
4008c2ecf20Sopenharmony_ciEven though untested, there is no reason why mirrors, i.e. raid level 1, and
4018c2ecf20Sopenharmony_cistripes with parity, i.e. raid level 5, should not work, too.
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ciYou have to use the "persistent-superblock 0" option for each raid-disk in the
4048c2ecf20Sopenharmony_ciNTFS volume/stripe you are configuring in /etc/raidtab as the persistent
4058c2ecf20Sopenharmony_cisuperblock used by the MD driver would damage the NTFS volume.
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ciWindows by default uses a stripe chunk size of 64k, so you probably want the
4088c2ecf20Sopenharmony_ci"chunk-size 64k" option for each raid-disk, too.
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ciFor example, if you have a stripe set consisting of two partitions /dev/hda5
4118c2ecf20Sopenharmony_ciand /dev/hdb1 your /etc/raidtab would look like this::
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci    raiddev /dev/md0
4148c2ecf20Sopenharmony_ci	    raid-level	0
4158c2ecf20Sopenharmony_ci	    nr-raid-disks	2
4168c2ecf20Sopenharmony_ci	    nr-spare-disks	0
4178c2ecf20Sopenharmony_ci	    persistent-superblock	0
4188c2ecf20Sopenharmony_ci	    chunk-size	64k
4198c2ecf20Sopenharmony_ci	    device		/dev/hda5
4208c2ecf20Sopenharmony_ci	    raid-disk	0
4218c2ecf20Sopenharmony_ci	    device		/dev/hdb1
4228c2ecf20Sopenharmony_ci	    raid-disk	1
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ciFor linear raid, just change the raid-level above to "raid-level linear", for
4258c2ecf20Sopenharmony_cimirrors, change it to "raid-level 1", and for stripe sets with parity, change
4268c2ecf20Sopenharmony_ciit to "raid-level 5".
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ciNote for stripe sets with parity you will also need to tell the MD driver
4298c2ecf20Sopenharmony_ciwhich parity algorithm to use by specifying the option "parity-algorithm
4308c2ecf20Sopenharmony_ciwhich", where you need to replace "which" with the name of the algorithm to
4318c2ecf20Sopenharmony_ciuse (see man 5 raidtab for available algorithms) and you will have to try the
4328c2ecf20Sopenharmony_cidifferent available algorithms until you find one that works.  Make sure you
4338c2ecf20Sopenharmony_ciare working read-only when playing with this as you may damage your data
4348c2ecf20Sopenharmony_ciotherwise.  If you find which algorithm works please let us know (email the
4358c2ecf20Sopenharmony_cilinux-ntfs developers list linux-ntfs-dev@lists.sourceforge.net or drop in on
4368c2ecf20Sopenharmony_ciIRC in channel #ntfs on the irc.freenode.net network) so we can update this
4378c2ecf20Sopenharmony_cidocumentation.
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ciOnce the raidtab is setup, run for example raid0run -a to start all devices or
4408c2ecf20Sopenharmony_ciraid0run /dev/md0 to start a particular md device, in this case /dev/md0.
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ciThen just use the mount command as usual to mount the ntfs volume using for
4438c2ecf20Sopenharmony_ciexample::
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci    mount -t ntfs -o ro /dev/md0 /mnt/myntfsvolume
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ciIt is advisable to do the mount read-only to see if the md volume has been
4488c2ecf20Sopenharmony_cisetup correctly to avoid the possibility of causing damage to the data on the
4498c2ecf20Sopenharmony_cintfs volume.
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ciLimitations when using the Software RAID / MD driver
4538c2ecf20Sopenharmony_ci-----------------------------------------------------
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ciUsing the md driver will not work properly if any of your NTFS partitions have
4568c2ecf20Sopenharmony_cian odd number of sectors.  This is especially important for linear raid as all
4578c2ecf20Sopenharmony_cidata after the first partition with an odd number of sectors will be offset by
4588c2ecf20Sopenharmony_cione or more sectors so if you mount such a partition with write support you
4598c2ecf20Sopenharmony_ciwill cause massive damage to the data on the volume which will only become
4608c2ecf20Sopenharmony_ciapparent when you try to use the volume again under Windows.
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ciSo when using linear raid, make sure that all your partitions have an even
4638c2ecf20Sopenharmony_cinumber of sectors BEFORE attempting to use it.  You have been warned!
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ciEven better is to simply use the Device-Mapper for linear raid and then you do
4668c2ecf20Sopenharmony_cinot have this problem with odd numbers of sectors.
467