fsck without proper file-system descriptor can cause corruption

book

Article ID: 100021122

calendar_today

Updated On:

Description

Error Message

UX:vxfs mount: ERROR: V-3-20012: not a valid vxfs file system
UX:vxfs mount: ERROR: V-3-24996: Unable to get disk layout version

Resolution

If using fsck and without the proper descriptor, (-F vxfs), you can overwrite the vxfs superblock with a ufs superblock.
 
Here is a vxfs file-system I have created and mounted:
 
bash-2.05# vxprint -g testingdg -htq testvol
v  testvol      -            ENABLED  ACTIVE   2097152  SELECT    -        fsgen
pl testvol-01   testvol      ENABLED  ACTIVE   2097152  CONCAT    -        RW
sd test01-01    testvol-01   test01   0        2097152  0         c2t12d0  ENA
 
bash-2.05# df -k /testing
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/vx/dsk/testingdg/testvol
                    1048576  224075  773993    23%    /testing
 
bash-2.05# ls -l /testing
total 410290
drwxr-xr-x   2 root     other         96 May 29 12:03 acct
-rw-r--r--   1 root     other       1423 May 29 12:03 aliases
drwxr-xr-x   2 root     other       1024 May 29 12:03 apache
-rw-r--r--   1 root     other         43 May 29 12:03 auto_direct
-rw-r--r--   1 root     other         50 May 29 12:03 auto_home
-rw-r--r--   1 root     other        135 May 29 12:03 auto_master
-r-xr-xr-x   1 root     other     236392 May 29 12:03 autopush
-rw------T   1 root     other    209715200 May 29 12:19 bobby.out
-r-xr-xr-x   1 root     other      20996 May 29 12:03 cfgadm
-r-xr-xr-x   1 root     other       4800 May 29 12:03 chroot
-r-xr-xr-x   1 root     other      15776 May 29 12:03 clri
-rw-r--r--   1 root     other        314 May 29 12:03 coreadm.conf
-r-xr-xr-x   1 root     other      57284 May 29 12:03 cron
drwxr-xr-x   2 root     other       1024 May 29 12:03 cron.d
drwxr-xr-x   2 root     root          96 May 29 12:02 lost+found
 
Unmount file-system and perform fsck without using descriptor:
 
bash-2.05# umount /testing
 
bash-2.05# fsck /dev/vx/rdsk/testingdg/testvol
** /dev/vx/rdsk/testingdg/testvol
BAD SUPERBLOCK AT BLOCK 16: MAGIC NUMBER WRONG
 
LOOK FOR ALTERNATE SUPERBLOCKS WITH MKFS? y
 
 
LOOK FOR ALTERNATE SUPERBLOCKS WITH NEWFS? y
 
SEARCH FOR ALTERNATE SUPERBLOCKS FAILED.
 
USE GENERIC SUPERBLOCK FROM MKFS? y
 
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? n
 
** Last Mounted on
** Phase 1 - Check Blocks and Sizes
NEGATIVE SIZE 3472310635091290982 I=16
CLEAR? y
 
PARTIALLY ALLOCATED INODE I=32
CLEAR? y
 
PARTIALLY ALLOCATED INODE I=40
CLEAR? y
 
NEGATIVE SIZE -1 I=41
CLEAR? y
 
CG 0: BAD CG MAGIC NUMBER (0x1 should be 0x90255)
IMPOSSIBLE NUMBER OF CYLINDERS IN GROUP (0 is less than 1)
INCORRECT NUMBER OF INODES IN GROUP (0 should be 1920)
IMPOSSIBLE BLOCK ALLOCATION ROTOR POSITION (1243623771 should be at least 0 and less than 4096)
IMPOSSIBLE FRAGMENT ALLOCATION ROTOR POSITION (375731 should be at least 0 and less than 4096)
IMPOSSIBLE INODE ALLOCATION ROTOR POSITION (65536 should be at least 0 and less than 1920)
INCORRECT BLOCK TOTALS OFFSET (0 should be 168)
BAD FREE BLOCK POSITIONS TABLE OFFSET (0 should 232)
INCORRECT USED INODE MAP OFFSET (4 should be 488)
INCORRECT FREE FRAGMENT MAP OFFSET (0 should be 728)
END OF HEADER POSITION INCORRECT (0 should be 1240)
 
 
UPDATE STANDARD SUPERBLOCK? y
 
Irreparable cylinder group header problem.  Program terminated.
 
Mount the file-system back:
 
bash-2.05# mount -F vxfs /dev/vx/dsk/testingdg/testvol /testing
UX:vxfs mount: ERROR: V-3-20012: not a valid vxfs file system
UX:vxfs mount: ERROR: V-3-24996: Unable to get disk layout version
 
The file-system is corrupted.
 
Checking the superblock:
 
bash-2.05# fstyp -v /dev/vx/rdsk/testingdg/testvol | more
ufs                                                                                           <<<===we can see the file-system now reports UFS
magic   11954   format  dynamic time    Fri May 29 12:23:22 2009   <<<===also the date it was created (time of the fsck)
sblkno  16      cblkno  24      iblkno  32      dblkno  272
sbsize  2048    cgsize  2048    cgoffset 16     cgmask  0xfffffff0
ncg     256     size    1048576 blocks  0
bsize   8192    shift   13      mask    0xffffe000
fsize   1024    shift   10      mask    0xfffffc00
frag    8       shift   3       fsbtodb 1
minfree 10%     maxbpg  2048    optim   time
maxcontig 128   rotdelay 0ms    rps     60
csaddr  272     cssize  4096    shift   9       mask    0xfffffe00
ntrak   16      nsect   32      spc     512     ncyl    4096
cpg     16      bpg     512     fpg     4096    ipg     1920
nindir  2048    inopb   64      nspf    2
nbfree  0       ndir    0       nifree  0       nffree  0
cgrotor 0       fmod    0       ronly   0       logbno  0
fs_reclaim is not set
file system state is valid, fsclean is 1
blocks available in each rotational position
cylinder number 0:
  position 0:      0    2    4
  position 4:      1    3    5
 
As the super-block and most of metadata were overwritten by UFS, the filesystem cannot be recovered.   This corruption was happened as UFS fsck doesn't check existing non-UFS filesystem before create new super-block.
 

Issue/Introduction

fsck without proper file-system descriptor can cause corruption