Is there a way to restart badblocks?
I found this great answer to the question on the Atlanta Linux Enthusiasts General Mailing List:
I finally figured this out after much pondering and reading the man page about 10 times. I thought I'd share it in case someone else needs the info. Googling didn't help much, as those listings usually just quote the man page. When the man page says last-block first-block, it doesn't want you to enter those WORDS, it wants you to enter a NUMBER. It mentions that both are optional, but I cannot figure out how to leave out last-block if I want to specify first block.
Say you stopped your test originally at block 33000001. I would restart the test at one block less, so 33000000.
First, you have to determine what the last block number is on the partition. I've found two ways to do that.
You can start
badblocks
without block numbers. It will tell you the block range it's processing.Ex:
sudo badblocks -sv /dev/sda3
And it says something like:
Searching for badblocks in read only nondestructive mode from block to 66828373
Write down this ending block number. Terminate the test with CTRL-C and then enter the command with the block numbers that you want.
You can use the
fdisk
(or I think alsosfdisk
) command to list partition information. One of the columns of information is # of blocks. Find the number of blocks in the partition you're interested in and SUBTRACT 1 since the blocks are numbered starting at 0.
sudo fdisk -l /dev/sda
(That option is a lower case L. In this case, you don't specify the partition number, just the hard drive designation.)And it says something like:
/dev/sda2 ... /dev/sda3 ... 66828374 /dev/sda4 ...
Find the partition you're interested in and read the number of blocks and subtract 1 to find the last block number.
Now, you can enter the
badblocks
command as follows. Say you want to start testing in the middle of the partition at block 33000000. This example is for non destructive read write mode withbadblocks
list to a text file. If booted from a live cd, you will lose this text file when you reboot.
sudo badblocks -nsv -o ~/Desktop/badblocks.txt /dev/sda3 66828373 33000000
This will test from block 33000000 to the end of the partition. If you specify 66828374 as the last block, as reported in
fdisk
, it will report that block number as bad, but, in fact, that block number doesn't exist.I hope others may find this useful, as it really confused me for a while.
Sincerely,
Ron
There is a way to specify from which block badblocks
should start and the last block, (see man badblocks
):
badblocks [ -svwnfBX ] [ -b block-size ] [ -c blocks_at_once ] [ -e
max_bad_blocks ] [ -d read_delay_factor ] [ -i input_file ] [ -o
output_file ] [ -p num_passes ] [ -t test_pattern ] device [
last-block ] [ first-block ]