Union filesystem broken in Sierra, High Sierra
Hello world, I am unable to get union filesystem mounts working as expected in both Sierra and High Sierra (with latest updates). Specifically, files on the underlying filesystem are not visible to standard macOS libraries/utilities, though they are visible when using third-party (GNU) utilities. The problem is identical in Sierra and High Sierra, HFS+ and APFS, even in a macOS installer thumb drive (configured by Apple, not me, so I have a higher expectation that they would get it right). I have tried every permutation I can think of, without success. Below is an example. If anyone is able to get the union filesystem to work as expected, I would greatly appreciate the help. Regards, David
$ pwd
/Users/Shared/test
# Create some dummy files on the SSD
$ touch file_on_ssd
$ echo test > test.txt
$ ls -l
total 8
-rw-r--r-- 1 david wheel 0 Feb 22 12:36 file_on_ssd
-rw-r--r-- 1 david wheel 5 Feb 22 12:36 test.txt
$ cat test.txt
test
# Make a ramdisk
$ hdiutil attach -nomount ram://1048576
/dev/disk2
$ newfs_hfs -v ramdisk1 /dev/disk2
Initialized /dev/rdisk2 as a 512 MB case-insensitive HFS Plus volume
$ mkdir tmp_mnt
# Mount the ramdisk somewhere temporary so we can put dummy files on it
$ mount -t hfs /dev/disk2 tmp_mnt
$ touch tmp_mnt/ramdisk1
$ echo ramdisk1 > tmp_mnt/test.txt
$ ls -l tmp_mnt
total 8
-rw-r--r-- 1 david wheel 0 Feb 22 12:38 ramdisk1
-rw-r--r-- 1 david wheel 9 Feb 22 12:38 test.txt
# Unmount the ramdisk from its temporary location and mount it with the union option at our current location
$ umount tmp_mnt
$ mount -o union -t hfs /dev/disk2 .
# Show that the ramdisk is mounted with the union option
$ mount
/dev/disk1 on / (hfs, local, journaled)
/dev/disk2 on /Users/Shared/test (hfs, local, nodev, nosuid, union, mounted by david)
# macOS ls does not show the file "file_on_ssd" or directory "tmp_mnt" on the underlying filesystem as it should
$ ls -l
total 8
-rw-r--r-- 1 david wheel 0 Feb 22 12:38 ramdisk1
-rw-r--r-- 1 david wheel 9 Feb 22 12:38 test.txt
# But if you force macOS ls to look for the directory in the underlying filesystem, it finds it
$ ls -ld tmp_mnt
drwxr-xr-x 2 david wheel 68 Feb 22 12:37 tmp_mnt
# GNU ls does show the file "file_on_ssd" and directory "tmp_mnt" on the underlying filesystem
$ gls -l
total 4
-rw-r--r-- 1 david wheel 0 Feb 22 12:41 file_on_ssd
-rw-r--r-- 1 david wheel 0 Feb 22 12:38 ramdisk1
-rw-r--r-- 1 david wheel 9 Feb 22 12:38 test.txt
drwxr-xr-x 2 david wheel 68 Feb 22 12:37 tmp_mnt
# and has the correct contents of the file "test.txt" from the ramdisk filesystem
$ cat test.txt
ramdisk1
$
Mac Pro, macOS Sierra (10.12.6)