Package: ntfs2btrfs
Version: 20240115-2
Severity: normal
X-Debbugs-Cc: marc.don...@gmail.com

When used on NTFS filesystems with a blocksize smaller than 4096 and -d is 
specified to not create checksums, ntfs2btrfs happily converts the filesystem 
to btrfs, however, the resulting btrfs is corrupt and cannot be mounted.

I tested cluster sizes of 512 (failed), 2048 (failed), 4096 (ok), 8192 (ok), 
and 16384 (ok).

When -d is not used, that is when checksums are created, which is the default, 
ntfs2btrfs fails with a cryptic error message and apparently leaves the 
filesystem unconverted, instead of destroying it. This seems to be just a lucky 
accident, though.

Transcripts for 512 (without -d), 512 (with -d), and 4096 (with -d) follow:

root@ws-lab-lnx-2:~# rm -f ntfs.img
root@ws-lab-lnx-2:~# dd if=/dev/zero of=ntfs.img bs=1M count=0 seek=5000
0+0 records in
0+0 records out
0 bytes copied, 4.2831e-05 s, 0.0 kB/s
root@ws-lab-lnx-2:~# losetup loop0 ntfs.img 
root@ws-lab-lnx-2:~# mkfs.ntfs -s 512 -c 512 -f /dev/loop0
The partition start sector was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could 
not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors 
per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
root@ws-lab-lnx-2:~# mount -t ntfs /dev/loop0 /mnt/mnt0
root@ws-lab-lnx-2:~# mkdir -p /mnt/mnt0/a/b
root@ws-lab-lnx-2:~# date > /mnt/mnt0/a/b/date
root@ws-lab-lnx-2:~# umount /dev/loop0
root@ws-lab-lnx-2:~# ntfs2btrfs /dev/loop0
Using Zstd compression.
Using CRC32C for checksums.
Processing inode 22 / 22 (100.0%)
Mapped 0 inodes directly.
Rewrote 0 inodes.
Inlined 1 inodes.
Updating directory sizes
basic_string_view::substr: __pos (which is 4096) > __size (which is 3584)
root@ws-lab-lnx-2:~# file ntfs.img 
ntfs.img: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS    ", Media 
descriptor 0xf8, sectors/track 0, dos < 4.0 BootSector (0x80), FAT (1Y bit by 
descriptor); NTFS, sectors 10239999, $MFT start cluster 32, $MFTMirror start 
cluster 5119999, clusters/RecordSegment 2, clusters/index block 8, serial 
number 0d0100ad7575364c
root@ws-lab-lnx-2:~# losetup -d loop0



