Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Mar 2000 10:39:39 PST
From:      Marc Frajola <marc@enginet.com>
To:        Warner Losh <imp@village.org>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: How to fdisk/disklabel whole disk for FreeBSD from command line?
Message-ID:  <200003061839.KAA19796@enginet.com>
In-Reply-To: Your message of "Sat, 04 Mar 2000 01:14:51 MST." <200003040814.BAA32604@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200003040814.BAA32604@harmony.village.org>, Warner Losh writes:
> In message <Pine.BSF.4.21.0003032320080.10089-100000@resnet.uoregon.edu> Doug White writes:
> : > 	fdisk -e /dev/rda1
> : > 	disklabel -r -w da1 auto
> :
> : Yeah, this is wrong.  You need to specify a slice.
>
> But you can't specify a slice here.  It won't work.  If you give it
> the whole path, disklabel won't even try.  If you day da1s1, it will
> complain that it can't fit a disklabel for the entire disk into the
> slice smaller than the disk with some cryptic error message or another
> :-).

    Probably an error like 'No space left on device' (the error message
I talked about in my original posting about this problem). :)

> : I generally don't depend on the 'auto' magic -- it breaks for IDE
> : disks, and I'm not sure it works for slices either.
>
> It breaks for all disk lables that aren't the entire disk.

    Thanks, this is VERY helpful information to me -- I was expecting
'auto' mode to work on an fdisk slice, and knowing that it doesn't work
there tells me to pursue less optimal options.

> : I'm looking at the script and notice that it doesn't select slice
> : 1... somehow disklabel DTRT.  It works here :-)
>
> Well, you could look at my diskprep script that I just posted a
> reference to.
> 	http://people.freebsd.org/~imp/diskprep
> (also needs patches to fdisk:
> http://people.freebsd.org/~imp/fdisk-patch)  I'd like to commit it to
> FreeBSD after 4.0 goes out the door.  We have many partital solutions
> to this problem.  It is time to make a simple, standard tool to do
> this.  No, sysinstall doesn't count here because it isn't simple and
> cannot be driven from a script.  The fla tool is limited to fla DOC2K
> disks.  The prepdisk in picobsd has too many things hard coded and
> will work only for ide disks.
>
> It is designed to create a sane slice (ala fdisk -I (since -e -> -I
> soon)) and put a reasonable disklabel on it.  By default it does only
> one partition, but can be configured to do more.  I wrote it to deal
> with creating dozens of compact flash labeling when I'm given a hodge
> podge of CF sizes and manufactures to create images for (sometimes 48M
> parts are available, other times 45M parts, and each of those sizes
> varies +- 300 blocks between vendors).
>
> Warner

    Warner, thanks for the diskprep reference. I was hoping there was
some automagic disklabel command flag I was missing to automatically
create a valid FreeBSD partition table that covers a whole FreeBSD
slice, but after the many messages in this thread, I've come to the
conclusion that 'fdisk -e' (or -I as it will become) can automatically
create the fdisk slice, but the FreeBSD disklabel parameters must be
calculated externally from disklabel, requiring a script, such as
prepdisk. In short, the disklabel command simply doesn't have the
capability to automatically create a label that covers an entire
FreeBSD fdisk slice. Note that disklabel auto mode works fine if you
want to use "Dangerously dedicated mode", which I do not.

    I have written my own Perl script that reads dmesg to get the disk
geometry and then generates a proper FreeBSD partition (disklabel)
label, and have verified that I can get the result I want this way.

    A problem with both prepdisk and my script is that it depends on
the format of the kernel autoconfiguration entry for the sizes of
disks to stay relatively static. The message format changed recently,
and future such changes will cause our scripts to break.

    I believe the right solution to all this is to use a C program
doing ioctl's on the raw device to get disk geometry info, and then
using libdisk to write a proper label.

    Just as a side note, I discovered that 'fdisk -e' produces a
different ending cylinder number on the fdisk slice than sysinstall,
even though the number of sectors in the fdisk slice between the two
methods are identical. This doesn't seem to effect operation at all,
but I'd guess that the sysinstall number of 1023 is probably more
accurate than the less-than 1023 numbers I get with 'fdisk -e'. This is
probably a bug in 'fdisk -e'.

...Marc...


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003061839.KAA19796>