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

Mills, James jameswmills at ti.com
Fri Oct 8 19:02:31 UTC 2010


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



More information about the parted-devel mailing list