System Administration Guide: Devices and File Systems

Enhancements to UFS File System Utilities (fsck, mkfs, and newfs)

Solaris 10 6/06: The file system check utility, fsck, has been enhanced to include features from the FreeBSD 4.9 version of the fsck program, as well as other enhancements.

The fsck utility in this Solaris release includes the following improvements:

In addition, the newfs and mkfs commands have been updated to include new options for displaying a file system's superblock information in text or dumping the superblock information in binary format.


newfs [ -S or -B ] /dev/rdsk/...
-S

Displays the file system's superblock in text

-B

Dumps the file system's superblock in binary


mkfs [ -o calcsb or -o calcbinsb ] /dev/rdsk/... size
-o calcsb

Displays the file system's superblock in text

-o calcbinsb

Dumps the file system's superblock in binary

The fsck utility uses this superblock information to search for backup superblocks.

The following sections describe specific fsck enhancements and their corresponding error messages. For step-by-step instructions on using the fsck utility to repair a damaged superblock, see How to Restore a Bad Superblock (Solaris 10 6/06 Release).

Automatic Search for Backup Superblocks

The following fsck error message examples illustrate the automatic backup superblock discovery feature.


Caution – Caution –

If a file system has a damaged superblock and it was created with newfs or mkfs customized parameters, such as ntrack or nsect, using fsck's automatically discovered superblock for the repair process could damage your file system.

In the case of a file system that was created with customized parameters and it has a bad superblock, fsck provides the prompt to cancel the fsck session:


CANCEL FILESYSTEM CHECK?

The following example illustrates what would happen if you specified fsck's -y option in a damaged superblock scenario. You are automatically dropped out of the fsck session. A message is displayed to rerun it with the alternate superblock.


# fsck -y /dev/dsk/c1t2d0s0
# 
** /dev/rdsk/c1t2d0s0
BAD SUPERBLOCK AT BLOCK 16: BLOCK SIZE LARGER THAN MAXIMUM SUPPORTED

LOOK FOR ALTERNATE SUPERBLOCKS WITH MKFS?  yes


LOOK FOR ALTERNATE SUPERBLOCKS WITH NEWFS?  yes

SEARCH FOR ALTERNATE SUPERBLOCKS FAILED.

USE GENERIC SUPERBLOCK FROM MKFS?  yes

CALCULATED GENERIC SUPERBLOCK WITH MKFS
If filesystem was created with manually-specified geometry, using
auto-discovered superblock may result in irrecoverable damage to
filesystem and user data.

CANCEL FILESYSTEM CHECK?  yes

Please verify that the indicated block contains a proper
superblock for the filesystem (see fsdb(1M)).

