[Parted-maintainers] Bug#299906: parted: mistakes ext2 for fat

Sven Luther Sven Luther <sven.luther@wanadoo.fr>, 299906@bugs.debian.org
Thu, 17 Mar 2005 12:41:39 +0100


On Thu, Mar 17, 2005 at 12:21:51PM +0100, A Mennucc wrote:
> On Thu, Mar 17, 2005 at 11:37:36AM +0100, Sven Luther wrote:
> > On Thu, Mar 17, 2005 at 10:36:07AM +0100, A Mennucc wrote:
> > > Package: parted
> > > Version: 1.6.21-1
> > > Severity: important
> > > I have a USB memory stick; I have created one partition on it;
> > > the current layout is 
> > > 
> > > # fdisk -l /dev/sda
> > > Disk /dev/sda: 130 MB, 130809856 bytes
> > > 5 heads, 50 sectors/track, 1021 cylinders
> > > Units = cylinders of 250 * 512 = 128000 bytes
> > >    Device Boot      Start         End      Blocks   Id  System
> > > /dev/sda1               1        1021      127600   83  Linux
> > > 
> > > I wanted to use parted to resize my partition
> > > (to make room for a second crypto partition ) 
> > > But if I try to use parted on it, I get
> > > 
> > > # parted /dev/sda
> > > GNU Parted 1.6.21 with HFS shrink patch 16
> > > ....
> > > Using /dev/sda
> > > (parted) print
> > > Disk geometry for /dev/sda: 0.000-124.750 megabytes
> > > Disk label type: loop
> > > Minor    Start       End     Filesystem  Flags
> > > 1          0.000    124.750  fat16
> > > (parted)
> > > 
> > > This is very dangerous
> > 
> > You still have the old fat partition there, which you forgot to erase
> > completely.
> 
> ???  why was I supposed to  erase it in the firstplace ??

Because the old fat partition (and all usb sticks come with fats on it), has
still the marker thingy there, which parted uses for detecting partitions, and
searches first for a fat before going looking for an ext2.

> > Please do a dd if=/dev/zero of=/dev/sda or something such before creating the
> > ext2 partition, to make sure no trace of the olf fat remains.
> 
> I would prefer not . My partition is now full of data

Yep, i mean before you created the ext2 filesystem.

> btw: I doubt there is any vfat data around : I filled 
> the partition with my data almost completely

The magic marker for fat partition is probably kept, it is just one sector,
and probably living outside the ext2 accessible data or something.

> > How do you create the ext2 partition anyway ? 
> 
> with  'cfdisk /dev/sda' ; then I did 'mkfs.ext2 /dev/sda1'

If you had created the ext2 filesystem with parted, it would probably have
clobbered the old fat on it, not sure though.

> my usb stick works perfectly well with : 
> fdisk, cfdisk , mount, etc etc 

Sure, but you can't use those for resizing.

> moreover when I plug it in , the combination of
> udev/hal/pmount/nautilus
> mounts my partition and shows it in a nice
> nautilus window

Sure again.

> parted should see that the partion table clearly states that 
> the first partition is a Linux partition, no fat16 ;
> parted should not be fouled by 'traces of fat'

parted does not care about what the partition table states, but goes looking
for itself, which is the root of this problem. Something more clever could
(and maybe should) be done, but this is a post-sarge issue which we need to
convince upstream of, and would probably require a not-so-small redesign.
Maybe for parted 1.7 or something.

> parted is the only program being fouled

Because the other blindly follow the partition table. Now if you had changed
the partition type in the partition table erroneously, parted would not be
fouled, but the others would, so ...

Friendly,

Sven Luther