Bug 139257 - FAT-32 partition damaged when shrunk
FAT-32 partition damaged when shrunk
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: parted (Show other bugs)
3
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Chris Lumens
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-11-14 10:35 EST by Björn Persson
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-01-07 17:32:51 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
/etc/fstab (1.38 KB, text/plain)
2004-11-14 10:38 EST, Björn Persson
no flags Details
/boot/grub/grub.conf (2.99 KB, text/plain)
2004-11-14 10:39 EST, Björn Persson
no flags Details
the first 32 KiB of hda2 (32.00 KB, application/octet-stream)
2004-11-20 14:20 EST, Björn Persson
no flags Details

  None (edit)
Description Björn Persson 2004-11-14 10:35:29 EST
I booted the FC3 CD1 in rescue mode, skipped mounting partitions and
ran Parted to shrink my Windows 98 SE partition (hda2). Since then I
can't mount the filesystem from Fedora 1. Mount says:

# LANG=en mount /dev/hda2
mount: wrong fs type, bad option, bad superblock on /dev/hda2,
       or too many mounted file systems

When I try to boot Windows, Grub prints "chainloader +1" and then
nothing happens.

No partition numbers have changed, so no changes to fstab or grub.conf
should be needed. I conclude that Parted must have screwed up the
filesystem somehow.


Here's what the partition table looked like before:

(parted) print
Disk geometry for /dev/hda: 0.000-76319.085 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031     62.753  primary   fat16       boot, hidden
2         62.754  16127.753  primary   fat32       lba
3      16127.754  76316.594  extended
5      16127.785  17163.193  logical   linux-swap
6      17163.224  45778.974  logical   ext3
7      45779.005  76316.594  logical   ext3

I issued these commands (I don't remember the numbers I typed exactly):
resize 2 62.754 6500
resize 3 6502 76319
move 5 6503 7538

Now the partition table looks like this:

(parted) print
Disk geometry for /dev/hda: 0.000-76319.085 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031     62.753  primary   fat16       boot, hidden
2         62.754   6502.873  primary   fat32       lba
3       6502.874  76316.594  extended
5       6502.904   7538.312  logical   linux-swap
6      17163.224  45778.974  logical   ext3
7      45779.005  76316.594  logical   ext3


I'm attaching my /etc/fstab and /boot/grub/grub.conf. What else can I
provide? Any particular sectors from the damaged partition?
Comment 1 Björn Persson 2004-11-14 10:38:19 EST
Created attachment 106669 [details]
/etc/fstab
Comment 2 Björn Persson 2004-11-14 10:39:50 EST
Created attachment 106670 [details]
/boot/grub/grub.conf
Comment 3 Andrew Clausen 2004-11-20 02:27:27 EST
Could you please attach the first 32k of /dev/hda2 ?

dd if=/dev/hda2 of=persson-fat32-mangled.img bs=32k count=1

Thanks!
Comment 4 Björn Persson 2004-11-20 14:20:41 EST
Created attachment 107123 [details]
the first 32 KiB of hda2
Comment 5 Andrew Clausen 2004-11-20 16:47:27 EST
My kernel (2.6) doesn't complain about the file system (other than the
errors you'd expect from missing most of it).  In particular, it does
recognize it as FAT.

What does Parted's "check" command say?
Comment 6 Björn Persson 2004-11-22 19:42:29 EST
Now that Fedora 3 is installed I see the same behaviour (I think). The
partition gets mounted without errors, and when I try the image file
Linux recognizes it as VFAT and then complains that it can't read the
superblock. That is with Linux 2.6.9-1.678_FC3 and Mount 2.12a.

In Fedora 1, with Linux 2.4.22-1.2199.nptl and Mount 2.11y, both the
partition and the image file are recognized as VFAT, and then the
error message I quoted above is printed:

# LANG=en mount -v /dev/hda2 /mnt
mount: you didn't specify a filesystem type for /dev/hda2
       I will try type vfat
mount: wrong fs type, bad option, bad superblock on /dev/hda2,
       or too many mounted file systems
# LANG=en mount -v -o loop /home/bjorn/persson-fat32-mangled.img /mnt
mount: going to use the loop device /dev/loop3
mount: you didn't specify a filesystem type for /dev/loop3
       I will try type vfat
mount: wrong fs type, bad option, bad superblock on /dev/loop3,
       or too many mounted file systems

Told to "check 2", Parted reads the disk for a while but says nothing,
so I suppose it doesn't find any errors. (Parted 1.6.3 and 1.6.15.)
Comment 7 Andrew Clausen 2004-11-27 01:10:55 EST
What does dosfsck say?  (It is in the dosfsutils package)
Comment 8 Björn Persson 2004-11-27 07:43:34 EST
# dosfsck /dev/hda2 
dosfsck 2.8, 28 Feb 2001, FAT32, LFN 
Warning: FAT32 support is still ALPHA. 
Invalid disk format in boot sector. 
 
(It says that about the image file too.) 
 
Comment 9 Andrew Clausen 2004-11-27 18:44:37 EST
Ah, thanks, found the problem!

The version of Parted on the FC3 disks has a bug that sets bad CHS
geometry in the file system.  This bug was introduced in version
1.6.12 and fixed in version 1.6.17.  (If you can, please verify that
this is the same bug!)

I have just added a feature to Parted's "check" and "resize" (etc.)
operations that recognizes file systems that have been damaged in this
way, and offers to fix them.  This will be included in version 1.6.19.
Comment 10 Björn Persson 2004-11-27 22:17:15 EST
OK, with Parted 1.6.19:

(parted) check 2
Error: The file system's CHS geometry is (0, 0, 0), which is invalid.
 The partition table's CHS geometry is (9729, 255,
63).  If you select Ignore, the file system's CHS geometry will be
left unchanged.  If you select Fix, the file system's CHS
geometry will be set to match the partition table's CHS geometry.
Fix/Ignore/Cancel? fix

[root@groucho ~]# dosfsck /dev/hda2 -r
dosfsck 2.8, 28 Feb 2001, FAT32, LFN
Warning: FAT32 support is still ALPHA.
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
  24:3f/00, 26:ff/00
1) Copy original to backup
2) Copy backup to original
3) No action
? 1
Perform changes ? (y/n) y
/dev/hda2: 28950 files, 197057/206032 clusters

Linux 2.4 can mount the filesystem now, so it seems like it was that bug.
Comment 11 Andrew Clausen 2004-12-20 19:54:13 EST
Parted 1.6.20 now writes to both the main and backup sectors.  I think
this bug can be closed now.  Thanks.
Comment 12 Chris Lumens 2005-01-07 17:32:51 EST
I've put 1.6.20 into rawhide.  Please check and make sure this takes care of the
problem.  If not, feel free to reopen this bug.

Note You need to log in before you can comment on or make changes to this bug.