https://bugs.kde.org/show_bug.cgi?id=411559

            Bug ID: 411559
           Summary: Failed to format a Compact Flash card as FAT32
           Product: partitionmanager
           Version: 4.0.0
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: andr...@stikonas.eu
          Reporter: zi...@kayari.org
  Target Milestone: ---

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 )

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to