Linux – How should I prevent data corruption on an NTFS partition shared by Windows and Linux

hard-disklinuxlinux-mintpartitionwindows

I use Linux for most of the things but I still need Windows sometimes. So, I have Linux Mint 14 and Windows 8 installed (dual-booting) on my computer with the following disk setup:

  • sda1: The 350 MB partition Windows 8 allocates (I still don't know why.)
  • sda2: Windows installation
  • sda3: My shared NTFS drive
  • sda5: Linux Mint 14 installation
  • sda6: Swap area for Linux Mint

Most of my files are in sda3 which I share between the two OSs (kind of like my backup partition). I can access it from both operating systems. However, sometimes my files get corrupted.

Example: I recently downloaded Eclipse and extracted it to a folder in sda3 drive in Linux Mint. It was working fine. Then when I switched to Windows, it asked me to repair my drives because there were some errors. I accepted, Windows did some scanning and restarted. When I switched back to Linux Mint, I noticed that Eclipse wasn't working. When I checked, most of the files in Eclipse folder were corrupted. Similar things happen other way around as well. Sometimes I'm not able to see and/or open files in Windows that I created/downloaded in Linux Mint. I'm tired of losing files like this.

Is it a hardware issue? (My computer is kind of old)

If not related to hardware, is there a better way to share data between OSes than what I currently have? (a separate NTFS partition for both)

Best Answer

What is likely happening is not that files are being corrupted but that Linux is doing its best to ensure that files are not corrupted.

When a filesystem is opened, written to, and is being closed, the operating system (both Windows and Linux) will mark the filesystem as being "dirty", e. g. not properly closed.

Under normal circumstances, when you unmount a filesystem, it will mark it as clean, presuming that all remaining I/O requests have been fulfilled, the filesystem's journal (if available) is empty, and all disk cache has been synced to the physical disk.

In some cases, the NTFS-3G utilities will simply not mark the filesystem as "clean" to ensure that it is checked by Windows at startup and avoid possible corruption.

In short, your hardware is probably fine, although it can't hurt to check the hard drive's health at any point. As far as actually sharing data back and forth, I would recommend a network-based storage method. Whether a locally-housed server or a push of the data into the cloud, using a network filesystem (probably SMB/CIFS for Windows compatibility) will ease the migration problems.

Related Question