如何使用 /etc/fstab 自动挂载 Windows 分区

jst*_*err 15 windows fstab ntfs

您好,我必须在文件“/etc/fstab”中写入什么才能在启动时自动安装我的 Windows 分区(/dev/sda3)?

我收到此错误消息(单击 nautilus 中分区的书签):

    Error mounting: mount exited with exit code 1: helper failed with:
  Unprivileged user can not mount NTFS block devices using the external FUSE
library. Either mount the volume as root, or rebuild NTFS-3G with integrated
FUSE support and make it setuid root. Please see more information at
http://ntfs-3g.org/support.html#unprivileged
Run Code Online (Sandbox Code Playgroud)

我的 fstab 看起来像这样:

> # /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' 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>
proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/sdb6       /               ext4    errors=remount-ro 0       1
/dev/sda3   /media/Jonas    ntfs    rw,auto,users,nls=utf8,umask=007,gid=46  0  0

# swap was on /dev/sdb7 during installation
UUID=9dcdfad2-4e66-416e-bf68-142afe23fa0b none            swap    sw              0       0
Run Code Online (Sandbox Code Playgroud)

我创建了文件夹/media/Jonas,分区是/dev/sda3。我做错了什么?

解决方法:重启后,运行良好。奇怪的。

小智 15

假设您确定: - 您创建的目录是 /media/Jonas(大写 J) - 您的 ntfs 分区是 /dev/sda3(您可以通过发出 找到sudo blkid

我的 fstab 使用更简单的形式:

/dev/sda3   /media/windows  ntfs    defaults    0   0
Run Code Online (Sandbox Code Playgroud)

您可以将“rw,auto, ....”更改为“defaults”


小智 6

我会为这个主题添加更多信息。

如果没有安装,我建议安装ntfs-3g以允许r/wntfs 分区。

apt-get install ntfs-3g
Run Code Online (Sandbox Code Playgroud)

此外,要使安装“与设备无关”,请使用从blkid实用程序收到的 UUID,而不是引用物理设备。

root:~ blkid
...
/dev/sda1: SEC_TYPE="msdos" LABEL="boot" UUID="140A-14B7" TYPE="vfat" PARTUUID="0009bf4f-01"
/dev/sda2: UUID="f24a4949-f4b2-4cad-a780-a138695079ec" TYPE="ext4" PARTUUID="0009bf4f-02"
/dev/sdb1: LABEL="Western Digital" UUID="1C0EBC7A0EBC4F10" TYPE="ntfs" PARTUUID="0002f5f9-01"
...
Run Code Online (Sandbox Code Playgroud)

然后,像往常一样,创建一个安装点,例如\wd并编辑/etc/fstab插入以下行:

..
UUID=1C0EBC7A0EBC4F10  /wd  ntfs-3g  defaults  0 0
..
Run Code Online (Sandbox Code Playgroud)

您可以尝试在不重启的情况下挂载新设备mount -a

为避免数据损坏,如果您需要移除设备,请确保您umountumount /wd在本示例中)。