On April 18, 2020, extended attribute support was added to UFS2 in NetBSD-current, but that unfortunately this change made UFS2 dangerously incompatible with UFS2 from previous NetBSD releases, so it was necessary to remove extended attribute support from the UFS2 format that was recognized by previous releases. UFS2 extended attributes will only be supported in NetBSD by a new UFS2 variant called "UFS2ea". This new variant has a different filesystem magic number than the regular UFS2 filesystem, so make sure you update your boot blocks if your root filesystem is UFS2ea, otherwise you are not going to be able to boot from a UFS2ea filesystem.

If your NetBSD-current system has UFS2 file systems and was built from a source tree from between April 18, 2020 and September 23, 2022, then you should use a special procedure to upgrade to a later NetBSD-current, or to NetBSD 10 or later.

BEFORE YOU BEGIN:

If you want to have the option of preserving any extended attributes in UFS2 file systems (including ACLs), then you must download and compile this utility:

https://ftp.netbsd.org/pub/NetBSD/misc/UFS2ea/ufs2ea-flip.c

cc -o ufs2ea-flip ufs2ea-flip.c

Put the resulting "ufs2ea-flip" executable somewhere in your root file system. Putting it directly in the root directory is fine.

If you do not want to preserve any extended attributes that may have been created in UFS2 file systems then you do not need the ufs2ea-flip utility.

Then follow these steps:

  1. Install your new kernel and userland. In particular, you need the new version of /sbin/fsck_ffs. If your existing -current version is too old then the new fsck_ffs may require a new /lib/libc.so* and possibly other things.

  2. Reboot your system into single-user mode. It is important to do an orderly reboot so that file systems are unmounted cleanly. Do not remount the root file system read/write or mount any other file systems yet.

  3. Run a forced "fsck -p" of each UFS2 file system, eg.

    fsck -fp /dev/rwd0a

    fsck -fp /dev/rwd0e

    ...

  4. If the new fsck says that your UFS2 file systems are all fine, then it is safe to exit single-user mode and let the system continue the normal boot process.

    However, if the new fsck reports this message for any file system: NON-ZERO EXTATTR FIELDS then that file system has had extended attributes set on one or more files, and you must decide whether to preserve or discard these extended attributes.

    Discarding extended attributes will lose this information forever, and each file that has extended attributes removed will also have the permission bits of the file's mode cleared, removing all access to the file (except by root). This is because the extended attributes might have been intended to contain an ACL, so removing all permissions avoids allowing access to the file by a process that should not have had any access.

    Preserving extended attributes avoids the downsides of discarding them, but this also converts the file system to the UFS2ea format, which is completely unrecognized by earlier NetBSD versions. It is possible to convert a UFS2ea file system back to UFS2, but this also requires removing all extended attributes and removing access permissions to affected files.

    To discard extended attributes and keep a UFS2 file system in UFS2 format, run a forced full fsck, eg.

    fsck -fy /dev/rwd0a

    To preserve extended attributes and convert a UFS2 file system to UFS2ea format, run the ufs2ea-flip utility that you built earlier on the character device containing the file system, eg.

    /ufs2ea-flip /dev/rwd0a

    The ufs2ea-flip utility will verify that the given device contains a UFS2 file system and ask for confirmation before converting the file system to UFS2ea format while preserving extended attributes. Running a forced full fsck after using this utility is strongly recommended.

  5. After all UFS2 file systems are processed, if you have converted your root file system to UFS2ea then you should reboot. Otherwise you can exit the single-user shell and allow the system to continue the normal boot process.

After this procedure, your system should be ready for use.