Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.)
Subject: Re: What can you do about corrupt disk blocks?
Date: 2000/10/11	[thread overview]
Message-ID: <8s29c7$n60$1@mailint03.im.hou.compaq.com> (raw)
In-Reply-To: 8s1a9h$qjk$1@nnrp1.deja.com


In article <8s1a9h$qjk$1@nnrp1.deja.com>, ed <ed2323@my-deja.com> writes:

>Can anyone advise: I had a disk with corrupt
>blocks on it recently. To get the system up and
>running again, I had to reset the bad blocks
>with fsck at boot up to get the disk mounted again.

For what it is worth, fsck doesn't do anything to directly
fix the bad block.  The bad block handling of most disks,
the kernel and/or controller subsystem can replace the
block on a write since they have known data to put into
it.  When fsck clears a block, the overwrite is probably
what causes the block to replaced.

>
>Is it possible in any way to back up the disk before resetting
>any blocks? (say using dd, to do a block by block copy)

Odds are, the disk is trying as hard as is likely to succeed,
if it can succeed, to read the block before it gives up.  You
could try re-reading it a lot of time and you might get good
data.  You might also get an undetected read error; the disk
thinks it got a good copy, but didn't.  That's can be worse
than getting a bad block.

>Is it possible to recover the blocks when fsck says it
>cannot read them?

Depends on what is in the block.  Bad blocks in a directory
will simply cause the directory to be cleared, unlinking the
files.  fsck has a pass that notices this and will relink
any files to the lost+found directory.  You lose the directory
structure and names for those files, but not the data in them.

If you can identify the affected files, the data in them may
not matter; object files created from a compiler step.  Or,
you can restore the data from a recent backup.

What you need to do is record all the blocks that fsck can't
read and identify what they're used for.  In many cases fsck
will say, but you can also use icheck.  Once you know what
affect cleaning the file system will have you can take
appropriate recovery actions.

It is worth noting that fsck doesn't read data block of most
files.  It will read data blocks for directories, since that
affects the file system organization.  Everything else it
reads is file system meta-data.  The types of blocks affected:

Superblock - There are backup copies of the superblock scattered
across the disk.  The first one is always block 32.  For file
systems created during the system installation the logs of
of these backups are kept somewhere under /var/adm.  The
newfs command can also be coereced to print the block numbers
for a given set of parameters without trying to write the
file system.

Cylinder group block - There is one of these per cylinder group.
Must of the information can be regenerated from the superblock
and most of the rest from the file system once consistent.

Inode blocks - Each inode data structure represents one file.
There are four of these data structure per disk sector.  About
all that can be done for a bad block is to clear it.  What
you'll want to do is record the inode numbers, see if you can
determine what file is about to be obliterated and plan
accordingly.  If the block can't be read, there isn't much
choice except to clear it, but at least you'll know what
file is lost.

Indirect blocks - UFS stores block addresses of file data at
three levels; direct block addresses in the inode and three
levels of indirect block.  The indirect blocks are the address
blocks which store addresses.  Each level address more and
more space;

direct blocks:      96 KB
1st indirect block: 16 MB
2nd indirect block: 32 GB
3rd indirect block: 64 TB

The 3rd indirect block can allow a file to address far more
space than the 32 bit block counter can track, so file
size and file system size are limited by the block counter
not the 3rd indirect block.

Losing an indirect block causes the corresponding amount of
storage in that file to be lost.  For an I/O error here,
you'll probably just have to restore the file from a backup.

Directory blocks - As noted earlier, this only causes the
file name to be lost.  The inode is unaffected by an I/O
error on the directory block.

Cylinder group summary - This can always be regenerated from
the cylinder group blocks.

If you have bad blocks in the file system meta-data, there's
a fair chance you also have them in the file data.  As I
noted earlier, fsck doesn't look at those blocks.  You can
use dd(1) for a simple scan or scu(8) for a scan of SCSI
connected disks.  The backplane RAID controller, probably
have their own utility.

Many bad blocks scattered out over the disk, and that's
probably a hint that the disk needs to be replaced...

>
>Thanks for any information or advice.
>
>ed
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
>

--
Alan Rollow				alan@nabeth.cxo.dec.com




  parent reply	other threads:[~2000-10-11  4:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-11  4:00 What can you do about corrupt disk blocks? ed
2000-10-11  4:00 ` Eric Bennett
2000-10-11  4:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes. [this message]
2000-10-12  4:00   ` ed
2000-10-12  4:00     ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox