2

I had set the immutable attribute for a file that shouldn't be changed until it is deleted (The file was a backup image of a virtual machine). As it seems the file also cannot be hard-linked, i.e. it cannot be renamed.

Is that the way it should be? Compared to a file lacking write permission, this behaves quite differently. I couldn't find a manual page giving details.

In case it matters: The filesystem where the problem was seen was OCFS2.

1 Answer 1

3

This is a feature. See man chattr:

A file with the 'i' attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file, most of the file's metadata can not be modified, and the file can not be opened in write mode. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

It is possible to have multiple immutable hard links to a given file: create the links first, then make one of them immutable; they will all become immutable.

1
  • Somehow I overlooked that when browsing the different manual pages. Commented Jan 4, 2022 at 14:49

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.