Reading ntfs in linux

Как монтировать NTFS в Linux

Инструкция на примере Linux CentOS 7.

Установка компонентов

Для начала необходимо установить пакет ntfs-3g. В противном случае, при попытке запустить команду на монтирование раздела NTFS мы получим ошибку mount: unknown filesystem type ‘ntfs’.

Сначала устанавливаем расширенный репозиторий:

yum install epel-release

Затем сам пакет ntfs-3g

yum install ntfs-3g

После установки данного пакета в системе появятся дополнительные команды mount.ntfs-fuse и mount.ntfs-3g., а также команда mount распознает опцию -t ntfs.

Ручное монтирование

Монтирование NTFS на чтение и запись выполняется любой из трех команд:

mount -t ntfs /dev/sdb1 /mnt

mount -t ntfs-3g /dev/sdb1 /mnt

mount.ntfs-3g /dev/sdb1 /mnt

* в данном примере, примотировано устройство /dev/sdb1 в раздел /mnt. Понять, какой устройство нужно монтировать можно при помощи команды fdisk -l

Автоматическое монтирование

Чтобы раздел автоматически монтировался при перезапуске компьютера, открываем на редактирование файл:

/dev/sdb1 /mnt ntfs defaults 0 0

* в данном примере мы раздел /dev/sdb1 будем монтировать в каталог /mnt.

Чтобы применить настройку и проверить ее, вводим:

Посмотреть примонтированные разделы и файловые системы можно командой:

Источник

NTFS-3G

NTFS-3G is an open source implementation of Microsoft NTFS that includes read and write support (the Linux kernel only supports reading NTFS). NTFS-3G developers use the FUSE file system to facilitate development and to help with portability.

Contents

Installation

Manual mounting

Two options exist when manually mounting NTFS partitions. The traditional:

The mount type ntfs-3g does not need to be explicitly specified in Arch. The mount command by default will use /usr/bin/mount.ntfs which is symlinked to /usr/bin/ntfs-3g after the ntfs-3g package is installed.

The second option is to call ntfs-3g directly:

See ntfs-3g(8) for the available options.

Formatting

Configuring

Your NTFS partition(s) can be setup to mount automatically, or pre-configured to be able to mount in a certain way when you would like them to be mounted. This configuration can be done in the static filesystem configuration (fstab) or by the use of udev rules.

Default settings

Using the default settings will mount the NTFS partition(s) at boot. With this method, if the parent folder that it is mounted upon has the proper user or group permissions (e.g. /run/media/ /), then that user or group will be able to read and write on that partition(s).

Linux compatible permissions

Permissions on a Linux system are normally set to 755 for folders and 644 for files. It is recommended to keep these permissions in use for the NTFS partition as well if you use the partition on a regular basis. The following example assigns the above permissions to a normal user:

Alternatively, if the Windows permissions do matter to you, you can use the ntfsusermap(8) command to map Windows users to Linux ones. ntfs-3g will handle the translation of these permissions.

Allowing group/user

In /etc/fstab you can also specify other options like those who are allowed to access (read) the partition. For example, for you to allow people in the groupid group to have access:

By default, the above line will enable write support for root only. To enable user writing, you have to specify the user who should be granted write permissions. Use the uid parameter together with your user id to enable user writing:

If you are running on a single user machine, you may like to own the file system yourself and grant all possible permissions:

Basic NTFS-3G options

For most, the above settings should suffice. Here are a few other options that are general common options for various Linux filesystems. For a complete list, see ntfs-3g(8) § OPTIONS .

umask umask is a built-in shell command which automatically sets file permissions on newly created files. For Arch Linux, the default umask for root and user is 0022. With 0022 new folders have the directory permissions of 755 and new files have permissions of 644. You can read more about umask permissions here. fmask and dmask Like umask but defining file and directory respectively individually. noauto If noauto is set, NTFS entries in /etc/fstab do not get mounted automatically at boot. uid The user id. This allows a specific user to have full access to the partition. Your uid can be found with the id command.

The following option is specific to ntfs-3g only:

windows_names prevents files, directories and extended attributes to be created with a name not allowed by windows.

Allowing user to mount

By default, ntfs-3g requires root rights to mount the filesystem if it is a block device, even with the user option in /etc/fstab . See ntfs-3g-faq for details. The user option in the fstab is still required.

For non-blockfiles like normal images, ntfs-3g on the command-line should work out-of-the-box with normal user privileges as the underlying FUSE calls are redirected to the setuid-root fusermount when direct kernel interaction is unavailable.

Resizing NTFS partition

Most systems that are purchased already have Windows installed on it, and some people would prefer not wipe it off completely when doing an Arch Linux installation. For this reason, among others, it is useful to resize the existing Windows partition to make room for a Linux partition or two. This is often accomplished with a Live CD or bootable USB thumb drive.

For Live CDs the typical procedure is to download an ISO file, burn it to a CD, and then boot from it. InfraRecorder is a free (as in GPL3) CD/DVD burning application for Windows which fits the bill nicely. If you would rather use a bootable USB media instead, see USB flash installation media for methods to create bootable USB stick.

Читайте также:  Uninstall tool для linux

There are a number of bootable CD/USB images avaliable. This list is not exhaustive, but is a good place to start:

  • GParted — Small bootable GNU/Linux distribution for x86 based computers. It enables you to use all the features of the latest versions of the GParted application. Does not include additional packages System Rescue CD may incorporate, and disk encryption schemes may not be supported.

http://gparted.sourceforge.net/ || gparted

  • Parted Magic — Very good complete hard disk management solution. With the Partition Editor you can re-size, copy, and move partitions. You can grow or shrink your C: drive. Create space for new operating systems. Attempt data rescue from lost partitions.

https://partedmagic.com/ ||

  • SystemRescueCD — Good tool to have, and works seamlessly in most cases. Once booted, run GParted and the rest should be fairly obvious.

https://www.sysresccd.org/ || systemrescuecdAUR

Note that the important programs for resizing NTFS partitions include ntfs-3g and a utility like (G)parted or fdisk, provided by the util-linux package. Unless you are an «advanced» user it is advisable to use a tool like GParted to perform any resize operations to minimize the chance of data loss due to user error.

If you already have Arch Linux installed on your system and simply want to resize an existing NTFS partition, you can use the parted and ntfs-3g packages to do it. Optionally, you can use the GParted GUI after installing the GParted package. At the core of the resizing is the ntfsresize(8) command.

Troubleshooting

Compressed files

When mounting an NTFS filesystem for Windows 10, and reading files or directories, you may

  1. see broken symbolic links to ‘unsupported reparse point’, or
  2. see the error message cannot access some_file: Input/output error (in this case you see Could not load plugin /usr/lib64/ntfs-3g/ntfs-plugin-80000017.so: Success in the journal).

The reason for this are NTFS reparse points, and that NTFS-3G does not support some types of reparse points by default. NTFS-3G plugins may be used to provide compatibility with a part of the features defined by the following reparse points

  • System compression
  • Deduplicated files
  • OneDrive files

See this page for further details.

System compression a.k.a. «Compact OS» compresses certain files. There are two possible workarounds for System compression.

You may install the NTFS-3G plugin ntfs-3g-system-compression AUR . Currently only reading is supported by this plugin, but not writing, i.e. creating or updating files is not supported.

Alternatively, disable the System compression feature in Windows 10

Damaged NTFS filesystems

If an NTFS filesystem has errors on it, NTFS-3G will mount it as read-only. To fix an NTFS filesystem, load Windows and run its disk checking program, chkdsk.

Note that ntfsfix can only repair some errors. If it fails, chkdsk will probably succeed.

To fix the NTFS file system, the device must already be unmounted. For example, to fix an NTFS partition residing in /dev/sda2 :

If all went well, the volume will now be writable.

Metadata kept in Windows cache, refused to mount