root@ws-lab-lnx-2:~# rm -f ntfs.img
root@ws-lab-lnx-2:~# dd if=/dev/zero of=ntfs.img bs=1M count=0 seek=5000
0+0 records in
0+0 records out
0 bytes copied, 2.9301e-05 s, 0.0 kB/s
root@ws-lab-lnx-2:~# losetup loop0 ntfs.img 
root@ws-lab-lnx-2:~# mkfs.ntfs -s 512 -c 512 -f /dev/loop0
The partition start sector was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could 
not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors 
per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
root@ws-lab-lnx-2:~# mount -t ntfs /dev/loop0 /mnt/mnt0
root@ws-lab-lnx-2:~# mkdir -p /mnt/mnt0/a/b
root@ws-lab-lnx-2:~# date > /mnt/mnt0/a/b/date
root@ws-lab-lnx-2:~# umount /dev/loop0
root@ws-lab-lnx-2:~# ntfs2btrfs -d /dev/loop0
Disabling compression as it requires checksums to be enabled.
Using CRC32C for checksums.
Not calculating checksums.
Processing inode 22 / 22 (100.0%)
Mapped 0 inodes directly.
Rewrote 0 inodes.
Inlined 1 inodes.
Updating directory sizes
root@ws-lab-lnx-2:~# file ntfs.img 
ntfs.img: BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, 
UUID=4778290d-34c2-3557-3384-627bff0e654d, 28135936/5242875904 bytes used, 1 
devices
root@ws-lab-lnx-2:~# btrfs check /dev/loop0 
Opening filesystem to check...
Checking filesystem on /dev/loop0
UUID: 4778290d-34c2-3557-3384-627bff0e654d
[1/7] checking root items
[2/7] checking extents
ERROR: ignoring invalid extent, bytenr 1049088 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1057280 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1057792 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1058304 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1058816 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1059328 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1059840 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1060352 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1061376 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1061888 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1062400 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1062912 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1063424 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1063936 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1064448 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1180160 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1180672 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1181184 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1181696 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1182208 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1182720 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1183232 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1184256 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1184768 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1185280 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1185792 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1186304 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1186816 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1187328 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1188352 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1188864 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1189376 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1189888 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1190400 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1190912 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1191424 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1192448 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1192960 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1193472 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1193984 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1194496 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1195008 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1195520 is not aligned to 4096
ERROR: ignore invalid data extent, length 512 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1196544 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1197056 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1197568 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1198080 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1198592 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1199104 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 1199616 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 656424448 is not aligned to 4096
ERROR: ignoring invalid extent, bytenr 2622488064 is not aligned to 4096
ERROR: invalid file offset, have 512 expect aligned to 4096
ERROR: invalid file offset, have 66048 expect aligned to 4096
ERROR: invalid file offset, have 66560 expect aligned to 4096
ERROR: invalid file offset, have 67072 expect aligned to 4096
ERROR: invalid file offset, have 67584 expect aligned to 4096
ERROR: invalid file offset, have 68096 expect aligned to 4096
ERROR: invalid file offset, have 68608 expect aligned to 4096
ERROR: invalid file offset, have 69120 expect aligned to 4096
ERROR: invalid file offset, have 70144 expect aligned to 4096
ERROR: invalid file offset, have 70656 expect aligned to 4096
ERROR: invalid file offset, have 71168 expect aligned to 4096
ERROR: invalid file offset, have 71680 expect aligned to 4096
ERROR: invalid file offset, have 72192 expect aligned to 4096
ERROR: invalid file offset, have 72704 expect aligned to 4096
ERROR: invalid file offset, have 73216 expect aligned to 4096
ERROR: invalid file offset, have 74240 expect aligned to 4096
ERROR: invalid file offset, have 74752 expect aligned to 4096
ERROR: invalid file offset, have 75264 expect aligned to 4096
ERROR: invalid file offset, have 75776 expect aligned to 4096
ERROR: invalid file offset, have 76288 expect aligned to 4096
ERROR: invalid file offset, have 76800 expect aligned to 4096
ERROR: invalid file offset, have 77312 expect aligned to 4096
ERROR: invalid file offset, have 78336 expect aligned to 4096
ERROR: invalid file offset, have 78848 expect aligned to 4096
ERROR: invalid file offset, have 79360 expect aligned to 4096
ERROR: invalid file offset, have 79872 expect aligned to 4096
ERROR: invalid file offset, have 80384 expect aligned to 4096
ERROR: invalid file offset, have 80896 expect aligned to 4096
ERROR: invalid file offset, have 81408 expect aligned to 4096
ERROR: invalid file offset, have 82432 expect aligned to 4096
ERROR: invalid file offset, have 82944 expect aligned to 4096
ERROR: invalid file offset, have 83456 expect aligned to 4096
ERROR: invalid file offset, have 83968 expect aligned to 4096
ERROR: invalid file offset, have 84480 expect aligned to 4096
ERROR: invalid file offset, have 84992 expect aligned to 4096
ERROR: invalid file offset, have 85504 expect aligned to 4096
ERROR: invalid file offset, have 86528 expect aligned to 4096
ERROR: invalid file offset, have 87040 expect aligned to 4096
ERROR: invalid file offset, have 87552 expect aligned to 4096
ERROR: invalid file offset, have 88064 expect aligned to 4096
ERROR: invalid file offset, have 88576 expect aligned to 4096
ERROR: invalid file offset, have 89088 expect aligned to 4096
ERROR: invalid file offset, have 89600 expect aligned to 4096
ERROR: invalid file offset, have 90624 expect aligned to 4096
ERROR: invalid file offset, have 91136 expect aligned to 4096
ERROR: invalid file offset, have 91648 expect aligned to 4096
ERROR: invalid file offset, have 92160 expect aligned to 4096
ERROR: invalid file offset, have 92672 expect aligned to 4096
ERROR: invalid file offset, have 655375872 expect aligned to 4096
ERROR: invalid file offset, have 2621439488 expect aligned to 4096
ERROR: errors found in extent allocation tree or chunk allocation
[3/7] checking free space cache
unaligned value in the extent tree start 1049088 end 1057280
[4/7] checking fs roots
root 256 inode 257 errors 40, bad file extent
ERROR: errors found in fs roots
found 200704 bytes used, error(s) found
total csum bytes: 0
total tree bytes: 131072
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 112917
file data blocks allocated: 53248
 referenced 53248
