How to Fix Error ata1.00: failed to enable AA (0x1 = error_mask

The hard drive incorrectly advertises the ATA_FLAG_FPDMA_AA flag (the FPDMA FIS Auto Activate bit) but when this is activated it does not seem to have this capability. See http://download.intel.com/support/chipsets/imsm/sb/sata2_ncq_overview.pdf

Generally, the best fix is for drivers/ata/libata-core.c to be quirked to fix this for the specific drive series. A workaround may be do disable NCQ using the kernel parameter libata.force=noncq but this will make performance suck.

To do this, edit /etc/default/grub

and change:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash libata.force=noncq"

and run:

sudo update-grub

Error ata1.00: failed to enable AA (error_mask = 0x1)

This point to a problem with your hardware, be the cables, the hard drive or the motherboard. The only way to fix it, is diagnostic each piece of hardware. Since you said is random, you may test the memory and the Hard Disk first. Ubuntu includes the memtest86+ to do heuristics test to the memory, for the Hard Drive, you should do a full backup of all your important data then replace it.