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

stage-2-init: directory contains user files. Symlinking may fail. #56932

Closed
wizzup opened this issue Mar 6, 2019 · 4 comments
Closed

stage-2-init: directory contains user files. Symlinking may fail. #56932

wizzup opened this issue Mar 6, 2019 · 4 comments

Comments

@wizzup
Copy link
Contributor

wizzup commented Mar 6, 2019

Issue description

Recently I've got Symlinking may file warning at stage 2

[wizzup@ ~]$ dmesg | grep etc | grep fail
[    9.828785] stage-2-init: /etc/cups directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[    9.843423] stage-2-init: /etc/fonts directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[    9.904143] stage-2-init: /etc/kbd directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.466034] stage-2-init: /etc/terminfo directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.488041] stage-2-init: /etc/dbus-1 directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.580033] stage-2-init: /etc/zoneinfo directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.715797] stage-2-init: /etc/profiles/per-user/wizzup directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.764449] stage-2-init: /etc/systemd/system directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.768595] stage-2-init: /etc/systemd/system-generators directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.792518] stage-2-init: /etc/systemd/user directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.
[   10.884702] stage-2-init: /etc/udev/rules.d directory contains user files. Symlinking may fail. at /nix/store/amhpx347b7n6m2bq24siw0qq27w3np8n-setup-etc.pl line 114.

I don't remembering making any file at /etc, and my user doesn't even have permission to do

[wizzup@ ~]$ touch /etc/test
touch: cannot touch '/etc/test': Permission denied

There is no noticeably error or anything other than warning at stage-2 boot screen but I have some question.

  1. Any idea how to investigate more?
  2. Should a normal system have empty /etc at stage-1?
  3. Is there any way to get a working shell before stage-2 begin so that I can check ?
  4. If I boot from usb-stick and mound the disk, am I expect to see empty /etc

I failed to find any information about NixOS boot stages in the manual that I can use to lean more about my case, any additional recommendation would be appreciated.

Steps to reproduce

Don't sure if it would reproducible but in my case warning are popup on every boot.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.103, NixOS, 19.09pre170705.1233c8d9e9b (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2
  • channels(root): "nixos-19.09pre170705.1233c8d9e9b"
  • channels(wizzup): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@arianvp
Copy link
Member

arianvp commented Mar 6, 2019

The warning being thrown is caused by the environment.etc module.

The following script https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/setup-etc.pl#L82
is called during stage-2-init to make sure that /etc is populated with configuration files from /nix/store

If there is a potential conflict (because, for example, you manually put a file in /etc/dbus ) it will warn you that you are touching files that might conflict with NixOS.

To find out what's up, I would suggest running ls -al in the warned directories, and see which files are not symlinks to stuff in the /nix/store

@arianvp
Copy link
Member

arianvp commented Mar 6, 2019

If I boot from usb-stick and mound the disk, am I expect to see empty /etc

No. /etc remains populated (For the exact reason it not only contains symlinks to the /nix/store, but also user configuration). The symlinks aren't removed when shutting down. However, during profile activation, (Which happens during boot), setup-etc.pl is called.

To give an overview how boot works, this is the stage-2 script:

https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/stage-2-init.sh

it sets up mounts, and then it calls: $systemConfig/activate, which is the profile activation script.
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/stage-2-init.sh#L131

The activation script is built up by the collection of NixOS modules. For example, the mentioned environment.etc module adds the setup-etc.pl script to the activation script here:
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/etc/etc.nix#L153-L158

causing /etc to be populated with the current profile on boot

@eadwu
Copy link
Member

eadwu commented Mar 6, 2019

This looks like #54980?

@wizzup
Copy link
Contributor Author

wizzup commented Mar 9, 2019

Close for no more warning after update nix-channel (unstable)

$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"19.09pre171786.34aa254f9eb"

@wizzup wizzup closed this as completed Mar 9, 2019
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

3 participants