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)
 
(badblocks is part of e2fsprogs)
 
(13 intermediate revisions by one user not shown)
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?
+
=== 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 [http://manpages.ubuntu.com/manpages/karmic/man8/badblocks.8.html 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?
+
    If you need to adjust the list of bad blocks you can use:
+
  
    reiserfstune --badblocks file device
+
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.
    or
+
  
    reiserfstune --add-badblocks file device
+
If the drive does not remap them (see [[#I have bad blocks on my hard drive, what do I do?|above]]), 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.
    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
+
=== How can I create a ReiserFS filesystem on the block device with bad blocks? ===
    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
+
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?|above]]), then you can use the following:
  
    linux-2.4.22-badblocks.diff
+
  [[mkreiserfs]] --badblocks file ''device''
    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
+
Remember that the block size of the ReiserFS is 4k by default, specify the same block size to [http://e2fsprogs.sourceforge.net/e2fsprogs-release.html badblocks] program.
    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
+
=== How can I check a ReiserFS filesystem with bad blocks? ===
    do
+
        reiserfs-add-badblock /path_to/reiserfs-mount-point $REPLY used
+
    done < file
+
  
 +
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?|above]])
 +
 +
=== 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 <tt>"file"</tt> contains the list of blocks to be marked as bad. The <tt>--badblocks</tt> option clears the list of bad blocks on the ReiserFS before adding the given list as the list of bad blocks, whereas <tt>--add-badblocks</tt> 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?|above]]).
 +
 +
=== 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 <tt>''file''</tt> 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?|above]])
 +
 +
=== How can I mark a block as bad on a mounted ReiserFS? ===
 +
 +
You need to apply the following patch corresponding to your kernel version:
 +
 +
* [http://ftp.icm.edu.pl/packages/linux-reiserfs/misc-patches/linux-2.4.19-badblocks.diff linux-2.4.19-badblocks.diff]
 +
* [http://ftp.icm.edu.pl/packages/linux-reiserfs/misc-patches/linux-2.4.22-badblocks.diff linux-2.4.22-badblocks.diff]
 +
 +
The patch provides the new <tt>ioctl()</tt> 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 program [[FAQ/bad-block-handling/reiserfs-add-badblock.c|reiserfs-add-badblock.c]] as the following:
 +
 +
  reiserfs-add-badblock /path_to/reiserfs-mount-point ''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 <tt>/path_to/reiserfs-mount-point</tt> you can use:
 +
 +
  while read r; do
 +
    reiserfs-add-badblock /path_to/reiserfs-mount-point $r used
 +
  done < ''file''
  
 
[[category:ReiserFS]]
 
[[category:ReiserFS]]

Latest revision as of 17:07, 27 June 2009

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

Contents

[edit] 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.

[edit] 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.

[edit] 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 above), then you cannot use this partition with ReiserFS, use dd_rescue to make a backup, run reiserfsck on the backup.

[edit] 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 above), 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.

[edit] 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 above)

[edit] 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 above).

[edit] 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 above)

[edit] How can I mark a block as bad on a mounted ReiserFS?

You need to apply the following patch corresponding to your kernel version:

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 program reiserfs-add-badblock.c as the following:

 reiserfs-add-badblock /path_to/reiserfs-mount-point 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 r; do
    reiserfs-add-badblock /path_to/reiserfs-mount-point $r used
 done < file
Personal tools