我有一个服务器的文件系统,在根shell中本地离线安装,如何将postfix的状态设置为禁用,这样下次启动服务器时postfix就不会自动启动?
答案1
假设您将文件系统的根目录挂载在 中/mnt/serverdisk
,
cd /mnt/serverdisk
rm -v etc/systemd/system/multi-user.target.wants/postfix.service
这应该足够了。
这是 CentOS 8 上的演示,显示删除符号链接不会破坏任何内容:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
[root@localhost ~]#
[root@localhost ~]# systemctl get-default
multi-user.target
[root@localhost ~]#
[root@localhost ~]# runlevel
N 3
[root@localhost ~]# systemctl is-enabled postfix
enabled
[root@localhost ~]# rm -v /etc/systemd/system/multi-user.target.wants/postfix.service
rm: remove symbolic link '/etc/systemd/system/multi-user.target.wants/postfix.service'? y
removed '/etc/systemd/system/multi-user.target.wants/postfix.service'
[root@localhost ~]#
[root@localhost ~]# systemctl is-enabled postfix
disabled
[root@localhost ~]#
[root@localhost ~]# systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@localhost ~]#
[root@localhost ~]# systemctl is-enabled postfix
enabled
[root@localhost ~]#
答案2
chroot 进入安装的新系统:
mkdir /media/tmp/
mount /dev/vg0/vm01.tmp-disk-snapshot /media/tmp/
mount -t proc none /media/tmp/proc
mount --bind /dev /media/tmp/dev
mount -t sysfs sysfs /media/tmp/sys
chroot /media/tmp/ /bin/bash
做好你的工作并退出
systemctl disable postfix
exit