-1

I am using mount/umount commands with a Win VM on a KVM Linux host. I have a script that continuously loops:

sleep 1 sec
mount
read guest file
unmount

When I change a Win7 file (say, a text file using Notepad),I am able to see changes only after 10-30 seconds.
I also tried Windows 7 VM file cache flushing, but still there is no improvement in the performance.
Is there a way to force Windows 7 machine to write file changes directly on hard drive instead of cache?

Reference link:
Share files between Linux host and Windows guest

Harshal Patel
  • 59
  • 1
  • 1
  • 3

2 Answers2

0

most probably the sync command in your script would help. It will degrade overall performance of Linux box at the moment it is called, because it will flush all file caches to disk. It will not remove data from caches, just physically writes to disk.

Arunas Bartisius
  • 773
  • 5
  • 13
  • I tried 'sync' command on Linux host side, but it did not help. Then I found sync.exe which is Win utility. link: https://technet.microsoft.com/en-us/sysinternals/bb897438.aspx . I tried it and it is able to flush all file cache to disk. So after changing my file, if I do sync on Win7 guest side, I am able to see changes immediately (less than 0.5 sec) on the host side. I'm currently making measurements to get the exact latency. If anyone would like to see the host script I'm using, please let me know. – Harshal Patel Feb 10 '15 at 21:52
0

As per the clarifications you gave in comments, you are trying to mount an NTFS filesystem on two systems at the same time. In this case, the filesystem in question is the root filesystem of a VM and, while the VM is still running, you are trying to mount the filesystem from outside the VM. That cannot be done safely. You will corrupt the filesystem and lose data.

There are filesystems like OCFS2 that are designed for mounting shared storage devices on multiple systems simultaneously. They rely on communication between the mounting nodes to coordinate the on-disk state of the filesystem at all times.

"Normal" filesystems like NTFS do not support this. The filesystem must only be mounted on one system at a time. The state of the filesystem on disk is not necessarily consistent at all times while it is mounted. Operations are in the middle of taking place, buffers are cached in RAM, etc... They are simply not designed to coordinate simultaneous on-disk operations between multiple mounting nodes.

Celada
  • 43,173
  • 5
  • 96
  • 105
  • I'm working with Harshal. We're only doing read from the host side, no writes. It works reliably, no corruption, and we can get about 8 MByte/sec data transfer rate. Making repeated unmount and mount calls is inefficient, so now the objective is to find a method with less overhead. –  Feb 14 '15 at 02:17
  • @JeffBrower, it doesn't matter if you're doing only reads, although of course the problem would be much more serious if you were also doing writes. It's just not something that a non-cluster filesystem can support except by sheer luck. I really encourage you to find another method of data transfer. – Celada Feb 14 '15 at 08:45