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