Problem solved! Guess I should follow my hunches more often. the line of "root (hd2,0)" was the problem, since when I don't boot from compact disk, the hard drive is mounted as the first hard disk, so simply changing the code to "hd0,0" worked.