vermaden/scripts

lsblk.sh lists exfat as ntfs filesystem

Yetoo1 opened this issue · 15 comments

When I run lsblk with a drive (I tested with an external drive connected via usb) formatted on Windows as exfat, lsblk.sh will list the filesystem of the relevant formatted partition as ntfs instead of exfat. On Linux, lsblk -fs would list the relevant formatted partition as exfat.

Can you send me output of these?

# fstyp -u /dev/DEVICE
# file -s /dev/DEVICE
# fstyp -u /dev/DEVICEpartition
# file -s /dev/DEVICEpartition

Also sometimes when you create new fileystem on old one without cleaning the beginning of device with dd(8) - dd < /dev/zero > /dev/DEVICE bs=1m count=10 - you can get wrong results.

For example:
# mkntfs /dev/DEVICE
# mkexfatfs /dev/DEVICE

The above can be detected both as NTFS or exFAT depending on the method used.

  1. fstyp: /dev/da1: filesystem not recognized
  2. /dev/da1: DOS/MBR boot sector; partition 1 : ID=0x7, active, start-CHS (0x0,1,1), end-CHS (0x3d2,254,63), startsector 63, 15728454 sectors; partition 2 : ID=0xea, start-CHS (0x3d2,254,63), end-CHS (0x3d2,254,63), startsector 15728517, 63 sectors
  3. exfat
  4. /dev/da1s1: DOS/MBR boot sector

Can you also send me output of this?

Thanks.

# sh -x /path/to/lsblk.sh

The /dev/da1s1 is the exFAT partition?

The /dev/da1s1 is the exFAT partition?

Yes.

Please show me also gpart show -p command output.

Please show me also gpart show -p command output.
=> 40 976773088 ada0 GPT (466G)
40 1024 ada0p1 freebsd-boot (512K)
1064 968883200 ada0p2 freebsd-ufs (462G)
968884264 7888864 ada0p3 freebsd-swap (3.8G)

=> 63 15728577 da1 MBR (7.5G)
63 15728454 da1s1 ntfs [active] (7.5G)
15728517 63 da1s2 !234 (32K)
15728580 60 - free - (30K)

=> 63 15728577 diskid/DISK-AA00000000000489 MBR (7.5G)
63 15728454 diskid/DISK-AA00000000000489s1 ntfs [active] (7.5G)
15728517 63 diskid/DISK-AA00000000000489s2 !234 (32K)
15728580 60 - free - (30K)

This is the output of gpart show -p /dev/da1 in case you want it:
=> 63 15728577 da1 MBR (7.5G)
63 15728454 da1s1 ntfs [active] (7.5G)
15728517 63 da1s2 !234 (32K)
15728580 60 - free - (30K)

It looks like TYPE_EXFAT_HELPER is returning nothing from the sh -x output, but I might be reading that wrong.

The current TYPE_EXFAT_HELPER is only useful when exFAT is created on whole device. Useless for exFAT created on partition. Working on small 'workaround' for that ...

I get errors:
https://pastebin.com/peG8nc1E

I ran that with sh in a tcsh shell.

I will recreate this exFAT on MBR and will figure something out.

I reran the script (not the modified one, but a fresh script from the repository) on 12.2-STABLE (stable/12-n233912-0d2b77383b0) and the exfat partition is now identified as ms-basic-data, although it seems this is because windows is leaving a 1.0 M blank partition before writing the data partition. This is the case after having windows writing 0s to the device before formatting as exfat. This is opposed to earlier in the thread when it wrote exfat in the first partition. I noticed that windows was setting the drive as GPT after it formatted so I don't know if this is different from last time, although this may not be the case because here is the output when I typed the following commands (from earlier in the thread):

# fstyp -u /dev/DEVICE
# file -s /dev/DEVICE
# fstyp -u /dev/DEVICEpartition
# file -s /dev/DEVICEpartition
  1. fstyp: /dev/da1: filesystem not recognized
  2. /dev/da1: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3d2,254,63), startsector 1, 4294967295 sectors, extended partition table (last)
  3. exfat
  4. /dev/da1p1: DOS/MBR boot sector

Output of gpart show -p:
=> 34 15728573 da1 GPT (7.5G)
34 2014 - free - (1.0M)
2048 15724544 da1p1 ms-basic-data (7.5G)
15726592 2015 - free - (1.0M)

In case you needed it here are images of the aforementioned usb drive that was formatted on Windows. These were copied with conv=sync,noerror:
Here's a compressed archive of the partition (I was able to mount this and traverse filesystem):
exfatdrivepartback2.gz.xz.zip
Here's a compressed archive of the full drive (I'm not sure how to test this with mdconfig/mounting since no partitions enumerated, just device):
exfatdrivefullback.gz.xz.zip

Thakns for the report and the images. I will look into that.

Regards