root@ws-lab-lnx-2:~# mount -t btrfs /dev/loop0 /mnt/mnt0/
mount: /mnt/mnt0: can't read superblock on /dev/loop0.
       dmesg(1) may have more information after failed mount system call.
root@ws-lab-lnx-2:~# dmesg
[…]
[255897.291452] BTRFS: device fsid 4778290d-34c2-3557-3384-627bff0e654d devid 1 
transid 1 /dev/loop0 (7:0) scanned by mount (649781)
[255897.293366] BTRFS info (device loop0): first mount of filesystem 
4778290d-34c2-3557-3384-627bff0e654d
[255897.293449] BTRFS info (device loop0): using crc32c (crc32c-intel) checksum 
algorithm
[255897.294878] page: refcount:4 mapcount:0 mapping:00000000f73e7f36 
index:0x8118 pfn:0x22abeb
[255897.294884] memcg:ffff8be30b993000
[255897.294886] aops:btree_aops [btrfs] ino:1
[255897.294974] flags: 
0x17ffffc0004000(private|node=0|zone=2|lastcpupid=0x1fffff)
[255897.294979] raw: 0017ffffc0004000 0000000000000000 dead000000000122 
ffff8be4f5788bb8
[255897.294980] raw: 0000000000008118 ffff8be3091d70f0 00000004ffffffff 
ffff8be30b993000
[255897.294981] page dumped because: eb page dump
[255897.294984] BTRFS critical (device loop0): corrupt leaf: root=2 
block=135364608 slot=1, invalid key objectid, have 1049088 expect to be aligned 
to 4096
[255897.294990] BTRFS error (device loop0): read time tree block corruption 
detected on logical 135364608 mirror 1
[255897.295000] BTRFS error (device loop0): failed to load root extent
[255897.295284] BTRFS error (device loop0): open_ctree failed
root@ws-lab-lnx-2:~# losetup -d loop0



root@ws-lab-lnx-2:~# rm -f ntfs.img
root@ws-lab-lnx-2:~# dd if=/dev/zero of=ntfs.img bs=1M count=0 seek=5000
0+0 records in
0+0 records out
0 bytes copied, 3.3787e-05 s, 0.0 kB/s
root@ws-lab-lnx-2:~# losetup loop0 ntfs.img 
root@ws-lab-lnx-2:~# mkfs.ntfs -s 512 -c 4096 -f /dev/loop0
The partition start sector was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could 
not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be 
obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors 
per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
root@ws-lab-lnx-2:~# mount -t ntfs /dev/loop0 /mnt/mnt0
root@ws-lab-lnx-2:~# mkdir -p /mnt/mnt0/a/b
root@ws-lab-lnx-2:~# date > /mnt/mnt0/a/b/date
root@ws-lab-lnx-2:~# umount /dev/loop0
root@ws-lab-lnx-2:~# ntfs2btrfs -d /dev/loop0
Disabling compression as it requires checksums to be enabled.
Using CRC32C for checksums.
Not calculating checksums.
Processing inode 22 / 22 (100.0%)
Mapped 0 inodes directly.
Rewrote 0 inodes.
Inlined 1 inodes.
Updating directory sizes
root@ws-lab-lnx-2:~# file ntfs.img 
ntfs.img: BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, 
UUID=9cd9a805-e602-3f4f-a793-80c80d230ec0, 27033600/5242875904 bytes used, 1 
devices
root@ws-lab-lnx-2:~# mount -t btrfs /dev/loop0 /mnt/mnt0/
root@ws-lab-lnx-2:~# cat /mnt/mnt0/a/b/date 
Sa 28. Sep 21:02:55 CEST 2024
root@ws-lab-lnx-2:~# 








-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (550, 'testing'), (400, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.10.9-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages ntfs2btrfs depends on:
ii  libc6       2.40-2
ii  libgcc-s1   14.2.0-3
ii  liblzo2-2   2.10-3
ii  libstdc++6  14.2.0-3
ii  libzstd1    1.5.6+dfsg-1
ii  zlib1g      1:1.3.dfsg+really1.3.1-1

Versions of packages ntfs2btrfs recommends:
ii  btrfs-progs  6.6.3-1.2+b1

ntfs2btrfs suggests no packages.

-- no debconf information

Reply via email to