FSCK was running in YES mode.  If you wish to run in that mode using
the alternate superblock, run `fsck -y -o b=453920 /dev/rdsk/c1t2d0s0'.

The following fsck error message scenario illustrates the new prompts for the backup superblock, but the fsck run is not canceled, in this example. Canceling the fsck session would be an appropriate response if this file system was created with customized parameters or if there is some other concern about running fsck on this file system.

The various superblock error conditions are provided in italics as follows:


# fsck /dev/rdsk/c0t1d0s0

** /dev/rdsk/c0t1d0s0

BAD SUPERBLOCK AT BLOCK 16: BLOCK SIZE LARGER THAN MAXIMUM SUPPORTED
BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DATA BLOCKS OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: INODES PER GROUP OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: MAGIC NUMBER WRONG
BAD SUPERBLOCK AT BLOCK 16: BAD VALUES IN SUPER BLOCK
BAD SUPERBLOCK AT BLOCK 16: NCG OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: CPG OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: NCYL IS INCONSISTENT WITH NCG*CPG
BAD SUPERBLOCK AT BLOCK 16: SIZE OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DIRECTORIES OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: ROTATIONAL POSITION TABLE SIZE OUT OF RANGE
BAD SUPERBLOCK AT BLOCK 16: SIZE OF CYLINDER GROUP SUMMARY AREA WRONG
BAD SUPERBLOCK AT BLOCK 16: INOPB NONSENSICAL RELATIVE TO BSIZE

LOOK FOR ALTERNATE SUPERBLOCKS WITH MKFS? yes

FOUND ALTERNATE SUPERBLOCK 32 WITH MKFS

USE ALTERNATE SUPERBLOCK? yes

FOUND ALTERNATE SUPERBLOCK AT 32 USING MKFS
If filesystem was created with manually-specified geometry, using
auto-discovered superblock may result in irrecoverable damage to
filesystem and user data.

CANCEL FILESYSTEM CHECK? no

** Last Mounted on 
** Phase 1 - Check Blocks and Sizes
** Phase 2a - Check Duplicated Names
** Phase 2b - Check Pathnames
** Phase 3a - Check Connectivity
** Phase 3b - Verify Shadows/ACLs
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cylinder Groups

SALVAGE? yes


UPDATE STANDARD SUPERBLOCK? yes

82 files, 3649 used, 244894 free (6 frags, 30611 blocks, 0.0% 
fragmentation)

***** FILE SYSTEM WAS MODIFIED *****

fsck Reports When it Needs to be Rerun

Better reporting by fsck about when it needs to be rerun should alleviate the time and necessity of running it multiple times, which can be particularly time consuming on large file systems.

The following new messages prompt you to rerun the fsck utility at the end of an error scenario:


***** PLEASE RERUN FSCK *****

Or:


Please rerun fsck(1M) to correct this.

These new prompts resolve the previous difficulty in determining whether fsck should be rerun or not.

Unless you are prompted to rerun fsck as in the above messages, there is no need to run fsck, even after you see the following message:


***** FILE SYSTEM WAS MODIFIED *****

However, it doesn't harm the file system to rerun fsck after this message. This message is just informational about fsck's corrective actions.

New fsck Messages Regarding Extended Attributes

New fsck messages are included that report on and repair files with extended attributes. For example:


BAD ATTRIBUTE REFERENCE TO I=1 FROM I=96

Attribute directory I=97 not attached to file I=96
  I=96  OWNER=root MODE=40755
SIZE=512 MTIME=Jul 12 10:55:10 2010
DIR= <xattr> 

FIX?  yes

ZERO LENGTH ATTR DIR I=12  OWNER=root MODE=160755
SIZE=0 MTIME=Jul 12 10:56:10 2010
CLEAR?  yes

File should BE marked as extended attribute
  I=22  OWNER=root MODE=100644
SIZE=0 MTIME=Jul 12 10:57:10 2010
FILE=  <xattr>

FIX?  yes

UNREF ATTR DIR  I=106  OWNER=root MODE=160755
SIZE=512 MTIME=Jul 12 10:58:10 2010
RECONNECT?  yes

File I=107 should NOT be marked as extended attribute
  I=107  OWNER=root MODE=100644
SIZE=0 MTIME=Jul 12 10:59:10 2010
FILE=?/attfsdir-7-att

FIX?  yes
DIR I=106 CONNECTED.

Better Handling of Duplicate Blocks or Fragments

The fsck error messages now reports information about blocks, fragments, or a LFNs, which are the logical fragment numbers from the start of the file. For example, you might see output similar to the following:


** Phase 1 - Check Blocks and Sizes
FRAGMENT 784 DUP I=38 LFN 0
FRAGMENT 785 DUP I=38 LFN 1
FRAGMENT 786 DUP I=38 LFN 2
.
.
.

fsck processes objects as fragments, but in previous Solaris releases, only reported object information as blocks. It now correctly reports as fragments.

If fsck finds error conditions that involve duplicate blocks or fragments, fsck offers to display the uncleared files at end of the fsck output. For example, you might see output similar to the following:


LIST REMAINING DUPS?  yes

Some blocks that were found to be in multiple files are still
assigned to file(s).
Fragments sorted by inode and logical offsets:
Inode 38:
  Logical Offset  0x00000000               Physical Fragment  784
  Logical Offset  0x00000800               Physical Fragment  786
  Logical Offset  0x00001000               Physical Fragment  788
  Logical Offset  0x00001800               Physical Fragment  790

Then, you can use the find -i inode-number command to identify the name of inode 38, in this example.