maharmstone / ntfs2btrfs

GNU General Public License v2.0
683 stars 30 forks source link

Failure to convert Windows 10 20H2 boot disk #9

Closed boricj closed 3 years ago

boricj commented 3 years ago

I'm following the Quibble installation procedure and I have an error at the file-system conversion step:

Index record magic was not INDX.

The target partition is a straightforward, fresh Windows 10 20H2 French physical UEFI installation on a 480 GiB NVMe drive, with all Windows updates applied, WinBTRFS 1.7.5 installed, fast boot+pagefile disabled. The error happens on both Linux (Debian 10 netinstall media with statically-linked ntfs2btrfs) and Windows (Windows 10 20H2 installation media).

Details about the installation:

PS C:\Windows\system32> systeminfo

Host Name:                 DESKTOP-NJDFLGG
OS Name:                   Microsoft Windows 10 Professionnel
OS Version:                10.0.19042 N/A Build 19042
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          Jean-Baptiste Boric
Registered Organization:
Product ID:                00330-80000-00000-AA022
Original Install Date:     26/12/2020, 15:12:53
System Boot Time:          26/12/2020, 17:16:29
System Manufacturer:       System manufacturer
System Model:              System Product Name
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: AMD64 Family 23 Model 1 Stepping 1 AuthenticAMD ~3600 Mhz
BIOS Version:              American Megatrends Inc. 5603, 28/07/2020
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             fr;French (France)
Input Locale:              fr;French (France)
Time Zone:                 (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
Total Physical Memory:     32 705 MB
Available Physical Memory: 29 165 MB
Virtual Memory: Max Size:  32 705 MB
Virtual Memory: Available: 28 594 MB
Virtual Memory: In Use:    4 111 MB
Page File Location(s):     N/A
Domain:                    WORKGROUP
Logon Server:              \\DESKTOP-NJDFLGG
Hotfix(s):                 7 Hotfix(s) Installed.
                           [01]: KB4586876
                           [02]: KB4562830
                           [03]: KB4570334
                           [04]: KB4580325
                           [05]: KB4586864
                           [06]: KB4593175
                           [07]: KB4592438
Network Card(s):           3 NIC(s) Installed.
                           [01]: Intel(R) I211 Gigabit Network Connection
                                 Connection Name: Ethernet
                                 DHCP Enabled:    Yes
                                 DHCP Server:     172.16.175.2
                                 IP address(es)
                                 [01]: 172.16.175.176
                                 [02]: fe80::4825:ecfa:137d:b60a
                           [02]: Intel(R) Dual Band Wireless-AC 8260
                                 Connection Name: Wi-Fi
                                 Status:          Media disconnected
                           [03]: Bluetooth Device (Personal Area Network)
                                 Connection Name: Connexion réseau Bluetooth
                                 Status:          Media disconnected
Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                           Virtualization Enabled In Firmware: No
                           Second Level Address Translation: Yes
                           Data Execution Prevention Available: Yes
PS C:\Windows\system32> fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number :        0x5e38774e38772465
NTFS Version      :                3.1
LFS Version       :                2.0
Total Sectors     :                936 409 120  (446,5 GB)
Total Clusters    :                117 051 140  (446,5 GB)
Free Clusters     :                108 657 441  (414,5 GB)
Total Reserved Clusters :            1 895 112  (  7,2 GB)
Reserved For Storage Reserve :       1 766 319  (  6,7 GB)
Bytes Per Sector  :                512
Bytes Per Physical Sector :        4096
Bytes Per Cluster :                4096
Bytes Per FileRecord Segment    :  1024
Clusters Per FileRecord Segment :  0
Mft Valid Data Length :            206,50 MB
Mft Start Lcn  :                   0x00000000000c0000
Mft2 Start Lcn :                   0x0000000000000002
Mft Zone Start :                   0x00000000000cba40
Mft Zone End   :                   0x00000000000d2540
MFT Zone Size  :                   107,00 MB
Max Device Trim Extent Count :     256
Max Device Trim Byte Count :       0xffffffff
Max Volume Trim Extent Count :     62
Max Volume Trim Byte Count :       0x40000000
Resource Manager Identifier :      E4459AAA-4782-11EB-8D7A-97C30400D972
boricj commented 3 years ago

So I've looked at it and the utility is choking on large logical cluster numbers in the data runs because of these kinds of constructs in the source code:

l_val &= (1 << (l * 8)) - 1;

With a large enough l, 1 << (l * 8) will overflow an int and bad things happen. By changing all occurrences to 1ull << (l * 8), the utility managed to complete execution (with warnings about overly large ADS and compressed files, but that's a separate issue).

maharmstone commented 3 years ago

Brilliant! Thanks for this, that's very helpful.

I believe MSVC's code analyser picks up stuff like this - I'll run it through that and see if it finds anything else similar.

maharmstone commented 3 years ago

All the arithmetic overflow issues should now be fixed.