Help with sfdisk
Gary W. Swearingen
garys at opusnet.com
Fri Apr 14 16:59:59 UTC 2006
Daniel Carrera <daniel.carrera at zmsl.com> writes:
> Hello,
>
> I'm trying to write a script using sfdisk but it looks like sfdisk is reporting wrong information.
>
> ---//--- OUTPUT START ---//---
> $ sudo sfdisk -l /dev/hda 2> /dev/null
> Disk /dev/hda: 79656 cylinders, 16 heads, 63 sectors/track
> Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
8225280 / 512 / 63 = 255, not 16. Maybe BIOS is set to 255, Linux
kernel thinks it should be 16 (check dmesg log), and sfdisk is
obviously confused. I've noticed Linux and FreeBSD both seem to
ignore the BIOS settings and this seems to change over the years, but
I really haven't figured it out. I used to use 255 so cylinders were
big, giving fewer cylinder 1024 problems, but got some nastiness when
OSes used 16 regardless, so I've buckled to their will and use 16
since cyclinder 1024 is seldom a deal breaker these days.
> I need a way to get the number of cylinders for the script, but it looks like the output from sfdisk is not
> reliable!!!!!! Any ideas?
Use "parted"? Or if you're willing to check to work of a flakey
sfdisk, try setting the number heads to 16 with -H. Or just try
sfdisk, assuming the error is just in the display. Risking a messed-up
disk, of course.
> FYI: The ultimate goal is to partition the disk with two partitions, a large ext3 partition and a 1GB swap partition at
> the end. I plan to use the number of cylinders and the size of each cylinder to calculate how many cylinders to alocate
> to each and then use fdisk to partition the disk.
If you get desparate, use cfdisk or fdisk interactively and pull
afterwards copy out the partition table with "dd" or "od" or "hd" and
put it on the new disks with "dd".
BTW, I don't recall every trying to write a partial hard disk block
(< 512b) with "dd" as you seem to have tried. Are you sure that works
well?
More information about the ubuntu-users
mailing list