Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[opentmpfiles-setup] chattr three error messages #2

Open
LW-archlinux opened this issue Mar 12, 2017 · 5 comments
Open

[opentmpfiles-setup] chattr three error messages #2

LW-archlinux opened this issue Mar 12, 2017 · 5 comments

Comments

@LW-archlinux
Copy link

*� Setting up tmpfiles.d entries ...
chattr: Operation not supported while setting flags on /var/log/journal
chattr: No such file or directory while trying to stat /var/log/journal/%m
chattr: Operation not supported while setting flags on /var/log/journal/remote
[ !! ]�
*� ERROR: opentmpfiles-setup failed to start

kernel 4.10.1 , systemd 232, openrc 0.24, opentmpfiles 0.1.3
rc.txt

@vaeth
Copy link
Contributor

vaeth commented Apr 30, 2017

The error is caused by the systemd config file
/var/lib/tmpfiles.d/journal-nocow.conf:

h /var/log/journal - - - - +C
h /var/log/journal/%m - - - - +C
h /var/log/journal/remote - - - - +C

Of course, the nocow attribute cannot be set on many filesystems where it makes not sense (like ext2), and systemd gracefully ignores the corresponding "error" (which is more an informal message).

It is really annoying that opentmpfiles-setup fails to start because of such an informal message, thus preventing all dependent services to start properly, too.

A workaround is to generate a 0-byte file /etc/tmpfiles.d/journal-nocow.conf (BTW: systemd recommends for such "deactivations" to symlink the file to /dev/null: This does not work with opentmpfiles, either...)

Anyway, it would be nicer if opentmpfiles could handle this automatically without requiring such hacks (which have to be remembered to be removed when the underlying file system changes.)

@LW-archlinux
Copy link
Author

The config file with the problem is /usr/lib/tmpfiles.d/journal-nocow.conf .
No need to use a 0-byte file. I've copied the original to /etc/tmpfiles.d/ , then commented out those 3 lines & added a comment why i did.
Vaeth, thank you for this workaround .

I do think tmpfiles.d design is the problem here by allowing settings -that only work under certain conditions- to fail silently.

@williamh
Copy link
Contributor

williamh commented May 2, 2017

Does systemd-tmpfiles ignore errors that are generated by commands in tmpfiles.d files?

@vaeth
Copy link
Contributor

vaeth commented May 2, 2017

Does systemd-tmpfiles ignore errors that are generated by commands in tmpfiles.d files?

It depends from case to case. For 'h' and 'H' the function path_set_attribute() of src/tmpfiles/tmpfiles.c is called (in case of H recursively).

This function returns with an error only if the file does not exist or is of a bad type.
It does not return with an error if the chattr_fd function fails. However, the error message is logged (and indeed it can be found with journalctl here).

then commented out those 3 lines

You commented out the only 3 non-comment lines of that file. So effectively you generated a 0-byte file.

@bill-auger
Copy link

bill-auger commented Jan 4, 2021

i am also having this problem with mariadb

$ cat /usr/lib/tmpfiles.d/mariadb.conf
d /run/mysqld 0755 mysql mysql -
d /var/lib/mysql 0700 mysql mysql -
h /var/lib/mysql - - - - +C

this seems to work for me - is it so terrible?

$ cat chattr-ignore-nocow.patch
diff a/tmpfiles.sh b/tmpfiles.sh
--- a/tmpfiles.sh
+++ b/tmpfiles.sh
@@ -54,6 +54,15 @@ _chattr() {
 		'') return ;;
 		*) attr="+$attr" ;;
 	esac
+
+	# ignore attempts to set unsupported attributes
+	local fs_type
+	case $attr in
+		[+-=]C) fs_type="$(df --output=fstype "$3" | tail --lines=1)"
+		        test "$fstype" == 'btrfs' || return 0
+		;;
+	esac
+
 	local IFS=
 	dryrun_or_real chattr "$1" "$attr" -- "$3"
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants