[parted-devel] Using parted to create a loopback disk with cylinders of a non-default size.

Mills, James jameswmills at ti.com
Mon Oct 11 17:02:22 UTC 2010


On Fri, Oct 8, 2010 at 2:02 PM, Mills, James <jameswmills at ti.com> wrote:
> Hello all.
>
> I have a situation where I need to create a "raw" disk image using
> parted.  This disk image is challenging in that it needs to maintain
> the number of heads (255) and sectors (63) no matter how large the
> image is.  Here are the basic steps I am following currently:
>
> dd if=/dev/zero of=test bs=1M count=100
> losetup /dev/loop1 test
> parted  -s /dev/loop1 mklabel msdos
>
> At this point, the disk image looks good in terms of heads and
> sectors... if I use fdisk to look at it:
>
> # fdisk -l /dev/loop1
>
> Disk /dev/loop1: 104 MB, 104857600 bytes
> 255 heads, 63 sectors/track, 12 cylinders
>
> But parted already has a different idea:
>
> # parted -s /dev/loop1 unit chs p
> Model:  (file)
> Disk /dev/loop1: 1599,3,31
> Sector size (logical/physical): 512B/512B
> BIOS cylinder,head,sector geometry: 1600,4,32.  Each cylinder is 65.5kB.
>
> At this point, I can use sfdisk or fdisk to partition the disk image
> and maintain the required heads/sectors.  Unfortunately, I cannot
> figure out how to do this with parted.
>
> Any help would be greatly appreciated!
> James
>

Replying to my own post, I have a bit more information around this
behavior.  Hopefully it will help someone on the list point me in the
right direction.

I have 4 machines:

Ubuntu 9.10 x86 running parted 1.8.8.1.159-1e0e
Ubuntu 10.04 amd64 running parted 2.2
Ubuntu 10.04 x86 running parted 2.2
Fedora Core 13 x86 running parted 1.9

On all four boxes, I am using the following steps (as root)

losetup -d /dev/loop1
dd if=/dev/zero of=test bs=1M count=100
losetup /dev/loop1 test
parted  -s /dev/loop1 mklabel msdos

At this point, I run both "fdisk -l /dev/loop1" and "parted /dev/loop1
-s unit chs p"

Version 1.8.8 reports the same CHS numbers using both fdisk and parted
(12,255,63). All other versions report:

fdisk - 12,255,63
parted - 1600,4,32

Can anyone help me understand what has changed that would cause me to
get such disparate behavior?

Thanks!
James Mills



More information about the parted-devel mailing list