如何在 /etc/fstab 中挂载 NTFS 分区?

Ama*_*nda 104 fstab automount

我有两个要在启动时挂载的分区:

/dev/sda3   /mnt/devel  ext4    defaults    0   2
/dev/sda2   /mnt/excess ntfs    defaults    0   2
Run Code Online (Sandbox Code Playgroud)

ext4分区坐骑罚款(归我,只可写的我),但NTFS坐骑归root有R \ W的所有权限。

如何解决这个问题?

drwxr-xr-x  7 amanda amanda 4096 2012-03-14 19:07 devel
drwxrwxrwx  1 root   root   4096 2012-03-14 22:38 excess
Run Code Online (Sandbox Code Playgroud)

bes*_*man 119

必须使用dmask,fmaskumask选项设置 ntfs 和 vfat 文件系统的权限。dmask控制目录的权限,fmask控制文件的权限,并umask控制两者。由于这些选项设置掩码,它们应该是您想要的权限的补充。例如,所有者的 rwx 和其他人的 rx 是 022 而不是 755。

要设置所有者,请分别对用户和组使用uidgid选项。您可以使用命令找到您的 UID id -u。要查找您的 GID,请使用id -g. 这些值通常都是 1000。

ntfs 的一组常见挂载选项是uid=1000,gid=1000,dmask=027,fmask=137. 这会将您设置为驱动器的所有者,并将权限设置为drwxr-x---

这是我的 /etc/fstab 工作中的两行

UUID=EEA2B69CA2B668AB        /WIN_C     ntfs-3g   defaults,nls=utf8,umask=000,dmask=027,fmask=137,uid=1000,gid=1000,windows_names 0 0 
UUID=65AEC0E830EA0497        /WIN_D     ntfs-3g   rw 0 0
Run Code Online (Sandbox Code Playgroud)

如果您在重新启动后没有出现明显错误并且分区保持只读状态,或者您收到类似于以下内容的错误:

