#788808 parted: incorrectly reads partition table, or crashes

Package:
parted
Source:
parted
Description:
disk partition manipulator
Submitter:
Date:
2015-06-17 21:33:04 UTC
Severity:
important
#788808#5
Date:
2015-06-15 09:06:08 UTC
From:
To:
Dear Maintainer,

the following bug happens when 'parted' tries to analyze to the image file
https://www.olimex.com/wiki/images/b/b4/A20_OLinuxino_Micro_debian_34_90_release_10.torrent
that contains the operating system (Debian Wheezy) for the (quite remarkable) embedded system
https://www.olimex.com/wiki/A20-OLinuXino-MICRO

The partition table of this image file cannot be properly read or
modified with parted. Older versions of parted crash on this image
file. Newer versions report a the partition table is dangerously
different from the real one, so an user that uses parted to change
partitions may destroy all the data.

As a comparison, see attachments fdisk.txt and cfdisk.txt to see what
the partizion table really looks like

The  attachment fdisk.txt was generated by the command
# echo p | fdisk  imagefile > /tmp/fdisk.txt
that was ran inside a Jessie-amd64 machine.

The  attachment cfdisk.txt was generated by the command
# cfdisk -P s /dev/mmcblk0
that was ran inside a the A20-OLinuXino-MICRO itself (since the
Jessie version of cfdisk does not print partitions anymore (!!))

This bug is twofold
------------ 

Using parted 3.2-7 (Debian jessie amd64) to read the above image file
seems to work, but the partition table is dangerously different from
the real one, so an user that uses parted to change partitions may
destroy all the data

See attachment parted.txt
---------- Using parted 2.3-12 (Debian wheezy, two archs) parted crashes by Assertion (head_size <= 63) (as in bug 685557) See attachment crash....txt --------- Best regards and thanks in advance. a.
#788808#12
Date:
2015-06-15 13:31:20 UTC
From:
To:
It seems that parted has decided that the MBR looks more like a FAT boot
sector than an MBR.  Please attach the first kb of the image.

#788808#17
Date:
2015-06-17 17:24:04 UTC
From:
To:
here is the MBR.

I also have a proposal. When parted opens a disk, it should both check
if the whole disk is formatted as a VFAT (or other) volume, and check if
there is a partition table of some kind. In case that both checks are
true, it should stop and warn the user that the disk structure is
ambiguous, and ask for instructions.

    a.

Il 15/06/2015 15:31, Phil Susi ha scritto:

#788808#22
Date:
2015-06-17 18:00:50 UTC
From:
To:
You are right.

I used the command
# dd conv=notrunc if=/dev/zero of=a20_Lime_debian_3.4.90_release_3.img
bs=446 count=1
to delete the boot code.

Now the wheezy version of parted reports:
This is still unsupported.
while th Jessie version reports

vvvvvvvvvvvvvvvvvvvvvvvvvvv
Model:  (file)
Disk
/home/andrea/mnt/frivolo/media/R2D2/olimex/a20_Lime_debian_3.4.90_release_3.img:
3980MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  17,8MB  16,8MB  primary  fat16
 2      17,8MB  3980MB  3963MB  primary  ext3
^^^^^^^^^^^^^^^^^^^
or in sectors

that is exactly what cfdisk reports

THX

    a.

ps: anyway I think that 'parted' should check as expressed above. You
may want to change the bug title


Il 15/06/2015 15:31, Phil Susi ha scritto:

#788808#27
Date:
2015-06-17 18:11:46 UTC
From:
To:
You forgot to attach the file.

Not a bad idea.

#788808#32
Date:
2015-06-17 21:21:10 UTC
From:
To:
Il 17/06/2015 19:24, A Mennucc1 ha scritto:
for real  ;->

#788808#37
Date:
2015-06-17 21:29:20 UTC
From:
To: