即使没有自动挂载,Systemd 也会不断尝试挂载不存在的 fstab 定义的磁盘

即使没有自动挂载,Systemd 也会不断尝试挂载不存在的 fstab 定义的磁盘

我有 2 个通常与 Raspberry Pi 一起使用的驱动器,但我通常只插入一个,尽管有时我可能需要使用另一个,它们有 500 GB 和 4 TB,我创建了挂载点并添加了这些到 /etc/fstab 的行:

UUID=0e399206-35fc-4ef2-bc90-925db7c34270 /mnt/4TB ext4 defaults,nofail,x-systemd.device-timeout=4 0 0
UUID=575A-EC15  /mnt/500GB exfat defaults,nofail,x-systemd.device-timeout=4,uid=1000,gid=1000,umask=003 0 0

上次我启动它时,已连接并在启动时安装了 500 GB 磁盘,并且由于nofail和,系统在没有 4 TB 磁盘的情况下正常启动x-systemd.device-timeout

然而,今天我不得不将其插入,并惊讶地发现它根据 fstab 自动安装。即使我没有设置任何自动安装,我也不介意这种行为,但在检查日志后我发现显然,systemd 一直在启动后以可变的时间间隔尝试挂载磁盘,直到它实际上可用,这绝对不是我想要的。

期刊中关于此事的最后几行:

    ago 01 20:58:55 Gawain systemd[1]: mnt-4TB.mount: Job mnt-4TB.mount/start failed with result 'dependency'.
-- Subject: Unit mnt-4TB.mount has failed
-- Unit mnt-4TB.mount has failed.
ago 02 00:00:05 Gawain systemd[1]: mnt-4TB.mount: Job mnt-4TB.mount/start failed with result 'dependency'.
-- Subject: Unit mnt-4TB.mount has failed
-- Unit mnt-4TB.mount has failed.
ago 02 00:20:03 Gawain systemd[1]: mnt-4TB.mount: Job mnt-4TB.mount/start failed with result 'dependency'.
-- Subject: Unit mnt-4TB.mount has failed
-- Unit mnt-4TB.mount has failed.
ago 02 11:27:35 Gawain systemd[1]: mnt-4TB.mount: Job mnt-4TB.mount/start failed with result 'dependency'.
-- Subject: Unit mnt-4TB.mount has begun start-up
-- Unit mnt-4TB.mount has begun starting up.
-- Subject: Unit mnt-4TB.mount has finished start-up
-- Unit mnt-4TB.mount has finished starting up.

并来自 dmesg:

[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] 7814037167 512-byte logical blocks: (4.00 TB/3.64 TiB)
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] 4096-byte physical blocks
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Write Protect is off
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Mode Sense: 47 00 00 08
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
[Wed Aug  2 14:01:52 2017]  sdb: sdb1 sdb2
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
[Wed Aug  2 14:01:52 2017] sd 1:0:0:0: [sdb] Attached SCSI disk
[Wed Aug  2 14:02:24 2017] EXT4-fs (sdb2): mounted filesystem with ordered data mode. Opts: (null)

答案1

假定使用默认选项auto,这会创建local-fs.target某些东西可能需要的依赖关系。您可以覆盖noauto,然后尝试添加x-systemd.automount以在引用安装点时安装它。

相关内容