Error mounting /dev/sda6 at /media/WindowsDrive: 
Command-line `mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sda6" "/media/rolindroy/Media Center"' exited with non-zero exit status 14: The disk contains an unclean file system (0, 0). 
Metadata kept in Windows cache, refused to mount. 
Failed to mount '/dev/sda6': Operation not permitted The NTFS partition is in an unsafe state. 
Please resume and shutdown Windows fully (no hibernation or fast restarting), or mount the volume read-only with the 'ro' mount option
Run Code Online (Sandbox Code Playgroud)

这是因为 Windows 8 和 10 提供了一个“快速启动”选项,该选项取决于“非完全”关机。您可以按照“电源选项”下的这些步骤禁用快速启动。

  • 您能否提供一个更完整的示例,显示在`/etc/fstab` 的一行中使用的那些选项 (3认同)
  • @puk,我有 `UUID=3030BD846F74E514 /media/iam/ntfspartition ntfs-3g uid=1000,gid=1000,dmask=022,fmask=133 0 0`,正如我在 http://askubuntu.com 中提供的/a/507326/221448(我还提到了`bind`)。 (3认同)
  • 将文件系统类型设置为“ntfs”还是“ntfs-3g”更好? (3认同)
  • @ScottF`uid=0,gid=0` (2认同)
  • 这个参数对我有用:“defaults,rw,nls=utf8,umask=000,dmask=027,fmask=137,uid=1000,gid=1000,windows_names”。在此之后,还运行“sudo ntfsfix /dev/sdXX”来修复分区。 (2认同)
  • @AaronFranke https://serverfault.com/q/304354/333603 (2认同)
  • 您显示的两个示例行之间有什么区别?如果它们在功能上相似,那么第二个看起来要简单得多 (2认同)

Pan*_*her 39

如果您使用权限选项挂载 ntfs 分区,则 chmod / chown 将起作用

/dev/sda2   /mnt/excess ntfs-3g    permissions,locale=en_US.utf8    0   2
Run Code Online (Sandbox Code Playgroud)

然后你可以

sudo chown your_user:your_user /mnt/excess
Run Code Online (Sandbox Code Playgroud)

更容易然后 uid,dmask,fmask。

  • chown 命令将挂载点的所有者 (/mnt/excess) 更改为所需的用户。根据我的经验(至少在每次重新启动后),每次挂载分区时都必须重复此步骤……所以,做正确的事情,设置 uid/gid/umask ……我一直认为 fmask 和 dmask 是可选 - 就像你想要不同的文件和目录权限一样。 (6认同)

rot*_*ers 10

I had some trouble with this because when I reboot the disk name changes... (sda0 to sdb2)

I fixed the problem by mounting them by UUID in the fstab, you can view the UUID for your harddrives by entering: sudo blkid

Make a back-up of your fstab file:

sudo cp /etc/fstab /etc/fstab.orig
Run Code Online (Sandbox Code Playgroud)

Make sure you tripple check the >>, if you place one > you overwrite your fstab!

sudo blkid >> /etc/fstab
Run Code Online (Sandbox Code Playgroud)

If you still screwed up you can replace your fstab with the original:

sudo cp /etc/fstab.orig /etc/fstab
Run Code Online (Sandbox Code Playgroud)

Next make a folder:

sudo mkdir /media/mydrivename
Run Code Online (Sandbox Code Playgroud)

Configure the fstab:

sudo vim /etc/fstab
Run Code Online (Sandbox Code Playgroud)

Don't forget to comment the output from the blkid with a '#' on the beginning of the lines!

Add this to the fstab file, you can find the UUID in the block on the bottom you inserted with the command above. media/mydrivename is where the partition should be mounted.

UUID=xxxxxxxxxxxxxxxxx   /media/mydrivename ntfs    permissions,locale=en_US.utf8    0   2
Run Code Online (Sandbox Code Playgroud)

This is my fstab file:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=5d4940cf-5cf5-443a-be11-1f7e551962d1 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda1 during installation
UUID=84b7e5e9-08c3-4641-b28b-99e0255e604d none            swap    sw              0       0

# 500 GB Webserver harddisk from lr-serv-01
UUID=BA9A48D39A488E37 /media/hdd1 ntfs permissions,locale=en_US.utf8 0 2

# 2 TB Movie share harddisk from lr-serv-01
UUID=7EB09666B09624A5 /media/hdd2 ntfs permissions,locale-en_US.utf8 0 2

#/dev/sda1: UUID="10EC004DEC003010" TYPE="ntfs" 
#/dev/sda2: LABEL="system" UUID="88A4FE47A4FE3772" TYPE="ntfs" 
#/dev/sda3: LABEL="storage_01" UUID="BA9A48D39A488E37" TYPE="ntfs" 
#/dev/sdb1: LABEL="storage_02" UUID="7EB09666B09624A5" TYPE="ntfs" 
#/dev/sdc1: UUID="84b7e5e9-08c3-4641-b28b-99e0255e604d" TYPE="swap" 
#/dev/sdc2: UUID="5d4940cf-5cf5-443a-be11-1f7e551962d1" TYPE="ext4" 
#/dev/sdd1: LABEL="storage_spotnet" UUID="EC6E8F416E8F0394" TYPE="ntfs" 
#/dev/sdd2: LABEL="storage_backup_pcs" UUID="6C2699D026999BA0" TYPE="ntfs" 
#/dev/sdd5: LABEL="storage_series" UUID="7670ABF770ABBC6D" TYPE="ntfs" 
#/dev/sdd6: LABEL="storage_winmx" UUID="564AB81B4AB7F5B9" TYPE="ntfs" 
Run Code Online (Sandbox Code Playgroud)

Reboot the system by typing:

sudo reboot
Run Code Online (Sandbox Code Playgroud)

To check if the partition is mounted you can type df -k.

Give ownership to yourself:

sudo chown -R USERNAME:USERNAME /media/mydrivename
Run Code Online (Sandbox Code Playgroud)

在 Ubuntu Server 14.04.01 上做了这个

希望这个答案对某人有所帮助;-)

  • 虽然这听起来通常是可靠的建议,但我发现简单地从 `sudo blkid` 的输出中复制 UUID 而不是将整个内容转储到 `/etc/fstab` 并暂时破坏它会更优雅。另一种方法是从 GParted 中分区的属性对话框中获取 UUID。 (3认同)

Gay*_*tti 8

您可以使用ntfs-config GUI 实用程序在 fstab 中挂载 NTFS 分区。并且可以轻松启用/禁用读写功能。

挂载 NTFS Windows 分区 FSTAB

更详细的指南:启动时在 Ubuntu 中挂载 Windows 分区


Jon*_*han 6

我使用以下我发现正确的给我挂载权限(来自双引导系统设置的 NTFS 驱动器):

编辑/etc/fstab

UUID 可以在/dev/disk/by-uuid/(通常映射到/dev/sd*)中找到

替换<your uuid>为您的 UUID

UUID=<your uuid> /mnt/e ntfs auto,users,uid=1000,gid=1000,dmask=027,fmask=137 0 0


dai*_*isy 5

可能不是一个好的解决方案,但您始终可以将用户 ID 映射到您自己的 ID 或组 ID:

这里只是一个例子,我的用户 ID 是 1000

/dev/sda5 /mnt/excess ntfs defaults,uid=1000,rw 0 0

在这种情况下,用户 ided 1000 拥有的所有挂载文件


小智 5

请注意,如果您使用标签挂载 ntfs 驱动器并希望能够更改此驱动器上目录或文件的权限,则以下操作很好(编辑 /etc/fstab 例如 sudo nano /etc/fstab 然后添加) :

LABEL=Portable_HD_2TB      /media/mintbox2/Portable_HD_2TB ntfs    permissions,defaults        0       2
Run Code Online (Sandbox Code Playgroud)

而下面将允许您更改目录或文件的权限:

LABEL=Portable_HD_2TB      /media/mintbox2/Portable_HD_2TB ntfs    defaults        0       2
Run Code Online (Sandbox Code Playgroud)