[parted-devel] parted with iPod 80GB

Jim Meyering jim at meyering.net
Tue Mar 27 07:45:25 CET 2007


"Mario Rossi" <mariofutire at googlemail.com> wrote:
> Indeed. I have problems READING the partition.
> Using the files I've uploaded and a loop device you can see exactly
> the partition table as it is in the iPod.
>
> losetup -f ipod.sda
>
> [root at thinkpad ~]# fdisk -b 2048 /dev/loop0
>
> Command (m for help): p
>
> Disk /dev/loop0: 50 MB, 50331648 bytes
> 255 heads, 63 sectors/track, 1 cylinders
> Units = cylinders of 16065 * 2048 = 32901120 bytes
>
>      Device Boot      Start         End      Blocks   Id  System
> /dev/loop0p1               1           4      128394    0  Empty
> /dev/loop0p2               5        2432    78011640    b  W95 FAT32
> Partition 2 has different physical/logical endings:
>     phys=(1023, 254, 63) logical=(2431, 254, 63)
>
> Of course fdisk reports errors because the file contains only the
> first 48MB of the disk. It needs to be told the sector size, but for
> the rest it shows the partition table in the same way as when I run it
> on the real iPod.
>
> And parted shows the same error
>
> [root at thinkpad ~]# parted /dev/loop0
> GNU Parted 1.8.6
> Using /dev/loop0
> Welcome to GNU Parted! Type 'help' to view a list of commands.
> (parted) print
> Error: Unable to open /dev/loop0 - unrecognised disk label.
>
> I don't know whether the problem is in the sector size, or in the
> strange partition table.
> I hope you can use it to test parted.

Thanks for the report and the disk image.
The problem was that your iPod partition table header
triggers a test for FAT file system, thus eliminating it.
Here's a patch that helps.
With it, at least, I now get this

    # ./parted /dev/loop0 print
    Error: Can't have a partition outside the disk!
    Information: Don't forget to update /etc/fstab, if necessary.

    [Exit 1]

BTW, if your disk really does have 2048-byte sectors,
then this patch is insufficient.  The label-matching code in
msdos_probe still requires a sector size of 512.  However, in your
image, everything between byte 512 and the 2K mark is all zeros.

Anyway, can you rebuild parted with this patch and try it on the actual disk?

2007-03-27  Jim Meyering  <jim at meyering.net>

	* libparted/labels/dos.c (msdos_probe): Don't reject a 0x52-offset
	"FAT" if there's also an "iPod" string at offset 0x47.

diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 8e7707e..7d70834 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -174,8 +174,12 @@ msdos_probe (const PedDevice *dev)
 	 * system.
 	 */
 	if ((!strncmp (part_table.boot_code + 0x36, "FAT", 3)
-	    && strncmp (part_table.boot_code + 0x40, "SBML", 4) != 0)
-	    || !strncmp (part_table.boot_code + 0x52, "FAT", 3))
+             && strncmp (part_table.boot_code + 0x40, "SBML", 4) != 0))
+		return 0;
+
+	/* Likewise, don't reject an iPod partition table. */
+	if (!strncmp (part_table.boot_code + 0x52, "FAT", 3)
+            && strncmp (part_table.boot_code + 0x47, "iPod", 4) != 0)
 		return 0;

 	/* If this is a GPT disk, fail here */



More information about the parted-devel mailing list