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.


From Reiser4 FS Wiki
Jump to: navigation, search

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


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

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)

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


 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).

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)

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