UNIX File System (UFS)

J

Jarret W. Buse

Guest
UNIX File System (UFS)

The Unix File System (UFS) is sometimes referred to as the Berkeley Fast File System, FFS or the BSD Fast File System. UFS was developed by the Computer Systems Research Group (CSRG).

NOTE: BSD uses UFS as the default file system.

The initial version of UFS was released in UNIX 4.2 BSD in 1983. The maximum file size is 8 ZB (zettabytes), as well as the maximum volume size. UFS supports long file names of 255 characters.

The 8ZB volume size is possible because of a 64-bit address pointer. The math is 2 to the power of 64 multiplied by 512 bytes (per block) for a total of 8 ZB (or 9,444,732,965,739,290,427,392 bytes). Theoretically, the maximum volume size could be 151,115,727,451,828,646,838,272 bytes (2 to the power of 64 times 8196 – a block size of 8 KB) or 147 ZB.

NOTE: UFS volumes formatted on MAC OSX are limited to 4 GB due to the UFS driver.

For directory searching, the information is stored in a table. Newer UFS file systems support Dirhash. Dirhash makes a hash of the directories to perform faster searches than the normal linear search done with a table. The Dirhash is stored in RAM which is faster than accessing the hash from disk.

Each UFS volume contains the following structure:
  • Boot blocks – made up of a few blocks which are initialized separately from the rest of the file system
  • Super Block – contains necessary information about the file system such as a magic number as well as partition parameters
  • Cylinder groups – a collection of cylinders acting as a unit, or a mini-partition. The cylinder groups are made up of the following:
    • Backup of the superblock
    • Cylinder group header, with information about the cylinder group, similar to the Super Block
    • Number of inodes in cylinder group
    • Number of data blocks in cylinder group
NOTE: Each cylinder group maintains its own file structure. The cylinder group manages data stored within the blocks contained by the cylinder groups.

Cylinder groups are meant to keep associated files within the same group. The function allows the data to be closer together. For example, when an application is installed, the application files should be placed into one cylinder group. When the application is run, then the files should be able to be accessed faster than if the files were in separate cylinder groups. This method also helps reduce fragmentation by not having files spread out across the disk.

Over time, the block size became larger when the hard disks became larger. Block sizes grew from 1KB to as much as 8KB in size. As noted in other File System articles, larger block size causes wasted space when storing small files. Each block contains one file or a portion of one file. If the block size is 8KB, and a file is less than 8KB, the block stores only that file. Whatever space is not used by the file is wasted. To help reduce wasted space, UFS supports Tail-Packing. Tail-Packing is a process of taking the end of the file which do not fill a whole block and combining them together to fill or nearly fill a block. The process does save space. One way to look at it is that if the block size is 8KB, you can imagine that each file saved to disk wastes less than 8KB. It is unlikely that a file will perfectly fill a block and not waste any space. If we assume that every 1,000 files can save at most (just under) 8KB per file (at most). This makes a maximum saving of 8MB and a minimum of 0KB (which is extremely unlikely). Of course, very large hard disks can store a lot more files than a thousand.

In a later implementation of UFS by Sun Microsystems, Journaling was added to UFS.

Another method to reduce fragmentation is to use Block Reallocation. Before a file is written to disk, the blocks are checked to determine if enough contiguous blocks are available. If enough contiguous blocks are not available, then files are moved to make enough blocks available.

UFS also has the ability to create Snapshots.

UFS also uses a variable size block similar to Extents.

In 4.4BSD, the UFS file systems was split into two ‘layers’. These layers are two sections of the file system: UFS1 (upper layer) and UFS2 (lower layer). The upper layers, referred to as UFS, provide the access to the metadata and directory structure. The lower layers, referred to as FFS or LFS, contain the data or files.
 

Attachments

  • slide.jpg
    slide.jpg
    28.9 KB · Views: 95,706
Last edited:

Members online


Top