大网数据广告活动
服务器运维问答

SystemD SysV generator and mounts

· 52CE 我爱测

So systemd-sysv-generator converts old style init.d files into systemd service files. But it might do this before all mounts have been mounted. I have some legacy commercial software that lives in /opt which is a separate mount p…

问题原文

原帖链接 · Slashterix · CC BY-SA 3.0

So systemd-sysv-generator converts old style init.d files into systemd service files. But it might do this before all mounts have been mounted.

I have some legacy commercial software that lives in /opt which is a separate mount point. It creates a symlink from /etc/init.d/their_service to a file in /opt

So when the server boots, systemd-sysv-generator cant yet read the linked file and fails to create a service and thus fails to start the service.

As the legacy software is managed by another team and they have the power to update it themselves, I don't want to start copying the file out of /opt and replacing the symlink. Or worse, try rewriting this into a systemd service myself.

Is there any way to have systemd-sysv-generator fire after opt.mount?

已采纳解答

原帖链接 · Slashterix · CC BY-SA 3.0

Thanks to the hint from iwaseatenbyagrue to read https://www.freedesktop.org/software/systemd/man/systemd.special.html I found this section

initrd-fs.target

systemd-fstab-generator(3) automatically adds dependencies of type Before= to sysroot-usr.mount and all mount points found in /etc/fstab that have x-initrd.mount and not have noauto mount options set.

So my fix was to do the following

  1. Edit /etc/fstab to have the x-initrd.mount option for my /opt mount point

/dev/mapper/rootvg-opt /opt ext4 nodev,x-initrd.mount 0 0

  1. Edit /etc/default/grub to list the extra mount point in GRUB_CMDLINE_LINUX

GRUB_CMDLINE_LINUX="rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rd.lvm.lv=rootvg/usr rd.lvm.lv=rootvg/opt ipv6.disable=1 rhgb quiet"

  1. Rebuild the boot

grub2-mkconfig -o /boot/grub2/grub.conf

dracut -f

These steps combined cause SystemD to correctly mount /opt early in the boot and succeed with systemd-sysv-generator

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。