Bug #1948

Hammer PFS weirdness when encrypting root

Added by t_dfbsd over 3 years ago. Updated almost 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

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

unnamed (2.3 KB) t_dfbsd, 12/31/2010 04:28 PM

unnamed (1.96 KB) t_dfbsd, 12/31/2010 04:56 PM

History

#1 Updated by dillon over 3 years ago

: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.

The issue is that you are cpdup'ing your current root onto the new
/mnt:

:cpdup -o / /mnt

And that is overwriting the PFS softlinks you created in /mnt/pfs.

I've made similar mistakes myself every so often.

-Matt

#2 Updated by t_dfbsd over 3 years ago

Ah, of course! Thanks, Matt.

Tim

On Fri, Dec 31, 2010 at 9:39 AM, Matthew Dillon (via DragonFly issue
tracker) <> wrote:

>
> Matthew Dillon <> added the comment:
>
> :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.
>
> The issue is that you are cpdup'ing your current root onto the new
> /mnt:
>
> :cpdup -o / /mnt
>
> And that is overwriting the PFS softlinks you created in /mnt/pfs.
>
> I've made similar mistakes myself every so often.
>
> -Matt
>
> ----------
> status: unread -> chatting
>
> _____________________________________________________
> DragonFly issue tracker <>
> <http://bugs.dragonflybsd.org/issue1948>
> _____________________________________________________
>

Also available in: Atom PDF