How should I prevent data corruption on an NTFS partition shared by Windows and Linux?
Solution 1
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.
Solution 2
It could be because of the fast reboot feature enabled by default in recent Windows, including Windows 8.
From ntfs-3g man page:
Moreover, the fast restart feature available on recent Windows systems has to be disabled. This can be achieved by issuing as an Administrator the Windows command which disables both hibernation and fast restarting :
powercfg /h off
Fast Startup is a new feature which is introduced in Windows 8 RTM. It allows your computer to start faster than normal by logging off the user session and then saving a part of system related files and drivers to a hibernation file. When you turn on your PC again, it resumes from hibernate and logs you in again. In other words, the fast startup feature combines the classic shutdown mechanisms with hibernation, so it can be called 'hybrid shutdown'. Hybrid shutdown is enabled by default in Windows 8 and its successor, Windows 8.1.
This will cause problems not only when dual-bootig to Linux, but also when daul-booting to a different installation of Windows.
Solution 3
Sometimes this is because Linux uses the characters in filenames which are invalid in Windows. For example you can save a file with a question mark (?) in its name in Linux (even in an NTFS partition). However, you cannot open it in Windows, and if you run a chkdsk, Windows will delete the file, and puts it in a folder named Found.nnn in the root of the drive with a different name which may become really tricky to find.
Related videos on Youtube
mAt
Updated on September 18, 2022Comments
-
mAt over 1 year
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 installationsda3
: My shared NTFS drivesda5
: Linux Mint 14 installationsda6
: 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)
-
Admin over 11 yearsHow are you switching between the different OS's? Are you using suspend-to-disk (hibernate) or are you rebooting?
-
Admin over 11 yearsJust rebooting. My battery is almost dead, so I use it plugged in. That's why I don't make my computer sleep or hibernate.
-
Admin over 11 yearsThat setup should work and I would recommend it. There's something pathological about your NTFS partition. If possible, you could try and reformat that partition (after having moved/copied all the data elsewhere):
mkfs.ntfs /dev/sda3
and see if it still does it.