Thursday, 8 September 2011

BAD MAGIC NUMBER MAGIC NUMBER WRONG


BAD MAGIC NUMBER MAGIC NUMBER WRONG – restore primary superblock with fsck

Before going to actual error we should look at the basic components of the UFS filesystem. There are  four components of file system
  • boot block    :    The boot block stores information used to boot the system.
  • super-block :     Much of the filesystems internal information( like data location, address mappings …etc. )  is stored in superblocks.
  • inode              :     The inode stores location information about a file — everything except for the file name. The number of inodes in a filesystem can be changed from the default if newfs -i is used to create the filesystem.
  • data block     :    The file’s data is stored in data blocks


We will receive superblock errors either during the reboot or while running fsck command on the filesystem and the typical errors appear like below
  • clean flag in superblock is wrong: fix
  • File system state in superblock is wrong fix
  • Bad magic number
  • wrong magic number
If the primary superblock of any filesystem [ referenced in the vfstab, to automatically mount during booting ] is corrupted, the system will fail fsck during bootup with the following message:
BAD MAGIC NUMBER MAGIC NUMBER WRONG
Very often, the bad information in the primary superblock might not have been propagated to the backup superblocks. Hence we have chances to use a backup superblock for the fsck command to save the corrupted filesystem.
When you run the fsck command with a backup superblock, the uncorrupted information at that location is copied to the primary superblock, fixing the original problem.
To resolve the bad superblock issue we should find out the alternate superblocks which were created during the file system creation. you can list all available superblocks with the below command
# newfs -Nv /dev/rdsk/c#t#d#s# (where # is the actual device number)
Once you get the list of backup superblocks, you can use below fsck command to recover the filesystem using the backup superblock
fsck -o b= 15435424 /dev/dsk/c#t#d#s# ( where c#t#d#S# is actual disk device name)
Precautions:
Everytime when you mount a filesystem the clean flag for the superblock will be unset automatically, and if you run fsck on mounted filesystem you will get the “clean flag in superblock is wrong, fix ” error, and answering “yes” does not help fixing the problem.
Never run a fsck on a mounted filesystem. When a filesystem cannot be unmounted, boot the server into single user mode or boot from the CD-ROM.

No comments:

Post a Comment

Twitter Bird Gadget