I ran into a weird issue while building an encrypted root filesystem. I used the script below to build the encrypted root. Right after this runs, "ls /mnt/usr" and "ls /mnt/var" show the expected files and directories. However, if I unmount root and remount it, I find that the contents of /usr and /var have swapped. I can easily fix it by renaming /pfs/usr to /pfs/var and vice versa. The script works fine on a non-encrypted root, so I'm wondering if it is somehow related to the mapper. I'm running 2.9.1.176.
kldload dm cryptsetup -y luksFormat /dev/da1s1d cryptsetup luksOpen /dev/da1s1d root || exit 1 newfs_hammer -L ROOT /dev/mapper/root mount_hammer /dev/mapper/root /mnt mkdir /mnt/boot mount /dev/da0s1a /mnt/boot mkdir /mnt/pfs hammer pfs-master /mnt/pfs/usr hammer pfs-master /mnt/pfs/usr.obj hammer pfs-master /mnt/pfs/var hammer pfs-master /mnt/pfs/var.crash hammer pfs-master /mnt/pfs/var.tmp hammer pfs-master /mnt/pfs/tmp hammer pfs-master /mnt/pfs/home mkdir /mnt/usr mkdir /mnt/var mkdir /mnt/tmp mkdir /mnt/home mount_null /mnt/pfs/usr /mnt/usr mount_null /mnt/pfs/var /mnt/var mount_null /mnt/pfs/tmp /mnt/tmp mount_null /mnt/pfs/home /mnt/home mkdir /mnt/usr/obj mkdir /mnt/var/tmp mkdir /mnt/var/crash mount_null /mnt/pfs/var.tmp /mnt/var/tmp mount_null /mnt/pfs/var.crash /mnt/var/crash mount_null /mnt/pfs/usr.obj /mnt/usr/obj chmod 1777 /mnt/tmp chmod 1777 /mnt/var/tmp cpdup -o / /mnt cpdup -o /boot /mnt/boot cpdup -o /usr /mnt/usr cpdup -o /var /mnt/var cpdup -i0 /etc /mnt/etc chflags -R nohistory /mnt/tmp chflags -R nohistory /mnt/var/tmp chflags -R nohistory /mnt/var/crash chflags -R nohistory /mnt/usr/obj
