CentOS & HyperV just do not mix !

Cat and Dog angrySome months ago I’ve installed a guest CentOS 6.3 in Hyper-V vers. 6.0.6002 in Windows 2008 Standard Ed, without any Linux Integration Components (i’m lazy……).

Using yum I’ve installed a LAMP, and created a php-mysql website.

It seemed to work correctly… but after some days the websites stopped to work: I got the following errors in /var/log.

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
rejecting i/o to offline device

After some investigation I’ve found that the filesystem root became readonly. A restart solved the issue, but after some days……. readonly again.

Linux VM’s seem to sporadically remount their file system as read-only. I made several tests to resolve the situation but… I must say that the two act like literally cat and dog.

In the next some notes about how I have (partially ?) solved the problem. I honestly do not know if the problem is solved completely but it’s been three months now and the problem is no longer happened.

1) Upgraded CentOS to rev 6.4 (automagically the upgrade process has installed Linux Integration Components)

2) I suppose that the problem was the long latency that linux kernel get when accessing to the virtual HD, and for this reason I moved the virtual HD from NAS (connected to HyperV via iScsi) to local hard disk. On this local hard disk I’ve minimized the activity: only the file related this guest VM are present !

3) I had a backup process that created compressed files on the local (virtual) HD and at the end  moved them in other place. To minimize the disk activity (see step #2) I’ve modified the process that save the file directly without using local HD like temp dir.

4) Always to minimize disk activity (see step #2) I’ve set the swappiness to 10. In /etc/sysctl.conf

vm.swappiness=10

5) Modified driver timeout. In /etc/rc.local i added this line.

echo 180 > /sys/block/sda/device/timeout

I hope this post can help someone else.