When dual booting with Windows 8 or 10, trying to mount a partition that is visible to Windows may yield the following error:

The problem is due to a feature introduced in Windows 8 called «fast startup». When fast startup is enabled, part of the metadata of all mounted partitions are restored to the state they were at the previous closing down. As a consequence, changes made on Linux may be lost. This can happen to any NTFS partition when selecting «Shut down» or «Hibernate» under Windows 8 or 10. Leaving Windows by selecting «Restart», however, is apparently safe.

To enable writing to the partitions on other operating systems, be sure fast startup is disabled. This can be achieved by issuing as an administrator the command:

You can check the current settings on Control Panel > Hardware and Sound > Power Options > System Setting > Choose what the power buttons do. The box Turn on fast startup should either be disabled or missing.

Deleting Windows hibernate metadata

As an alternative to above clean shutdown method, there is a way to completely destroy NTFS metadata that was saved after hibernating. This method is only feasible if you are not able or unwilling to boot into Windows and shut it down completely. This is by placing remove_hiberfile option when you are mounting your NTFS file system using ntfs-3g.

Mount failure

If you cannot mount your NTFS partition even when following this guide, try using the UUID instead of device name in /etc/fstab for all NTFS partitions. See fstab#File system UUIDs for an example.

Windows mount failure

Windows will not recognize a NTFS partition that does not have a corresponding partition type. A common pitfall when creating an NTFS partition to work with Windows is forgetting to set the partition type as NTFS. See fdisk or one of the partitioning tools.

Beta features and releases

There is a web page on «advanced features», maintained by Jean-Pierre André, one of the NTFS-3G authors. It provides:

  • Documentation on handling of NTFS features in NTFS-3G, including:
    • Symlinks, junctions, and other reparse points
    • Extended attributes (xattrs) as an interface for ADS streams and special NTFS attributes
    • Security and permission, including POSIX mapping and ACL mapping
  • Plugins for parsing special reparse points.

Information provided in the documentation apply to the Tuxera version (2017.3.23) too. The system-compression and dedupe plugins work with the Tuxera version, but the onedrive plugin requires a tweak of the plugin-loading system only available in advanced releases.

Источник

Ubuntu Documentation

Ubuntu is capable of reading and writing files stored on Windows formatted partitions. These partitions are normally formatted with NTFS, but are sometimes formatted with FAT32. You will also see FAT16 on other devices.

Читайте также:  Приложение карты для windows 10 что это

Ubuntu will show files and folders in NTFS/FAT32 filesystems which are hidden in Windows. Consequently, important hidden system files in the Windows C:\ partition will show up if this is mounted. Since it is all-too-easy to accidentally modify or delete files which are essential for Windows, it is advisable to mount your Windows C:\ partition as seldom as possible, preferably not at all, or read-only by configuring /etc/fstab (see below). If you have data which you want to access regularly from both Windows and Ubuntu, it is better to create a separate data partition for this, formatted NTFS.

Whether you write to your Windows C:\ partition or a shared NTFS data partition, be aware that if you are using Windows 7, and Windows 7 is in a hibernated state when you write to the NTFS partition from Ubuntu, you will lose all your changes. This is because when Windows 7 is hibernated it writes the system state to a file stored on disk and restores from that file when the system is re-awakened, thus restoring the whole fileystem to a state before any changes made from Ubuntu. In Windows 7 you must avoid using hibernation. With Windows 8, the situation is more complex in that, by default, it uses a hybrid hibernation/shutdown when you shut the system down. Any changes made by Ubuntu will be lost when you reboot into Ubuntu.

With both Windows 7 and Windows 8 (when installed to a legacy mbr partition table) there is usually a 100-200MB boot partition labelled «SYSTEM». Do not mount it — you do not need to. Similarly it is highly advisable to leave any recovery partitions unmounted.

Using the File Manager

