NTFS

From LQWiki
Jump to: navigation, search

NTFS (New Technology File System) is the default filesystem for Microsoft Windows. It is the only file system that can be read as well with Windows as with Linux and can store files greater than 2GB.

Creating NTFS volumes

To create an NTFS volume you need to format a partition erasing all data. In this example we use /dev/sdb1:

# fdisk -l /dev/sdb

Disk /dev/sdb: 8254 MB, 8254390272 bytes
254 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 15748 * 512 = 8062976 bytes
Disk identifier: 0x1ebdf237

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1023     8055071   83  Linux
# mkfs.ntfs /dev/sdb1
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

mounting NTFS volumes

In Linux there are the following ways to mount NTFS volumes: Linux-NTFS (kernel driver), ntfs-3g (fuse) and Captive-NTFS.

read/write

To mount our NTFS partition read/write, use ntfs3g:

# mkdir /mnt/ntfs
# ntfs-3g /dev/sdb1 /mnt/ntfs
# ls /mnt/ntfs
# echo hallo>/mnt/ntfs/welt
# ll /mnt/ntfs/
total 1
-rwxrwxrwx 1 root root 6 Dec  8 12:37 welt

ntfs3g uses fuse.

unmounting NTFS volumes

To unmount our NTFS partition, remember that it is mounted using fuse:

# mount
[...]
/dev/sdb1 on /mnt/ntfs type fuseblk (rw,allow_other,blksize=4096)

So you can just unmount it using the command umount:

# umount /dev/sdb1