Problems with old disks/controllers and the 'ata' driver
Problems with old disks/controllers and the 'ata' driver
According to the FreeBSD mailing lists, this is a common problem.
Every combination of hardware is different, this was my solution, yours may differ.
In my case, I had a dual-boot IDE disk, Win98 and FreeBSD 3.1.
FreeBSD 3.1 was using the 'wd' driver, no problem.
I upgraded to FreeBSD 4.2, using the 'ata' driver, still no problem.
When I had a motherboard failure and changed to a new one, the same old disk and the new disk controller continued working for Win98, but FreeBSD couldn't manage the new situation but screwed up the whole disk (the first and only time I have been disappointed with FreeBSD).
I tried to installed FreeBSD 4.2 from scratch various times, but the disk made timeouts and then reboot before finishing the installation.
Finally I returned to FreeBSD 3.1.
Recently, I read about improvements in the 'ata' driver, and tried to upgrade to FreeBSD 4.7.
Now the installation finished, but a minimal install took about an hour and a half.
On the debug screen (tty2) the screen filled up with:
ad0: WRITE command timeout tag=0 serv=0 - resetting
ata0: resetting devices ..ad0:DMA limited to UDMA33, non-ATA66 cable or device
I could log in to the system, but every now and then I had this annoying message, and the system freezing for at least 10 seconds.
I checked
# man ata
and looked for DMA-related issues, there was sysctl hw.ata.ata_dma.
Anyhow, sysctl hw.ata.ata_dma returned 1 (DMA enabled), while my error message told me not to use DMA.
Trying
# sysctl hw.ata.ata_dma="0"
sysctl: oid 'hw.ata.ata_dma' is read only
The man page referred to 'atacontrol', so the next step was:
# man atacontrol
The first attempt was
# atacontrol list
which only confirmed that the HDD (primary master) was set to DMA, while the CDROM (primary slave) was set to PIO4.
The first success was
# atacontrol mode 0 PIO4 PIO4
which set both the HDD and the CDROM to PIO4 mode.
No more timeouts!
I installed distributions, ports, etc.
Then I had a system failure, leaving the file systems dirty.
The system rebooted, setting hw.ata.ata_dma to 1 (DMA enabled) by default.
When 'fsck' tried to fix the dirty file system, the HDD timeout "confused" 'fsck' (my theory).
I got the following error messages:
and so on.
I could not clean the system, but had to reinstall FreeBSD again (sigh!).
In man ata I read "The following tunables are setable from the loader:":
hw.ata.ata_dma
set to 1 for DMA access 0 for PIO (default is DMA)
This lead me to
# man loader
which told me to put
hw.ata.ata_dma="0"
in
/boot/loader.conf
Voila!
I am up and running, my HDD boots forced to use PIO4 mode, no more disk crasches.
(In BIOS, I disabled DMA, and explicitly set Primary Master to PIO4 mode, but the 'ata' driver ignored that.)
Analizing this problem could lead to one of the following reasons:
A bad hard disk.
A bad hard disk controller.
Conflicting modes on the same IDE bus
(a master HDD in DMA mode and a slave CDROM in PIO4 mode).
An old 40-wire cable instead of a new 80-wire.
Changing one or more of the above maybe would allow me to use DMA instead of PIO.
Anyway, this solution was a successful workaround.