LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 01-08-2023, 04:56 PM   #1
L-28C
Member
 
Registered: Oct 2006
Posts: 38

Rep: Reputation: 0
Anyone know how to scan hard drives for bad sectors?


I need to find out the location of every last bad sector on this drive. I'm tired of getting trolled. The best help I've had thus far in Linux is journalctl because it screams the sector number every time there's an error, but I don't know how to make it save the sectors to a file. I'm sure there's a way to make a script to persistently scan journalctl while I abuse the drive and extract the sectors from there but I would have no clue how to do that. Perhaps there's some other tool already made for this purpose?

Thanks in advance!

Last edited by L-28C; 01-08-2023 at 04:58 PM.
 
Old 01-08-2023, 05:18 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,767

Rep: Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765
First: On many, perhaps most, modern devices you do not need to do that. If they are S.M.A.R.T. technology compliant they self-detect and remap bad sectors and many low level tools do not report the remapping, you need the SMARTMON toolset, with which you can see the reported block reports for the information.

See this page for SMART tool hints https://linuxconfig.org/how-to-check...using-smartctl

If you run the information option and discover you have a device that is not SMART, then you need other tools.

Please verify what you are working with first. The report, replacing 'whatever' with the real device name for the drive in the following command should give us that information
Code:
sudo smartctl -i /dev/whatever
You can use the "blkid" report to find the real device name.
 
Old 01-08-2023, 06:18 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Perhaps the OP should describe their menagerie of "devices" first - previous threads may give some idea, but who knows.
 
Old 01-08-2023, 09:47 PM   #4
L-28C
Member
 
Registered: Oct 2006
Posts: 38

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
First: On many, perhaps most, modern devices you do not need to do that. If they are S.M.A.R.T. technology compliant they self-detect and remap bad sectors and many low level tools do not report the remapping, you need the SMARTMON toolset, with which you can see the reported block reports for the information.

See this page for SMART tool hints https://linuxconfig.org/how-to-check...using-smartctl

If you run the information option and discover you have a device that is not SMART, then you need other tools.

Please verify what you are working with first. The report, replacing 'whatever' with the real device name for the drive in the following command should give us that information
Code:
sudo smartctl -i /dev/whatever
You can use the "blkid" report to find the real device name.
Oh yeah no I'm way past SMART. For some reason it only has a limited number of remappable sectors, after those are gone you're on your own. If I can't remap them then I'll just avoid going anywhere near them... unless perhaps there's some software remapping technology I'm not aware of?

edit: also yeah what @syg00 said LOL these drives are begging me to just let them die, and yes there are bad sectors but what about the good sectors? They deserve to continue serving. I might even pull up to guiness records one day and see if they have one for the most horrible SMART history in a still functioning drive, who knows I might get rich

Last edited by L-28C; 01-08-2023 at 10:05 PM.
 
Old 01-08-2023, 11:03 PM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,767

Rep: Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765Reputation: 2765
The SMART utilities can still test your drive and report bad sectors, both remapped and current.
If you have a device that does not support SMART, then the vendors disk utilities would be the software of choice.

If bad sectors are propagating, then it is likely you have surface rust flaking and floating around in there, and should retire the drive anyway. Your data is not secure, and you cannot depend upon any disk utility or scan to tell you where the next rash of bad sectors will suddenly appear.
 
Old 01-15-2023, 01:33 AM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,973

Rep: Reputation: 271Reputation: 271Reputation: 271
I eyeball it.
 
Old 01-15-2023, 04:09 AM   #7
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,878
Blog Entries: 1

Rep: Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078
Take a look at a ddrescue mapfile. Maybe you could use what it contains.
 
Old 01-15-2023, 08:29 PM   #8
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by L-28C View Post
Oh yeah no I'm way past SMART. For some reason it only has a limited number of remappable sectors, after those are gone you're on your own. If I can't remap them then I'll just avoid going anywhere near them... unless perhaps there's some software remapping technology I'm not aware of?

edit: also yeah what @syg00 said LOL these drives are begging me to just let them die, and yes there are bad sectors but what about the good sectors? They deserve to continue serving. I might even pull up to guiness records one day and see if they have one for the most horrible SMART history in a still functioning drive, who knows I might get rich
If the drive has already remapped all the available sectors as reported in smartctl then the only intelligent thing for a user to do is replace the drive. Bad sectors continuing to develop is 100% indication of progressive drive failure and it is only a matter of time until the drive is totally unusable -- with the inevitable loss of data.

I strongly suggest immediate drive replacement to avoid a potential total failure at the worst possible time.

The 'badblocks' command can do some of what you ask, but does not preclude further failure.

Last edited by computersavvy; 01-15-2023 at 08:31 PM.
 
Old 01-15-2023, 08:40 PM   #9
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by L-28C View Post
If I can't remap them then I'll just avoid going anywhere near them... unless perhaps there's some software remapping technology I'm not aware of?
If the bad block replacement mechanism has reached its limit, my suggestion would be to buy the replacement drive, remount the failing one as read-only, and begin copying everything to the new disk. And soon.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Scan and Repair Disk Bad Sectors in Ubuntu Linux, Fedora LXer Syndicated Linux News 0 07-15-2020 07:26 AM
Scan and list all bad sectors. Tl7 Linux - Newbie 1 08-21-2018 08:59 AM
LXer: Check Hard drive for bad sectors or bad blocks in linux LXer Syndicated Linux News 0 08-11-2014 08:00 AM
LXer: Check Hard drive for bad sectors or bad blocks in linux LXer Syndicated Linux News 0 08-10-2014 12:21 AM
re-allocated sectors count shows 2 bad sectors, in Ubuntu 10.04 disk utility james2b Linux - Hardware 4 10-12-2010 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration