FIX A CORRUPTED MAGIC NUMBER IN THE FILE SYSTEM SUPERBLOCK AIX
If the superblock of a file system is damaged, the file system cannot be accessed. Most damage to the superblock cannot be repaired. The following procedure describes how to repair a superblock in a JFS file system when the problem is caused by a corrupted magic number. If the primary superblock is corrupted in a JFS2 file system, use the fsck command to automatically copy the secondary superblock and repair the primary superblock.
In the following scenario, assume /home/myfs is a JFS file system on the physical volume /dev/lv02.
1. Unmount the /home/myfs file system, which you suspect might be damaged, using the following command:
2. To confirm damage to the file system, run the fsck command against the file system. For example:
fsck -p /dev/lv02
If the problem is damage to the superblock, the fsck command returns one of the following messages:
fsck: Not an AIXV5 file system
Not a recognized filesystem type
3. With root authority, use the od command to display the superblock for the file system, as shown in the following example:
od -x -N 64 /dev/lv02 +0x1000
Where the -x flag displays output in hexadecimal format and the -N flag instructs the system to format no more than 64 input bytes from the offset parameter (+), which specifies the point in the file where the file output begins. The following is an example output:
0001000 1234 0234 0000 0000 0000 4000 0000 000a
0001010 0001 8000 1000 0000 2f6c 7633 0000 6c76
0001020 3300 0000 000a 0003 0100 0000 2f28 0383
0001030 0000 0001 0000 0200 0000 2000 0000 0000
In the preceding output, note the corrupted magic value at 0x1000 (1234 0234). If all defaults were taken when the file system was created, the magic number should be 0x43218765. If any defaults were overridden, the magic number should be 0x65872143.
4. Use the od command to check the secondary superblock for a correct magic number. An example command and its output follows:
$ od -x -N 64 /dev/lv02 +0x1f000
001f000 6587 2143 0000 0000 0000 4000 0000 000a
001f010 0001 8000 1000 0000 2f6c 7633 0000 6c76
001f020 3300 0000 000a 0003 0100 0000 2f28 0383
001f030 0000 0001 0000 0200 0000 2000 0000 0000
Note the correct magic value at 0x1f000.
5. Copy the secondary superblock to the primary superblock. An example command and output follows:
$ dd count=1 bs=4k skip=31 seek=1 if=/dev/lv02 of=/dev/lv02
dd: 1+0 records in.