Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsblk.sh lists exfat as ntfs filesystem #3

Open
Yetoo1 opened this issue May 4, 2020 · 15 comments
Open

lsblk.sh lists exfat as ntfs filesystem #3

Yetoo1 opened this issue May 4, 2020 · 15 comments

Comments

@Yetoo1
Copy link

Yetoo1 commented May 4, 2020

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.

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

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.

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

  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

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

Can you also send me output of this?

Thanks.

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

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

The /dev/da1s1 is the exFAT partition?

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

The /dev/da1s1 is the exFAT partition?

Yes.

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

Please show me also gpart show -p command output.

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

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)

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

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

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

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 ...

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

Try this version:
https://pastebin.com/Ad46ebD5

@Yetoo1
Copy link
Author

Yetoo1 commented May 4, 2020

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

I ran that with sh in a tcsh shell.

@vermaden
Copy link
Owner

vermaden commented May 4, 2020

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

@Yetoo1
Copy link
Author

Yetoo1 commented Oct 10, 2021

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

@vermaden
Copy link
Owner

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

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants