Bug 411559 - Failed to format a Compact Flash card as FAT32
Summary: Failed to format a Compact Flash card as FAT32
Status: REPORTED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: 4.0.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-03 13:45 UTC by Jonathan Wakely
Modified: 2024-07-09 11:50 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Output of failed attempt to format CF card (2.92 KB, text/html)
2019-09-03 13:53 UTC, Jonathan Wakely
Details
Output of successful format by gparted (4.37 KB, text/html)
2019-09-03 13:55 UTC, Jonathan Wakely
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2019-09-03 13:45:43 UTC
I bought a brand new 64GB CF card and when it arrived I tried to use partitionmanager to format it as a single FAT32 partition. Every time I tried it told me there was an error.

Running the fsck.fat commands manually I kept seeing errors:

[root@wraith ~]# fsck.fat -a -w -v /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
  Auto-correcting it.
Filesystem has 1691491 clusters but only space for 1662974 FAT entries.
[root@wraith ~]# echo $?
1

No matter what I tried to do in partitionmanager, it would fail and fsck.fat would show similar errors that it couldn't resolve:

[root@wraith ~]# fsck.fat -a -w -v /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
  Auto-correcting it.
Boot sector contents:
System ID "lkfs.f`t"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
     32768 bytes per cluster
        64 reserved sectors
First FAT starts at byte 32768 (sector 64)
         2 FATs, 32 bit entries
   6553600 bytes per FAT (= 12800 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 13139968 (sector 25664)
   1631599 data clusters (53464236032 bytes)
32 sectors/track, 64 heads
      2048 hidden sectors
 104448000 sectors total
Cluster 0 out of range (251657976 > 1631600). Setting to EOF.
Reclaiming unconnected clusters.
Checking free cluster summary.
Free cluster summary uninitialized (should be 1631598)
  Auto-setting.
Performing changes.
/dev/sdg1: 1 files, 1/1631599 clusters
[root@wraith ~]# fsck.fat -r -w -v -V  /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
1) Correct
2) Don't correct (FSINFO invalid then)
? 1
Boot sector contents:
System ID "lkfs.f`t"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
     32768 bytes per cluster
        64 reserved sectors
First FAT starts at byte 32768 (sector 64)
         2 FATs, 32 bit entries
   6553600 bytes per FAT (= 12800 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 13139968 (sector 25664)
   1631599 data clusters (53464236032 bytes)
32 sectors/track, 64 heads
      2048 hidden sectors
 104448000 sectors total
Starting check/repair pass.
Cluster 0 out of range (251657976 > 1631600). Setting to EOF.
Checking for unused clusters.
Checking free cluster summary.
Free cluster summary uninitialized (should be 1631598)
1) Set it
2) Leave it uninitialized
? 1
Starting verification pass.
Checking for unused clusters.
Perform changes ? (y/n) y
/dev/sdg1: 1 files, 1/1631599 clusters

[root@wraith ~]# fatlabel /dev/sdg1
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
  Auto-correcting it.
Filesystem has 1691401 clusters but only space for 1662974 FAT entries.

[root@wraith ~]# fsck.fat -r -w -v -V  /dev/sdg1       
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
1) Correct
2) Don't correct (FSINFO invalid then)
? 1
Filesystem has 1691401 clusters but only space for 1662974 FAT entries.
[root@wraith ~]# 
[root@wraith ~]# 
[root@wraith ~]# 
[root@wraith ~]# fsck.fat -r -w -v -V  /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
There are differences between boot sector and its backup.
This is mostly harmless. Differences: (offset:original/backup)
  135:6e/6f, 167:6e/6f
1) Copy original to backup
2) Copy backup to original
3) No action
? 3
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
1) Correct
2) Don't correct (FSINFO invalid then)
? 1
Filesystem has 1691401 clusters but only space for 1662974 FAT entries.
[root@wraith ~]# 
[root@wraith ~]# 
[root@wraith ~]# fsck.fat -r -w -v -V  /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
1) Correct
2) Don't correct (FSINFO invalid then)
? 1
Filesystem has 1691401 clusters but only space for 1662974 FAT entries.

Eventually I gave up and installed parted and used that, which worked perfectly. After gparted had created the desired partition, I could use KDE partitionmanager to remove the partition table, create a new one, and create a FAT32 partition without any problems.

As far as I can tell, what gparted did differently is an extra step, "clear old file system signatures in /dev/sdg1". Presumably this wiped away some bad metadata on the CF card that paritionmanager didn't remove and which was confusing fsck.fat.

Although it was 100% reproducable at first, I'm afraid I can't reproduce the errors now to check the old metadata, because after using gparted everything is OK.

The step that gparted shows in its log is:

clear old file system signatures in /dev/sdg1  00:00:00    ( SUCCESS )
 write 512.00 KiB of zeros at byte offset 0  00:00:00    ( SUCCESS )
 write 4.00 KiB of zeros at byte offset 67108864  00:00:00    ( SUCCESS )
 write 512.00 KiB of zeros at byte offset 64028672000  00:00:00    ( SUCCESS )
 write 4.00 KiB of zeros at byte offset 64029130752  00:00:00    ( SUCCESS )
 write 8.00 KiB of zeros at byte offset 64029188096  00:00:00    ( SUCCESS )
 flush operating system cache of /dev/sdg  00:00:00    ( SUCCESS )
Comment 1 Jonathan Wakely 2019-09-03 13:47:16 UTC
I forgot to say that when the card arrived it didn't have any partitions created.

I would have hoped that paritionmanager could be used to do the initial format of a new disk, and completely wipe away whatever is needed to do it correctly.
Comment 2 Jonathan Wakely 2019-09-03 13:53:14 UTC
Created attachment 122468 [details]
Output of failed attempt to format CF card

This is the output of one of the paritionmanager runs that gave an error.
Comment 3 Jonathan Wakely 2019-09-03 13:55:21 UTC
Created attachment 122469 [details]
Output of successful format by gparted
Comment 4 Andrius Štikonas 2019-09-03 16:38:44 UTC
(In reply to Jonathan Wakely from comment #3)
> Created attachment 122469 [details]
> Output of successful format by gparted

Partition manager also wipes file system signatures, it runs wipefs.

Looks like file system size on that CF card exceeded free space on that card, this would be the first step to try to reproduce your problem. Still, I don't understand why partitionmanager ends up in error.

Did it say what error?
Comment 5 Jonathan Wakely 2019-09-03 16:41:52 UTC
The first attachment is all that paritionmanager told me. I tried running the failing commands by hand on the terminal, and the output of those is shown in comment 0.
Comment 6 Jonathan Wakely 2019-09-03 16:44:50 UTC
I tried creating smaller partitions to try and avoid exceeding some limit, but it still said there were more clusters than there was space for FAT entries, e.g.

[root@wraith ~]# fsck.fat -r -w -v -V  /dev/sdg1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
FSINFO sector has bad magic number(s):
  Offset 0: 0x40615252 != expected 0x41615252
  Offset 484: 0x60417272 != expected 0x61417272
1) Correct
2) Don't correct (FSINFO invalid then)
? 1
Filesystem has 1599615 clusters but only space for 1572862 FAT entries.

Even when I tried something like a 32GiB partition I got that same error from fsck.fat.