Welcome to the Reiser4 Wiki, the Wiki for users and developers of the ReiserFS and Reiser4 filesystems.

For now, most of the documentation is just a snapshot of the old Namesys site (archive.org, 2007-09-29).

There was also a Reiser4 Wiki (archive.org, 2007-07-06) once on pub.namesys.com.

FAQ/bad-block-handling

From Reiser4 FS Wiki
(Difference between revisions)
Jump to: navigation, search
(http://web.archive.org/web/20061113154756/www.namesys.com/bad-block-handling.html)
 
m (formatting fixes)
Line 1: Line 1:
Bad block handling in ReiserFS.
+
Bad block handling in [[ReiserFS]] is supported since [[reiserfsprogs]] v3.6.12-pre1.
The described bad block handling is supported since reiserfsprogs-3.6.12-pre1.
+
Questions
+
  
  1. Does my harddrive have bad blocks?
+
=== Does my harddrive have bad blocks? How can I get the list of bad blocks on my harddrive? ===
  2. How can I get the list of bad blocks on my harddrive?
+
  3. I have bad blocks on my hard drive, what do I do?
+
  4. I have bad blocks in the system reiserfs area, what do I do?
+
  5. How can I create a reiserfs filesystem on the block device with bad blocks?
+
  6. How can I check a reiserfs filesystem with bad blocks?
+
  7. How can I adjust the bad block list on a reiserfs partition?
+
  8. How can I get the list of bad blocks saved in the reiserfs?
+
  9. How can I mark a block as bad on a mounted reiserfs?
+
  
Answers
+
To figure out if the harddrive has bad blocks or not you can run
  
Does my harddrive have bad blocks?
+
  /sbin/badblocks [-b <reiserfs-block-size>] ''device''
How can I get the list of bad blocks on my harddrive?
+
    To figure out if the harddrive has bad blocks or not you can run
+
  
    /sbin/badblocks [-b <reiserfs-block-size>] device
+
the result is the list of bad blocks on the device, save it somewhere. Do not forget to specify the reiserfs-block-size to the [[badblocks]] program if you are going to use the result list of bad blocks with ReiserFS utilities. The default ReiserFS block size if 4k by default, you can also get it from [[debugreiserfs]] device output.
    the result is the list of bad blocks on the device , save it somewhere.
+
    Do not forget to specify the reiserfs-block-size to the badblocks program if you are going to use the result list of bad blocks with reiserfs utilities. The default reiserfs block size if 4k by default, you can also get it from debugreiserfs device output.
+
I have bad blocks on my hard drive, what do I do?
+
    You can try to write to all bad blocks with dd or dd_rescue program, the drive will probably be able to remap them to good ones (modern drives do this in response to write, but not reads). Understand that drives that start having problems with bad blocks very often rapidly decay and go bad, and consider buying a new drive to save yourself from experiencing that.
+
I have bad blocks in the system reiserfs area, what do I do?
+
    ReiserFS can handle only those bad blocks that belong to the data area, and cannot handle bad blocks of the reiserfs system area -- super block, journal, bitmap.
+
    If the drive does not remap them (see I have bad blocks on my hard drive, what do I do), then you cannot use this partition with reiserfs, use dd_rescue to make a backup, run reiserfsck on the backup.
+
How can I create a reiserfs filesystem on the block device with bad blocks?
+
    If you have the list of bad blocks of the device in the file (see How can I get the list of bad blocks on my harddrive), then you can use the following:
+
  
    mkreiserfs --badblocks file device
+
=== I have bad blocks on my hard drive, what do I do? ===
    Remember that the block size of the reiserfs is 4k by default, specify the same block size to badblocks program.
+
How can I check a reiserfs filesystem with bad blocks?
+
    If you want to just check a filesystem, there should be no extra option to reiserfsck.
+
    If you need to fix the list of bad blocks on the reiserfs partition, use:
+
  
    reiserfsck --badblocks file device
+
You can try to write to all bad blocks with [http://www.gnu.org/software/coreutils/ dd(1)] or [http://www.garloff.de/kurt/linux/ddrescue/ dd_rescue] program, the drive will probably be able to remap them to good ones (modern drives do this in response to write, but not reads). Understand that drives that start having problems with bad blocks very often rapidly decay and go bad, and consider buying a new drive to save yourself from experiencing that.
    where file contains the list of ALL bad blocks on the device.
+
    If you need to rebuild a reiserfs partition on the block device with bad blocks, you ALWAYS must specify the FULL list of bad blocks:
+
  
    reiserfsck --rebuild-tree --bad-badblocks file device
+
=== I have bad blocks in the system reiserfs area, what do I do? ===
    where file contains the list of ALL bad blocks on the device. (see How can I get the list of bad blocks on my harddrive)
+
 
How can I adjust the bad block list on a reiserfs partition?
+
ReiserFS can handle only those bad blocks that belong to the data area, and cannot handle bad blocks of the ReiserFS system area -- super block, journal, bitmap.
 +
 
 +
If the drive does not remap them (see I have bad blocks on my hard drive, what do I do), then you cannot use this partition with ReiserFS, use [http://www.garloff.de/kurt/linux/ddrescue/ dd_rescue] to make a backup, run [[reiserfsck]] on the backup.
 +
 
 +
=== How can I create a ReiserFS filesystem on the block device with bad blocks? ===
 +
 
 +
If you have the list of bad blocks of the device in the file (see How can I get the list of bad blocks on my harddrive), then you can use the following:
 +
 
 +
  [[mkreiserfs]] --badblocks file ''device''
 +
 
 +
Remember that the block size of the ReiserFS is 4k by default, specify the same block size to [[badblocks]] program.
 +
 
 +
=== How can I check a ReiserFS filesystem with bad blocks? ===
 +
 
 +
If you want to just check a filesystem, there should be no extra option to [[reiserfsck]].
 +
If you need to fix the list of bad blocks on the reiserfs partition, use:
 +
 
 +
  reiserfsck --badblocks file ''device''
 +
 
 +
where <tt>"file"</tt> contains the list of '''ALL''' bad blocks on the device.
 +
 
 +
If you need to rebuild a ReiserFS partition on the block device with bad blocks, you must '''ALWAYS''' specify the '''FULL''' list of bad blocks:
 +
 
 +
  reiserfsck --rebuild-tree --bad-badblocks file ''device''
 +
 
 +
where <tt>"file"</tt> contains the list of '''ALL''' bad blocks on the device. (see How can I get the list of bad blocks on my harddrive)
 +
 
 +
=== How can I adjust the bad block list on a ReiserFS partition? ===
 
     If you need to adjust the list of bad blocks you can use:
 
     If you need to adjust the list of bad blocks you can use:
  

Revision as of 04:19, 27 June 2009

Bad block handling in ReiserFS is supported since reiserfsprogs v3.6.12-pre1.

Contents

Does my harddrive have bad blocks? How can I get the list of bad blocks on my harddrive?

To figure out if the harddrive has bad blocks or not you can run

 /sbin/badblocks [-b <reiserfs-block-size>] device

the result is the list of bad blocks on the device, save it somewhere. Do not forget to specify the reiserfs-block-size to the badblocks program if you are going to use the result list of bad blocks with ReiserFS utilities. The default ReiserFS block size if 4k by default, you can also get it from debugreiserfs device output.

I have bad blocks on my hard drive, what do I do?

You can try to write to all bad blocks with dd(1) or dd_rescue program, the drive will probably be able to remap them to good ones (modern drives do this in response to write, but not reads). Understand that drives that start having problems with bad blocks very often rapidly decay and go bad, and consider buying a new drive to save yourself from experiencing that.

I have bad blocks in the system reiserfs area, what do I do?

ReiserFS can handle only those bad blocks that belong to the data area, and cannot handle bad blocks of the ReiserFS system area -- super block, journal, bitmap.

If the drive does not remap them (see I have bad blocks on my hard drive, what do I do), then you cannot use this partition with ReiserFS, use dd_rescue to make a backup, run reiserfsck on the backup.

How can I create a ReiserFS filesystem on the block device with bad blocks?

If you have the list of bad blocks of the device in the file (see How can I get the list of bad blocks on my harddrive), then you can use the following:

 mkreiserfs --badblocks file device

Remember that the block size of the ReiserFS is 4k by default, specify the same block size to badblocks program.

How can I check a ReiserFS filesystem with bad blocks?

If you want to just check a filesystem, there should be no extra option to reiserfsck. If you need to fix the list of bad blocks on the reiserfs partition, use:

 reiserfsck --badblocks file device

where "file" contains the list of ALL bad blocks on the device.

If you need to rebuild a ReiserFS partition on the block device with bad blocks, you must ALWAYS specify the FULL list of bad blocks:

 reiserfsck --rebuild-tree --bad-badblocks file device

where "file" contains the list of ALL bad blocks on the device. (see How can I get the list of bad blocks on my harddrive)

How can I adjust the bad block list on a ReiserFS partition?

   If you need to adjust the list of bad blocks you can use:
   reiserfstune --badblocks file device
   or
   reiserfstune --add-badblocks file device
   where file contains the list of blocks to be marked as bad. The --badblocks option clears the list of bad blocks on the reiserfs before adding the given list as the list of bad blocks, whereas --add-badblocks just adds the list to the list of bad blocks on reiserfs partition.
   If the reiserfs has some corruptions and reiserfstune refuses to run, use reiserfsck instead (see How can I check a reiserfs filesystem with bad blocks').

How can I get the list of bad blocks saved in the reiserfs?

   To get the list of blocks that are marked bad on reiserfs partition, run
   debugreiserfs -B file device
   where file is the filename of the file where the list should be stored in.
   Remember that if the reiserfs partition has fatal corruptions in the tree, the list of bad blocks can become unavailable, see How can I get the list of bad blocks on my harddrive'.

How can I mark a block as bad on a mounted reiserfs?

   You need to apply the following patch corresponding to your kernel version:
   linux-2.4.19-badblocks.diff
   linux-2.4.22-badblocks.diff
   The patch provides the new ioctl() commands for the ReiserFS that allows one to mark a given block as used/free in the block allocation bitmap without unmounting the filesystem.
   Then use the programm reiserfs-add-badblock as the following:
   reiserfs-add-badblock block used
   If you have the list of bad blocks of the block device saved in the file with the name file, and the reiserfs on this block device is mounted to /path_to/reiserfs-mount-point you can use:
   while read
   do
       reiserfs-add-badblock /path_to/reiserfs-mount-point $REPLY used
   done < file
Personal tools