Dut*_*rjo 18 automounting fstab file-manager
..不同方法的后果是什么?
我一直在尝试安装 sda2 分区。在 fstab 中挂载,不是在 fstab 中挂载,而是从文件管理器中挂载。
到目前为止,如果我是对的,我了解到通过在 fstab 中挂载,在启动时会自动挂载一个分区。但是这个挂载的分区没有显示在文件管理器的“设备”下,而例如显示了根分区和 cdrom。
当您想将它放在侧边栏中的设备下时,不应在 fstab 中挂载分区,而应在文件管理器中单击它。那是对的吗?
但是,如果两者都想要,该走哪条路呢?启动时自动挂载并显示在文件管理器的侧边栏中?
don*_*sti 18
这被记录在(至少对于gnome-shell
/ nautilus
)gvfs-udisks2-volume-monitor
:
The gvfs-udisks2-volume-monitor process is responsible for the disks,
media, mounts and fstab entries shown in the desktop user interface.
..........................................
A device is either mounted (in which case its directory is known) or
it's not. If the device is not mounted, then its directory is known
only if it's referenced in the /etc/fstab file.
Run Code Online (Sandbox Code Playgroud)
再往下是解释:
If the directory for a device is known and outside /media, $HOME
(typically /home/foo) or /run/media/$USER then the device is not shown
in the user interface. Additionally, if any of component directories
in its directory starts with a dot ("."), the device is not shown
either. This policy may be overriden by use of the options x-gvfs-show
and x-gvfs-hide.
Run Code Online (Sandbox Code Playgroud)
总结:
中列出的分区/etc/fstab
(默认情况下)仅在它们安装在/media
、$HOME
或下时才会显示/run/media/$USER
。如果您希望在系统启动时自动挂载分区并在文件管理器侧栏中列出,最简单的方法是通过/etc/fstab
这三个位置之一挂载它。
如果您希望分区安装在不同的目录下(例如/mnt
)并且仍然显示在侧边栏中,您可以通过添加x-gvfs-show
到您的安装选项来覆盖默认行为fstab
:
UUID=5a1615ca-cffd3124917a /mnt/storage ext4 rw,noatime,discard,x-gvfs-show 0 2
Run Code Online (Sandbox Code Playgroud)
未列出的分区/etc/fstab
由 1 处理udisks2
并将安装在/run/media/$USER/VolumeName
或/media/VolumeName
取决于UDISKS_FILESYSTEM_SHARED
1的值,因此它们将显示Devices
在侧边栏中。但是,它们不会自动安装。用户可以在会话启动时自动挂载它们udisksctl
,例如添加:
udisksctl mount -b /dev/sdb2 -t ext4
Run Code Online (Sandbox Code Playgroud)
到会话启动脚本。
1
man udisks
:
UDISKS_FILESYSTEM_SHARED
If set to 1, the filesystem on the device will be mounted in a shared directory e.g. /media/VolumeName)
instead of a private directory (e.g. /run/media/$USER/VolumeName) when the Filesystem.Mount() method is handled.
Run Code Online (Sandbox Code Playgroud)