For those using a desktop version of Ubuntu, or one of its offical derivatives, the easiest and quickest way of mounting NTFS or FAT32 partitions is from the file manager: Nautilus in Ubuntu, Thunar in Xubuntu, Dolphin in Kubuntu and PCManFM in Lubuntu. Simply look in the left pane of the file manager for the partition you wish to mount and click on it — it will be mounted and its contents will show up in the main pane. Partitions show with their labels if labelled, or their size if not.

Unless you require your Windows partition — or a NTFS/FAT32 partition for data shared with Windows — mounted every time you boot up for one of the reasons given below, mounting from the file manager in this way should suffice.

If you are using a Wubi version of Ubuntu and you wish to browse the host partition, you do not need to mount it — it is mounted already in the «host» folder. Click on «File System» in the left pane of the Nautilus file browser and then open the host folder which you will see in the main pane.

File System Differences

For a more in depth analysis, see LinuxFilesystemsExplained, but here are some basics:

  • Windows 7, Vista, XP, 2000, older NT systems, and Windows Server 2003 and 2008 are formatted with NTFS. In rare cases, OEM manufacturers have pre-installed Windows XP and Windows 2000 to FAT32 filesystems.
  • Older versions of Windows such as Windows ME, 98, and 95 are formatted with FAT32.
  • Flash drives, such as a USB thumb drive or a camera’s flash card are typically formatted as FAT16. Some Flash drives are formatted with Microsoft’s proprietary exFAT file system.

In Windows, you can check which filesystem your partition is formatted with by right-clicking the partition in Windows Explorer and selecting Properties. In Ubuntu, run from terminal:

The ntfs-3g driver is used in Linux-based systems to read from and write to NTFS partitions.

NTFS (New Technology File System) is a file system developed by Microsoft and used by Windows computers (Windows 2000 and later). Until 2007, Linux distros relied on the kernel ntfs driver which was read-only. The userspace ntfs-3g driver now allows Linux-based systems to read from and write to NTFS formatted partitions.

The ntfs-3g driver is pre-installed in all recent versions of Ubuntu and healthy NTFS devices should work out of the box without further configuration. In Ubuntu versions 11.10 and later the ntfs-3g package included the functionality previously provided by ntfsprogs. Trying to install ntfsprogs in 11.10 (and possibly in 12.04) will cause the package-manager to ask if you wish to remove ntfs-3g. Users who have installed ntfsprogs and failed to notice the message from the package manager have unintentionally uninstalled ntfs-3g, after which the system falls back to the read-only kernel ntfs driver. Loss of the ntfs-3g driver for similar reasons has also been reported when upgrading from 11.04 to 11.10. If you are experiencing inability to write to a NTFS formatted partition or device, check whether or not the ntfs-3g package is installed.

FAT32

The vfat driver is used in linux to read and write FAT32 and FAT16 partitions.

Configuring /etc/fstab

Preface

If you require one or more of your Windows partitions mounted automatically during bootup, it is necessary to add one line to the file /etc/fstab for each partition that is to be mounted. Some reasons for mounting partitions by means of /etc/fstab, rather than relying on the file manager, include:

  • Convenience.
  • Where more than one user account is in use during a session. Partitions mounted from one user account by means of the file manager are not accessible to the other account(s).
  • Where libraries have been set up in applications such as Banshee or Rhythmbox (for music) or Shotwell (for photos). If those libraries contain files on partitions mounted by means of the file manager, an error will occur in a subsequent session if the partition is not mounted first.

Where more advanced or special mount options are needed. Three working configurations for different needs are given below, but anything more advanced is beyond the scope of this wiki page. The NTFS-3G manual gives a list of mount options suitable for NTFS filesystems.

Automatic Configuration

Although there are a number of GUI applications available from the Ubuntu Software Centre, none of these can be recommended at the time of this writing, unfortunately. They are obsolete and unmaintained and can all cause problems. Two examples are ntfs-config and PySDM. (PySDM is no longer in the repository with effect from 12.10.) If you find a recommendation anywhere for either of these applications, it is likely to be an old one, and should not be followed. At this time it is advisable to configure /etc/fstab manually.

