Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu User (http://www.linux-archive.org/ubuntu-user/)
-   -   hard drive sector testing on Ubuntu (http://www.linux-archive.org/ubuntu-user/708230-hard-drive-sector-testing-ubuntu.html)

lazer100 09-28-2012 06:25 PM

hard drive sector testing on Ubuntu
 
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?


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.


For speed with an unformatted disk, one could say
write data which is the timestamp repeated,

eg 20120928230510 repeated up to 512 bytes.

2012092823051020120928230510....

then reread that sector and see if its the same data,

looking also for error messages for the read and the write.



but if the test preserves the data that would also be alright,
it would just take longer.

I have a problem drive, and I need to determine the problem sectors
in order to return the drive to the manufacturer. They said to
use the Windows sector testing, but that reported no error. However
both on Windows and Linux, software has reported read and write errors.

so I dont trust the Windows sector testing and would like to verify
by some other means before I believe that!




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,

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

0,1,2,...

?



sequentially accessing the drive is less satisfactory for
testing a 1tb volume as I would have to synthesize a 1tb file,
and that wouldnt test the control sectors

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?








--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Nils Kassube 09-29-2012 06:09 AM

hard drive sector testing on Ubuntu
 
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"?

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

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

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


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Rashkae 09-29-2012 04:18 PM

hard drive sector testing on Ubuntu
 
On 09/29/2012 02:09 AM, Nils Kassube wrote:



AFAIK badblocks wouldn't restore the data.



Badblocks non-destructive read-write (-n) test will, indeed, restore the
data. Of course, it would still be a good idea to have a good backup
first, and use a UPS.


Also note that by default, badblocks repeats the test with 4 different
patterns. On a modern >1TB drive, that ... can take a while, so I would
usually use -t 0xaa (or -t random) to only do 1 pass.


Do not even thing of doing this on an SDD. Probably not a good idea on
those hybrid drives either. Reasons are outside the scope of this quick
e-mail, just don't do it.



And finally, this whole methology has been deprecated for almost a
decade. Sector testing should be handled transparently by the drive
firware. Use smartctl to examine the results (or initiate a full test.)
At most, you should only ever have to do a read test to force the
drive to scan the entire thing end to end. (something like ddrescue
/dev/sd? /dev/null -f will work nicely.)


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Nils Kassube 09-29-2012 05:03 PM

hard drive sector testing on Ubuntu
 
Rashkae wrote:
> On 09/29/2012 02:09 AM, Nils Kassube wrote:
> > AFAIK badblocks wouldn't restore the data.
>
> Badblocks non-destructive read-write (-n) test will, indeed, restore
> the data.

Thanks for the correction. I think I should have checked the man page
instead of relying on my faulty memory.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

lazer100 10-04-2012 09:28 AM

hard drive sector testing on Ubuntu
 
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!



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

lazer100 10-04-2012 09:43 AM

hard drive sector testing on Ubuntu
 
On 29-Sep-12 21:18:28 Rashkae wrote:
>On 09/29/2012 02:09 AM, Nils Kassube wrote:

>>
>> AFAIK badblocks wouldn't restore the data.
>>

>Badblocks non-destructive read-write (-n) test will, indeed, restore the
>data. Of course, it would still be a good idea to have a good backup
>first, and use a UPS.

looks like the badblocks default is just a read test which will be
nondestructive.

eg I used:

sudo badblocks -sv /dev/sdc

this didnt find any problems and took about 13 hours for the 1tb drive,

unfortunately on completion I cut and pasted the output and
this doesnt mention how long it took:

$
$ sudo badblocks -sv /dev/sdc
[sudo] password for lazer:
Checking blocks 0 to 976762583
Checking for bad blocks (read-only test): done
Pass completed, 0 bad blocks found.
$



there seem to be conflicts between different command line options,
usually the program rejects the presented command line!



>Also note that by default, badblocks repeats the test with 4 different
>patterns. On a modern >1TB drive, that ... can take a while, so I would
>usually use -t 0xaa (or -t random) to only do 1 pass.

there is an option to set the number of passes, but the program rejected
the command line when I tried this!

>Do not even thing of doing this on an SDD. Probably not a good idea on
>those hybrid drives either. Reasons are outside the scope of this quick
>e-mail, just don't do it.

now I'm curious what the reasons are!

not sure what you mean by a hybrid drive.


>And finally, this whole methology has been deprecated for almost a
>decade. Sector testing should be handled transparently by the drive
>firware. Use smartctl to examine the results (or initiate a full test.)
> At most, you should only ever have to do a read test to force the
>drive to scan the entire thing end to end. (something like ddrescue
>/dev/sd? /dev/null -f will work nicely.)

I havent tried these yet, as I got bogged down with the initial suggestions,

I will send some feedback when I try these.


the drive would appear to have removed the bad sectors, but I just wonder
what happens if a bad sector is part of a file. The drive cannot just
replace that sector as that part of the file would become junk.

or are the bad sectors removed on a write?

if the drive has started to malfunction I'm a bit wary about continuing
to use the drive,

I have used many hard drives in the past, and this is only the second
one to fail. with the first problem drive, sector 0 the MBR stopped
functioning
and I could salvage the drive, but it could no longer be used.

would you say that zeroing a modern drive would then remove the bad sectors?



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

Steve Flynn 10-04-2012 02:28 PM

hard drive sector testing on Ubuntu
 
On 4 October 2012 10:43, lazer100 <lazer100@talktalk.net> wrote:

>>Also note that by default, badblocks repeats the test with 4 different
>>patterns. On a modern >1TB drive, that ... can take a while, so I would
>>usually use -t 0xaa (or -t random) to only do 1 pass.
>
> there is an option to set the number of passes, but the program rejected
> the command line when I tried this!

What command did you issue?

>>Do not even thing of doing this on an SDD. Probably not a good idea on
>>those hybrid drives either. Reasons are outside the scope of this quick
>>e-mail, just don't do it.
>
> now I'm curious what the reasons are!

SSD's have a limited number of read/write cycles. Running badblocks
against one for any length of time would do little other than burn up
its life.

> not sure what you mean by a hybrid drive.

A spinning platter drive backed up by a smaller SSD on-board. Heavily
used blocks are cached into the SSD, thereby speeding up access to
them.

> the drive would appear to have removed the bad sectors, but I just wonder
> what happens if a bad sector is part of a file. The drive cannot just
> replace that sector as that part of the file would become junk.
>
> or are the bad sectors removed on a write?

Bad blocks are found on a write. The data is written to the block, and
then read back and compared to the write buffer. If the two match, the
data is good on the drive and the next block is written. if the two
differ, that block cannot be trusted so it's moved into the badblocks
list on the drive and the data is written to another block where the
process repeats. This is why you can hear a failing drive struggling
to write blocks cleanly and the heads zipping about. It's also why
failing drives get slower - they spend more time trying to find a good
place to stash the data.

It's not coincidence that people normally think there's something
wrong with a failing drive because it "sounds funny" and "it's much
slower".

Of course, If a block goes "bad" (maybe from a head touchdown) after
it's already got data on it, then you are indeed looking at a trashed
file.

> if the drive has started to malfunction I'm a bit wary about continuing
> to use the drive,

I would be too. Only way to find out is to run badblocks in write mode
and see how many (if any) blocks are written to the badblocks list. On
big drives, this takes some time, as you have discovered.

> would you say that zeroing a modern drive would then remove the bad sectors?

It would re-write the badblocks list, but as soon as those blocks are
written to again (and they are still bad) they'd be put back onto the
badblocks list.
--
Steve

When one person suffers from a delusion it is insanity. When many
people suffer from a delusion it is called religion.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

"compdoc" 10-04-2012 02:36 PM

hard drive sector testing on Ubuntu
 
> not sure what you mean by a hybrid drive.

It ok to run badblocks on a hybrid drive. It's no more than a read-only
cache that greatly speeds up some drive operations.

Badblocks wont check it any more than it checks the smaller memory cache on
a drive.



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

lazer100 10-10-2012 07:44 AM

hard drive sector testing on Ubuntu
 
On 29-Sep-12 21:18:28 Rashkae wrote:
>On 09/29/2012 02:09 AM, Nils Kassube wrote:

>And finally, this whole methology has been deprecated for almost a
>decade. Sector testing should be handled transparently by the drive
>firware. Use smartctl to examine the results (or initiate a full test.)

apologies for the delays, but I have now tried this,
but the drive doesnt seem compatible, I got the following output:

$
$
$ sudo smartctl --all /dev/sdc
[sudo] password for *******:
smartctl version 5.38 [x86_64-unknown-linux-gnu] Copyright (C) 2002-8 Bruce
Allen
Home page is http://smartmontools.sourceforge.net/

Device: TOSHIBA MK1059GSM Version: 0100
Device type: disk
Local Time is: Wed Oct 10 12:38:08 2012 BST
Device does not support SMART

Error Counter logging not supported
Device does not support Self Test logging
$
$

I bought this drive in 2011.


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

lazer100 10-10-2012 08:18 AM

hard drive sector testing on Ubuntu
 
On 04-Oct-12 19:28:07 Steve Flynn wrote:
>On 4 October 2012 10:43, lazer100 <lazer100@talktalk.net> wrote:

>>>Also note that by default, badblocks repeats the test with 4 different
>>>patterns. On a modern >1TB drive, that ... can take a while, so I would
>>>usually use -t 0xaa (or -t random) to only do 1 pass.
>>
>> there is an option to set the number of passes, but the program rejected
>> the command line when I tried this!

>What command did you issue?

$
$ sudo badblocks -p=1 -sn /dev/sdc
badblocks: invalid number of clean passes - =1
$



>>>Do not even thing of doing this on an SDD. Probably not a good idea on
>>>those hybrid drives either. Reasons are outside the scope of this quick
>>>e-mail, just don't do it.
>>
>> now I'm curious what the reasons are!

>SSD's have a limited number of read/write cycles. Running badblocks
>against one for any length of time would do little other than burn up
>its life.

when you say limited number, what order of magnitude?

by SSD I assume you mean solid state drive?

are SD cards regarded as SSD?

one camera uses an SDHC card and another uses SD.


>> not sure what you mean by a hybrid drive.

>A spinning platter drive backed up by a smaller SSD on-board. Heavily
>used blocks are cached into the SSD, thereby speeding up access to
>them.

>> the drive would appear to have removed the bad sectors, but I just wonder
>> what happens if a bad sector is part of a file. The drive cannot just
>> replace that sector as that part of the file would become junk.
>>
>> or are the bad sectors removed on a write?

>Bad blocks are found on a write. The data is written to the block, and
>then read back and compared to the write buffer.

the hardware always does this verify test?

>If the two match, the
>data is good on the drive and the next block is written. if the two
>differ, that block cannot be trusted so it's moved into the badblocks
>list on the drive and the data is written to another block where the
>process repeats. This is why you can hear a failing drive struggling
>to write blocks cleanly and the heads zipping about. It's also why
>failing drives get slower - they spend more time trying to find a good
>place to stash the data.

what is needed is to be able to specify a limit to how many retries,

so you know its time to replace the drive!

presumably eventually the drive runs out of spare sectors
(unless the drive is a portal to another universe)


>It's not coincidence that people normally think there's something
>wrong with a failing drive because it "sounds funny" and "it's much
>slower".

>Of course, If a block goes "bad" (maybe from a head touchdown) after
>it's already got data on it, then you are indeed looking at a trashed
>file.

>> if the drive has started to malfunction I'm a bit wary about continuing
>> to use the drive,

>I would be too. Only way to find out is to run badblocks in write mode
>and see how many (if any) blocks are written to the badblocks list. On
>big drives, this takes some time, as you have discovered.

I'll have to delay trying this because it takes so long,

as there are many alternative usages,
what command line do you recommend?


>> would you say that zeroing a modern drive would then remove the bad
sectors?

>It would re-write the badblocks list, but as soon as those blocks are
>written to again (and they are still bad) they'd be put back onto the
>badblocks list.






--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


All times are GMT. The time now is 04:36 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.