我正在尝试在 Ubuntu 16.04 启动时挂载目录。我按照本教程中提到的确切步骤进行操作关联。我能够手动挂载和卸载文件夹。
正如教程中提到的,我也对 /etc/fstab 进行了更改,但不幸的是,当我启动系统时自动挂载失败了。
还尝试了手动安装并且两者都运行良好。
sudo mount -a
sudo start nfs-home.mount
/etc/fstab
nth@nthYOGA:~$ cat /etc/fstab
# /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/sda8 during installation
UUID=3384679d-4d31-4617-b9e4-d4ba7f0d4334 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=CC87-B297 /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda9 during installation
UUID=d18f6756-5068-4b1c-99f7-eeff16bf3edf none swap sw 0 0
XX.XX.XX.XX:/var/nfs/general /nfs/general nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
XX.XX.XX.XX:/home /nfs/home nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
以下是日志
nth@nthYOGA:~$ systemctl status nfs-home.mount
● nfs-home.mount - /nfs/home
Loaded: loaded (/etc/fstab; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2018-05-10 20:49:24 CEST; 13min ago
Where: /nfs/home
What: XX.XX.XX.XX:/home
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Process: 1038 ExecMount=/bin/mount XX.XX.XX.XX:/home /nfs/home -t nfs -o noatime,nolock,intr,tcp,actimeo=1800 (code=exited, status=32)
nth@nthYOGA:~$ journalctl -u nfs-home.mount
-- Logs begin at Thu 2018-05-10 20:49:22 CEST, end at Thu 2018-05-10 21:05:01 CEST. --
May 10 20:49:24 nthYOGA systemd[1]: Mounting /nfs/home...
May 10 20:49:24 nthYOGA mount[1038]: mount.nfs: Network is unreachable
May 10 20:49:24 nthYOGA systemd[1]: nfs-home.mount: Mount process exited, code=exited status=32
May 10 20:49:24 nthYOGA systemd[1]: Failed to mount /nfs/home.
May 10 20:49:24 nthYOGA systemd[1]: nfs-home.mount: Unit entered failed state.
systemctl show nfs-home.mount
Where=/nfs/home
What=XX.XX.XX.XX:/home
Options=rw,noatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=1800,acregmax=1800,acdirmin=1800,acdirmax=1800,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.0.2,local_lock=none,addr=XX.XX.XX.XX
Type=nfs4
TimeoutUSec=1min 30s
ControlPID=0
DirectoryMode=0755
SloppyOptions=no
Result=success
ExecMount={ path=/bin/mount ; argv[]=/bin/mount XX.XX.XX.XX:/home /nfs/home -t nfs -o noatime,nolock,intr,tcp,actimeo=1800 ; ignore_errors=no ; start_time=[Thu 2018-05-10 21:15:06 CEST] ; stop_time=[Thu 2018-05-10 21:15:07 CEST] ; pid=2256 ; cod
Slice=system.slice
ControlGroup=/system.slice/nfs-home.mount
MemoryCurrent=18446744073709551615
CPUUsageNSec=18446744073709551615
TasksCurrent=18446744073709551615
Delegate=no
CPUAccounting=no
CPUShares=18446744073709551615
...
...
...
KillSignal=15
SendSIGKILL=yes
SendSIGHUP=no
Id=nfs-home.mount
Names=nfs-home.mount
Requires=-.mount system.slice
Wants=network-online.target
WantedBy=remote-fs.target
Conflicts=umount.target
Before=umount.target remote-fs.target
After=-.mount system.slice systemd-journald.socket network.target remote-fs-pre.target network-online.target
RequiresMountsFor=/nfs
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Description=/nfs/home
LoadState=loaded
ActiveState=active
SubState=mounted
FragmentPath=/run/systemd/generator/nfs-home.mount
SourcePath=/etc/fstab
....
....
答案1
我遇到了同样的问题。通过将 更改auto
为 来x-systemd.automount,noauto
修复此问题/etc/fstab
。
例子:
192.168.178.42:/disk1/data /media/data nfs nouser,rsize=32768,wsize=32768,atime,x-systemd.automount,noauto,rw,dev,noexec,suid 0 0
x-systemd.automount
将为文件系统创建一个自动挂载单元。请参阅systemd.自动挂载(5)了解详情。