Skip to content

MacOS /nix unmount when reboot. /nix ownership change to root #4640

@OliverKoo

Description

@OliverKoo

Describe the bug

On aws Mac ec2 instance running Catalina 10.15.7 installed nix with recommended approach

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

works great. you can see /nix is mounted

ec2-user@ip-10-249-8-250 ~ % nix --version
nix (Nix) 2.3.10
ec2-user@ip-10-249-8-250 ~ % diskutil apfs list 
    +-> Volume disk2s6 7420B953-17CE-4369-B12E-7910CB17CE7A
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk2s6 (No specific role)
        Name:                      Nix Store (Case-insensitive)
        Mount Point:               /nix
        Capacity Consumed:         329789440 B (329.8 MB)
        FileVault:                 No

and /nix is own by ec2-user

ec2-user@ip-10-249-8-250 ~ % ls -la /nix
total 0
drwxrwxr-x   5 ec2-user  staff   160 Mar 15 17:53 .
drwxr-xr-x  22 root      wheel   704 Feb 10 01:37 ..
drwx------  34 ec2-user  staff  1088 Mar 15 17:53 .fseventsd
drwxr-xr-x  59 ec2-user  staff  1888 Mar 15 17:53 store
drwxr-xr-x   4 ec2-user  staff   128 Mar 15 17:53 var
ec2-user@ip-10-249-8-250 ~ % nix --version
nix (Nix) 2.3.10
---

Problem
however when I reboot the nix vol didn't auto mount (maybe /etc/fstab is no longer used by Catalina?)
and /nix is now own by root

ec2-user@ip-10-249-8-250 ~ % diskutil apfs list
APFS Container (1 found)
|
+-- Container disk2 7867D1D1-A318-4F69-BE7A-2C9DEF37A5BC
    ====================================================
    APFS Container Reference:     disk2
    Size (Capacity Ceiling):      274668150784 B (274.7 GB)
    Capacity In Use By Volumes:   38961782784 B (39.0 GB) (14.2% used)
    Capacity Not Allocated:       235706368000 B (235.7 GB) (85.8% free)
    |
    +-< Physical Store disk1s2 7E102836-D259-4625-A9AB-A33559D758B9
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk1s2
    |   Size:                       274668150784 B (274.7 GB)
    |
    +-> Volume disk2s1 047551A9-1611-4846-90E4-DF0B2D32BDFA
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk2s1 (Data)
    |   Name:                      Macintosh HD - Data (Case-insensitive)
    |   Mount Point:               /System/Volumes/Data
    |   Capacity Consumed:         24701288448 B (24.7 GB)
    |   FileVault:                 No
    |
    +-> Volume disk2s2 60805369-595C-484A-AA04-A6FD1B1C133E
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk2s2 (Preboot)
    |   Name:                      Preboot (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         79278080 B (79.3 MB)
    |   FileVault:                 No
    |
    +-> Volume disk2s3 CA71C970-9205-4BD0-8580-57EC6277A512
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk2s3 (Recovery)
    |   Name:                      Recovery (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         528957440 B (529.0 MB)
    |   FileVault:                 No
    |
    +-> Volume disk2s4 DDC89C2A-7772-45DE-B74E-CD6570BCEB30
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk2s4 (VM)
    |   Name:                      VM (Case-insensitive)
    |   Mount Point:               /private/var/vm
    |   Capacity Consumed:         2147504128 B (2.1 GB)
    |   FileVault:                 No
    |
    +-> Volume disk2s5 72E57EA3-53F3-4AA0-8C1F-375C722C86B4
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk2s5 (System)
    |   Name:                      Macintosh HD (Case-insensitive)
    |   Mount Point:               /
    |   Capacity Consumed:         11034324992 B (11.0 GB)
    |   FileVault:                 No
    |
    +-> Volume disk2s6 7420B953-17CE-4369-B12E-7910CB17CE7A
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk2s6 (No specific role)
        Name:                      Nix Store (Case-insensitive)
        Mount Point:               Not Mounted
        Capacity Consumed:         329789440 B (329.8 MB)
        FileVault:                 No
ec2-user@ip-10-249-8-250 ~ % ls -la /nix
total 0
drwxr-xr-x   2 root  wheel   64 Mar 15 18:08 .
drwxr-xr-x  22 root  wheel  704 Feb 10 01:37 ..
ec2-user@ip-10-249-8-250 ~ % mount -a
mount_apfs: volume could not be mounted: Operation not permitted
mount: / failed with 77
mount_apfs: volume could not be mounted: Operation not permitted
mount: /nix failed with 77

I can get around it by sudo mount_apfs disk2s6 /nix but
I am using these mac ec2 instance for CI purpose and the process would fail

due to /Users/ec2-user/.nix-profile/etc/profile.d/nix.sh: Operation not permitted

Steps To Reproduce

described above

Expected behavior

nix vol mounted when boot and /nix owned by user who executed the install scripted

nix-env --version output

nix (Nix) 2.3.10

Additional context

I am running these on aws ec2 Mac1.metal instances

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions