Little UFS2 FAQ (2003/04/25, v15.a)

Derived from contributions to freebsd-current@freebsd.org

Jeroen C. van Gelderen

jeroen@vangelderen.org

$FreeBSD$


1 Introduction

This Mini-FAQ contains tips and information regarding the newly ported UFS2 filesystem. This is intended to be a rapidly evolving document. The latest version of this document is always available from the UFS2 Mini-FAQ.

Suggestions and contributions should be sent to .

Contributors include:

      
            Alex Wilkinson <Alex.Wilkinson@dsto.defence.gov.au>
            Alexander Pohoyda <alexander.pohoyda@gmx.net>
            Anthony CARTER <a.carter@cordis.lu>
            Bernd Walter <ticso@cicely9.cicely.de>
            Bruce Evans <bde@zeta.org.au>
            Daniel C. Sobral <dcs@tcoip.com.br>
            David Schultz <das@FreeBSD.ORG>
            Frank van der Linden <fvdl@wasabisystems.com>
            Lucky Green <shamrock@cypherpunks.to>
            Manfred Antar <null@pozo.com>
            Marcin Dalecki <mdcki@gmx.net>
            Narvi <narvi@haldjas.folklore.ee>
            Peter Schultz <peter@jocose.org>
            Poul-Henning Kamp <phk@phk.freebsd.dk>
            Robert Watson <rwatson@freebsd.org>
            Takahashi Yoshihiro <nyan@jp.FreeBSD.org>
            Terry Lambert <tlambert2@mindspring.com>
            The Anarcat <anarcat@anarcat.ath.cx>
            Tomi Vainio <Tomi.Vainio@Sun.COM>
        
     
1.1. Which OSes support UFS2?
1.2. Is this FAQ (and UFS2) applicable to FreeBSD 4-STABLE?
1.3. What is UFS1?
1.4. What is UFS2?
1.5. What is the difference between UFS and FFS?
1.6. What platforms currently run UFS2?
1.7. What is the rationale for UFS2?
1.8. Who is responsible for UFS2?
1.9. Why did you not add feature while you were at it?
1.10. Does UFS2 offer any performance improvement over UFS1?
1.11. What is the UFS2 status on FreeBSD?
1.12. What is the UFS2 status on NetBSD?
1.13. On which platforms can UFS2 be used for the root filesystem?
1.14. Is there a UFS1 to UFS2 conversion tool?
1.15. Can a UFS1 dump be restored to a UFS2 filesystem?
1.16. Does UFS2 dynamically allocate inodes?
1.17. Does Grub work with UFS2?
1.18. My /boot/loader reports "Invalid format"?

1.1. Which OSes support UFS2?

Currently, FreeBSD 5-CURRENT and NetBSD. (Others?)

1.2. Is this FAQ (and UFS2) applicable to FreeBSD 4-STABLE?

Nope. MFC is not planned for UFS2.

1.3. What is UFS1?

The long-time BSD(?) native filesystem.

1.4. What is UFS2?

UFS2 -introduced in FreeBSD 5-CURRENT- is an extension to the well-known UFS. It adds 64 bit block pointers (breaking the 1T barrier), support for extended file storage, and a few other things.

Short summary of changes:

  • 64-bit pointers up the wazoo (implies that inodes have doubled in size, and now are 256 bytes)

  • Layout and functional changes to help support variable-size blocks (extent-like allocation)

  • Extension of various flag fields

  • Addition of per-inode extended attribute extent

  • Lazy inode initialization (watch newfs(8) fly)



Apart from these modifications all UFS1 code is being used in UFS2 unchanged.

1.5. What is the difference between UFS and FFS?

UFS (and UFS2) define on-disk data layout. FFS sits on top of UFS (1 or 2) and provides directory structure information, and a variety of disk access optimizations. FFS is described in A Fast File System for Unix. This FAQ is about a revision of UFS named UFS2.

1.6. What platforms currently run UFS2?

Currently, FreeBSD 5-CURRENT and NetBSD. (Others?)

1.7. What is the rationale for UFS2?

The motivating factor in the layout change was the need for better Extended Attribute (EA) support, and while the developers were at it they figured they would do a bunch of other useful things too. UFS2 uses the same basic technologies as modern UFS1 (inodes, linear directory layout, soft updates, snapshotting, background file system checking, etc) so it was a relatively low-risk change.

1.8. Who is responsible for UFS2?

UFS2 was developed by Kirk McKusick and Poul-Henning Kamp, but is based in large part on the existing UFS1 file system, which had a host of contributors. UFS2 development was sponsored by DARPA and Network Associates Laboratories, and motivated by the requirements of the TrustedBSD Project. UFS2 was ported to NetBSD by Frank van der Linden, sponsored by Wasabi Systems.

1.9. Why did you not add feature while you were at it?

It would most likely require significant changes whereas the developers wanted to restrict themselves to low-risk modifications only. See previous question.

1.10. Does UFS2 offer any performance improvement over UFS1?

UFS2 has the potential to be faster for really large files by using jumbo blocks, but the code to do that has yet to be written. Additionally, because inodes are lazily initialized in UFS2, newfs(8) runs much faster. Other than that, UFS2 performance should not significantly differ from UFS1.

1.11. What is the UFS2 status on FreeBSD?

As of FreeBSD-CURRENT 2003/04/20, newfs(8) and sysinstall(8) will create UFS2 file systems by default. Users wanting to create UFS1 file systems for whatever reason (interoperability with earlier versions, etc.) should be sure to employ the -O1 flag to newfs(8), or hit 1 in the label editor in sysinstall(8) to select UFS1.

Note: PC98 machines are exempt and still default to UFS1. See "On which platforms can UFS2 be used for the root filesystem?"

1.12. What is the UFS2 status on NetBSD?

As of 2003/04/02 UFS2 is not (yet) the default type for FFS filesystems. newfs(8) will create a normal FFS filesystem by default. If you want a UFS2 fileystem, specify -O 2 as an option.

No additional kernel options are needed for UFS2 support; it's contained within the FFS code.

Please note that older fsck(8) binaries will complain a bit about UFS2 filesystems, because of some superblock changes. This is harmless. However, if you have 1.6 fsck(8) binaries, they will signal a fatal superblock mismatch with the first alternate, because they compare too many fields (even ones that aren't useful). This is annoying, and pepole should upgrade their fsck_ffs(8) binaries before using UFS2. fsck_ffs(8) 1.6.1 will be fully UFS2 compatible.

1.13. On which platforms can UFS2 be used for the root filesystem?

The answer to this is defined by /boot/loader. FreeBSD Alpha, IA64, and SPARC have no problems.

On FreeBSD i386, the answer is yes, modulo the restriction that the root filesystem cannot be larger than 1.5TB. David Schultz, et al., have proposed a patch to remove this limitation. FreeBSD PC98 does not support UFS2 root partitions and it is unknown if work is underway to address this.

NetBSD support is unknown to the author of this document as of this writing.

1.14. Is there a UFS1 to UFS2 conversion tool?

No, but see next question.

1.15. Can a UFS1 dump be restored to a UFS2 filesystem?

The following sequence has been reported to work. Substitute the correct device name on your system.

newfs -U -O 2 /dev/da1s1a
mount /dev/da1s1a /mnt
cd /mnt
dump 0buf 126 - / | restore xbf 126 -
           
Other suggestions for a dump - restore pipeline include:
dump 0abf 64 - / | restore rbf 64 -
           
Use of the dump -C option (-C 32) has also been suggested.

Check the freebsd-current email archives (April 25, 2003 and following) for more discussion. Refer to dump(8) and restore(8) for additional details.

1.16. Does UFS2 dynamically allocate inodes?

No it does not. Inodes are preallocated, but UFS2 lazily initializes them. This mainly means that newfs(8) runs much faster.

1.17. Does Grub work with UFS2?

No. Not yet(?).

1.18. My /boot/loader reports "Invalid format"?

UNRESOLVED

You need a loader and bootblocks that support UFS2. Try using disklabel -B

 

You need a new boot block. What I'd recommend is booting an install floppy or cd, going to custom installation, checking the partitioning (ensuring everything is correct), writing, and then selecting the boot loader. I *think* this should work. What I *don't* recommend is getting a fixit disk and running boot0cfg. Last time I did that I spent three days recovering my partitions.

 
--From Daniel Sobral  

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.