hard drive sector testing on Ubuntu

lazer100 lazer100 at talktalk.net
Thu Oct 4 09:28:45 UTC 2012


On 29-Sep-12 11:09:20 Nils Kassube wrote:
>lazer100 wrote:
>> further to an earlier topic,
>> 
>> I would like to do a sector test of a hard drive on Ubuntu,
>> this is a read and write test of sectors.
>> is there any software to do this on Ubuntu 8.10?

>How about "badblocks"?

ok, I have now tried this. 

it took a bit of experimenting before it would function because
the arguments are different from what I thought.

once it was running I started reading the documentation, 
then restarted this with the -s option which gives a progress indicator.

but I then calculated it would take something like 2.6 days, so I decided
to restart this with the read only option, in case that found any problems,
and calculated from the progress indicator it would take about 13 hours.

no bad blocks were found, which is probably Rashkae's comment that
a read will prompt bad sectors to be replaced, I'll reply on that
point to his email.

for the read only test, I had to unmount the volume and then used:

sudo badblocks -sv /dev/sdc

s is the progress indicator, which IMO is essential,
and v is verbose output which seems to be equivalent to v.

>> this is where the software would say read each sector,
>> make some arbitrary change to the data, ideally change
>> every byte,
>> write that,
>> then reread the sector and see if the data is correct,
>> and then perhaps restore the original data.

>AFAIK badblocks wouldn't restore the data.

as Rashkae comments later there are options to restore the data
eg -n, although I found the documentation a bit confusing.

not sure but I think the default usage is just a read test
which wont change anything at all, which is the form I used above. 
There is actually an option to specify how many passes, but the program
wouldnt accept
this when I set this to 1.

the documentation says that if you think you know better than
the program then you probably dont! ie the default behaviour is 
good.

its a slightly eccentric program, it does do what you want
but it takes some effort to determine how, it typically 
rejects the command line you try!


>> Further on this topic, is there any way to read and write to a
>> specific sector number on say /dev/sdc or /dev/sdc1
>> 
>> I can read and write sequentially with dd eg
>> 
>> dd if=/path/file of=/dev/sdc1
>> 
>> would write the file sequentially,

>You can use the skip and seek options of the dd command.

>> does Linux have a trick for accessing a particular sector number,
>> and will the sector numbers of each volume begin at say 0, eg

>If you use bs=512 you would be operating with sector numbers.

ok, I have noted these ideas but not tried them yet.

>> I guess I could subdivide the drive into 8 unformatted logical drives
>> of 128G,
>> and then write a 128G file to each, then filecompare that file with
>> each,
>> 
>> but is there a less severe way of testing sectors, where every sector
>> is tested?

>Don't subdivide the disk into several partitions. You wouldn't really 
>access every sector because there might be space left between the 
>partitions and you also wouldn't access the boot sector. Instead use the 
>device node of the entire disk for your tests, i.e. /dev/sdc and not 
>/dev/sdc1.

yeah, indirectly testing is unsatisfactory!






More information about the ubuntu-users mailing list