不能在系统目录-只读文件系统中编辑服务文件

时间:2020-12-31 14:01:00

I want to edit a service file located in /usr/lib/systemd/system. Even if I edit it as root (sudo), it says Can't open file for writing.

我想编辑一个位于/usr/ lib/systemd/system.com的服务文件。即使我把它编辑成根(sudo),它说不能打开文件来写。

I thought it's a permission problem, but when trying to add rights to the file I get: chmod: changing permissions of 'flannel-docker-opts.service': Read-only file system.

我认为这是一个权限问题,但当我试图向文件添加权限时,我得到:chmod:更改'flannel-docker-opts '的权限。服务”:只读文件系统。

Since that isn't media(USB or something), I don't think I should mount it?

既然那不是媒体(USB或别的什么),我不认为我应该安装它?

I'm on coreOS btw.

我在coreOS顺便说一句。

2 个解决方案

#1


2  

This problem was more specific to Container Linux (specifically coreOS).

这个问题更具体到容器Linux(特别是coreOS)。

There are two methods of overriding default container Linux settings:

有两种覆盖默认容器Linux设置的方法:

  1. Copying the unit file from /usr/lib64/systemd/system to /etc/systemd/system and modifying the chosen settings
  2. 将单位文件从/usr/lib64/systemd/system复制到/etc/systemd/system并修改所选的设置
  3. Using systemd drop-in units
  4. 使用systemd dropin单位

I've used the latter.

我使用了后者。

I was configuring a file flannel-docker-opts.service located in the system direcotry. I solved it using a system drop-in. First step was creating a directory flannel-docker-opts.service.d in /etc/systemd/system. I created a configuration file in that directory, with my changes.

我正在配置一个文件flannel-docker-opts。位于系统direcotry中的服务。我用一个系统来解决它。第一步是创建目录flannel-docker-opt - service。d /etc/systemd/system.我在该目录中创建了一个配置文件,并进行了更改。

More info in the official coreOS documentation

更多信息请参阅coreOS官方文档

#2


0  

If a filesystem has been mounted read-only, chmod will not work since it's a write operation too.

如果文件系统已被安装为只读,那么chmod将不会工作,因为它也是一个写操作。

Try remounting it read-write:

试着卸载它读写:

sudo mount -o remount,rw '/usr/lib/systemd/system/yourfile'

#1


2  

This problem was more specific to Container Linux (specifically coreOS).

这个问题更具体到容器Linux(特别是coreOS)。

There are two methods of overriding default container Linux settings:

有两种覆盖默认容器Linux设置的方法:

  1. Copying the unit file from /usr/lib64/systemd/system to /etc/systemd/system and modifying the chosen settings
  2. 将单位文件从/usr/lib64/systemd/system复制到/etc/systemd/system并修改所选的设置
  3. Using systemd drop-in units
  4. 使用systemd dropin单位

I've used the latter.

我使用了后者。

I was configuring a file flannel-docker-opts.service located in the system direcotry. I solved it using a system drop-in. First step was creating a directory flannel-docker-opts.service.d in /etc/systemd/system. I created a configuration file in that directory, with my changes.

我正在配置一个文件flannel-docker-opts。位于系统direcotry中的服务。我用一个系统来解决它。第一步是创建目录flannel-docker-opt - service。d /etc/systemd/system.我在该目录中创建了一个配置文件,并进行了更改。

More info in the official coreOS documentation

更多信息请参阅coreOS官方文档

#2


0  

If a filesystem has been mounted read-only, chmod will not work since it's a write operation too.

如果文件系统已被安装为只读,那么chmod将不会工作,因为它也是一个写操作。

Try remounting it read-write:

试着卸载它读写:

sudo mount -o remount,rw '/usr/lib/systemd/system/yourfile'