Manual Configuration

First, you need to find the device locations of the partition(s) you wish to mount. Open a terminal and run:

For illustration purposes, an example output from a computer setup with a Vista/Ubuntu dual-boot and shared NTFS data partition is shown here:

The first three partitions, all NTFS, are the ones that concern us here. There are no FAT32 partitions. In this instance, all three NTFS partitions have partition labels, which makes it easier to identify the purpose of each. If your blkid output does not include partition labels, this means that the partitions do not have labels and you will have to determine which partition you wish to mount by another means. Of the three NTFS partitions, we are going to configure /etc/fstab with only the third, the Data partition. Partition /dev/sda1 is the OEM manufacturer’s recovery partition and should be left unmounted, or as described below. Partition /dev/sda2 is the Windows C:\ partition and is best not included in /etc/fstab for the reasons described above, or mounted read-only — see below.

You will now need to create a mountpoint for each NTFS partition that you wish to mount by means of /etc/fstab. In our illustration we are going to add one entry only for /dev/sda3. From a terminal:

In this case we have created a mountpoint with the same name – Data – as the partition label. You may use (almost) any string you wish.

Before editing /etc/fstab directly, it is a good idea to make a backup. From a terminal:

Now open /etc/fstab in a text editor with root privileges. In Ubuntu:

In Xubuntu or Lubuntu:

For a general-purpose read-write mount, add this line to the end of /etc/fstab:

Replace the UUID with the one relevant for your partition as shown in your blkid output. “519CB82E5888AD0F” will not work for you.

Also, substitute your mountpoint for “/media/Data”. In case you have a blank space in the name of the mountpoint you want to use like «New Volume» instead of «Data» located in «/media» use «/media/New\040Volume». The space character is created by using «\040» in the fstab.

You will also need to change the “locale=en_US.utf8” option to one suitable for your location and language if you are not in the USA. You can determine your locale with this terminal command:

Or for a list of all locales available on your system:

Now save your edited /etc/fstab and close the text editor. The partition(s) you have configured will be mounted the next time you reboot, but to mount them now:

Two special cases

Sample /etc/fstab lines are suggested for two special cases.

Option 1 — for mounting read-only access. For example, this would be suitable for mounting your Windows C:\ partition if you need to access it. Modify the line below with your UUID and mountpoint:

Option 2 — to ensure that Ubuntu does not mount the partition and also disables graphical mounting from the file manager. For example, you may wish to ensure that recovery and system partitions are never inadvertently mounted and do not appear in the file manager. In this case you need to create a mountpoint in /mnt, not /media. Modify the line below with your UUID and mountpoint:

Note: with these mount options, the partition does not appear in the Devices list in the left pane of Nautilus (the Ubuntu file manager), but it still appears in Dolphin, the Kubuntu File Manager. Clicking on the partition in Dolphin causes the display of an error message. This solution is less elegant in Dolphin than with Nautilus, but the desired effect is achieved — the partition cannot be mounted.

If you need to revert to the original configuration:

Substitute your mountpoint in the second line.

FAT32 Partition

FAT32 partitions are mostly only found in older systems. If you are creating a partition to be used for data to be shared between Windows and Ubuntu, it is better to choose NTFS. Should you have a FAT32 partition which you need to mount using /etc/fstab, this will work to mount it read-write:

Replace with the UUID that blkid reveals for your partition, and adjust for your mountpoint. These mount options will make all files in the partition executable. If you have other needs, you will need to modify the options, but this is beyond the scope of this wiki page.

Other Resources

Footnote

This page has recently been subject to significant revision. If you have any comments about current content, or suggestions for further additions or edits, please head over to this Ubuntu forums discussion thread so that we can co-ordinate our efforts.

MountingWindowsPartitions (последним исправлял пользователь jeremiah-l-marks 2014-11-16 06:31:46)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

Читайте также:  Windows пропали иконки у файлов
Оцените статью