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
m (.)
(badblocks is part of e2fsprogs)
 
(4 intermediate revisions by one user not shown)
Line 7: Line 7:
 
   /sbin/badblocks [-b <reiserfs-block-size>] ''device''
 
   /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 [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.
  
 
=== I have bad blocks on my hard drive, what do I do? ===
 
=== I have bad blocks on my hard drive, what do I do? ===
Line 25: Line 25:
 
   [[mkreiserfs]] --badblocks file ''device''
 
   [[mkreiserfs]] --badblocks file ''device''
  
Remember that the block size of the ReiserFS is 4k by default, specify the same block size to [[badblocks]] program.
+
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.
  
 
=== How can I check a ReiserFS filesystem with bad blocks? ===
 
=== How can I check a ReiserFS filesystem with bad blocks? ===
Line 40: Line 40:
 
   reiserfsck --rebuild-tree --bad-badblocks file ''device''
 
   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?]])
+
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? ===
 
=== How can I adjust the bad block list on a ReiserFS partition? ===
Line 54: Line 54:
 
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.
 
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]]).
+
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? ===
 
=== How can I get the list of bad blocks saved in the reiserfs? ===
Line 64: Line 64:
 
where <tt>''file''</tt> is the filename of the file where the list should be stored in.
 
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?]])
+
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? ===
 
=== How can I mark a block as bad on a mounted 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