LISTSERV mailing list manager LISTSERV 16.0

Help for LINUX-L Archives


LINUX-L Archives

LINUX-L Archives


LINUX-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LINUX-L Home

LINUX-L Home

LINUX-L  2010

LINUX-L 2010

Subject:

Fixing bad sectors on disk

From:

Bill Merriam <[log in to unmask]>

Reply-To:

Platform Independent Linux List! <[log in to unmask]>

Date:

Sun, 17 Jan 2010 21:35:59 -0500

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (79 lines)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is not a question so you can ignore it.

I have an old machine with old disks I was having problems with.  I was
going to reformat the disks and restore from backup (Bacula) but I
decided to play first.

I have read that IDE disk will reassign bad sectors to alternate
locations only if there is an error during a write, so bad reads don't
do you any good.  I have read the fix is to write /dev/zero to the whole
disk so write errors cause reassignment.

There are three disks in the machine, each on its own IDE interface
(there are four in this machine).  Partition 1 is RAID 1 with 3 disks,
partition 2 is swap with 3 disks and partition 3 is RAID 5 with 3 disks.
 I decided to take each disk offline, zero it, restore the partition
table and resync it, basically to see if it works.  It seems to.

I typed all these commands it one at a time to make sure I knew what was
going on, but I added them to a script as I did it.  Here is the script.

If there is an easier way to fix bad sectors I would be happy to hear
about it.  This isn't actually hard for me but it takes many hours of
the computers time.

Bill

DO NOT RUN THIS SCRIPT!!

#!/bin/bash

first=/dev/hdc
next=/dev/hda

echo testing arrays
mdadm -D --test /dev/md0 || exit
mdadm -D --test /dev/md1 || exit

echo turning off swap
swapoff /dev/${first}2

echo fail and remove ${first}1 from /dev/md0
mdadm /dev/md0 -f ${first}1
mdadm /dev/md0 -r ${first}1

echo fail and remove ${first}3 from /dev/md1
mdadm /dev/md1 -f ${first}3
mdadm /dev/md1 -r ${first}3

echo time to clear disk
sleep 20
dd if=/dev/zero of=$first

echo reloading partition table
sfdisk -d ${next} | sfdisk /dev/${first}

echo activating incomplete arrays
mdadm -Ac partitions -m 0 /dev/md0
mdadm -Ac partitions -m 1 /dev/md1

echo adding back empty partitions
mdadm /dev/md0 -a ${first}1
mdadm /dev/md1 -a ${first}3

echo formating and activating swap
mkswap /dev/${first}2
swapon /dev/${first}2


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLU8kO1uwH30QHmFQRAsgQAJ4ip8jH0azcFBU5Td9vo/iTLkmZkACgrNvm
+liTAp6hSYE2g78DMH1LQD4=
=vYO4
-----END PGP SIGNATURE-----

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager