How can I prevent Windows 10 from corrupting the ext4 superblock every time?

I have a pc with dual-boot Ubuntu/Windows since more than 5 years. The last working configuration was : windows 10 and Ubuntu 16.04 LTS.

I install Ubuntu 16.10 on the Linux partition and have some problems:

  • If I only boot on Linux, no problems, it works fine.
  • If I boot windows, no problem, windows works fine.
  • If I boot Linux after windows, I have a superblock error and drop to busybox.

If I restore the superblock with

fsck.ext4 -p -b 884736 -B 4096 /dev/sda5

I can boot Linux but after another boot to Windows the same problems reoccurs.

Of course I have tried solutions found:

  • chkdsk and testdisk while on windows.
  • I remove the extended partition and let the Linux installer recreate them.
  • Create by and, the extended partion + ext4 and swap and select these partition during the install process.

The partition table (fdisk -lu):

Disk /dev/sda: 298,1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6bb7527c

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048  22783999  22781952  10,9G  7 HPFS/NTFS/exFAT
/dev/sda2  *     22784000  22988799    204800   100M  7 HPFS/NTFS/exFAT
/dev/sda3        22988800 375246847 352258048   168G  7 HPFS/NTFS/exFAT
/dev/sda4       375246848 625141759 249894912 119,2G  f W95 Ext'd (LBA)
/dev/sda5       383440896 617844735 234403840 111,8G 83 Linux
/dev/sda6       617846784 625141759   7294976   3,5G 82 Linux swap / Solaris

I did some more tests without success:

  • I removed the Linux extended partition
  • I extended the windows partition to the full disk
  • I launched a chkdsk /F /R on this new windows partition → after a couple of hours all is good
  • I reinstalled Ubuntu 16.10 and let the install program resize the disk and create the ext4 and swap part.
  • I boot Linux → no problem
  • I boot windows → no problem (I reach the windows menu that let me choose between Windows and Linux, I choose Windows)
  • I boot Linux: same problem again (superblock error)

Update : the exact superblock error :

fsck.ext4: Superblock checksum does not match superblock while trying to open /dev/sda5

To repair it :

fsck.ext4 -p -b 884736 -B 4096 /dev/sda5

works fine, but after a Windows boot, the problem is there again ...

Update 2 : From W10, I can mount the linux ext4 partition with the W10 ext2 tool. It works fine, I can see the files. But after that, same problem, when I boot on Linux: superblock errors.

Of course if I just boot W10 (no login) and reboot linux, the problem is there too.

The problem was present with W10 1511, I've upgraded to W10 1607 : same problem

I saw that I was not alone on earth with this problem, but I did not see any solution.

update2 : I removed the linux and swap partition and create a new partition from windows. Then I reinstalled Ubuntu 16.10 => same problem again

update 3: The beginning of solution I have perhaps found a solution. When loggued in windows : With the command diskpart, when the linux volume is set offline there is no more problem when I boot linux.

I now have to find how to set the volume offline automaticaly (regedit ?)


Solution 1:

I have done some research and it seems that since ext2fsprogs 1.43 (Ubuntu 16.10), the 64bit and the metadata_csum features are enabled when a new ext4 filesystem is created. I did a fresh install of Ubuntu 16.10, but before installing, I started into the USB live session and removed the 64bit and metadata_csum features for ext4 from /etc/mke2fs.conf. After this I ran the installer out of the this live session and now I can start Windows 10 without corrupting my ext4 partitions (you have to reformat your ext4 partitions during the installation of Ubuntu 16.10).

The problem is related to ext2fsd which obviously does not support the 64bit feature and/or metadata_csum feature. It is sufficient to have ext2fsd installed to corrupt your ext4 partitions. No need for them to be mounted in Windows.

You can check if these features are enabled with the following command:

sudo tune2fs -l /dev/[sdXX]

where [sdXX] stands for the ext4-partition in question.

Solution 2:

I have the same issue and for me it seems to be the Windows 10 ext2fsd file system driver. Maybe for you too? When I uninstall ext2fsd (version 0.68) I can start Windows 10 as often as I want and the ext4 partitions stay clean. With ext2fsd installed all ext4 partitions get corrupted no matter if they are mounted or not.

Solution 3:

I have a solution that works for me (diskpart is my friend)

1) identify the linux partition in the cmd administrative windows :

diskpart
list volume

you can see your linux partition

  N° volume   Ltr  Nom          Fs     Type        Taille   Statut     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     D   BIOS_RVY     NTFS   Partition     10 G   Sain
  Volume 1     E   System       NTFS   Partition    100 M   Sain       Système
  Volume 2     C   OS_Install   NTFS   Partition    131 G   Sain       Démarrag
  Volume 3     L                       Partition     18 G   Sain     

DISKPART>

In my case : Volume 3

2) create a diskpart script with notepad create the file volume3offline.txt

select volume 3
offline volume
exit

3) create a bat file with notepad create the file govolume3offline.bat in the same directory

cd \users\f35\documents
diskpart /s volume3offline.txt

4) create a scheduled task Open the windows tash scheduler Program a task that launch govolume3offline.bat at boot time

5) check if all is ok after a reboot in windows

diskpart
list volume

your linux volume should be offline

Reboot in linux

If no errors => it's good
if you have errors, 
    correct them
    reboot in windows
    reboot in linux 
       If no errors => it's good
       if you have errors, goto 1)