Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Nov 2008 17:58:34 -0500
From:      Jerry McAllister <jerrymc@msu.edu>
To:        Jonatan Evald Buus <jonatan.buus@cellpointmobile.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: FreeBSD 7.0 fdisk issue during installation
Message-ID:  <20081121225834.GA44520@gizmo.acns.msu.edu>
In-Reply-To: <113ce31b0811211341s10a602bfu5289a7116b024551@mail.gmail.com>
References:  <113ce31b0811211103w22b2108emf6a376a402d7fa60@mail.gmail.com> <20081121195524.GB43897@gizmo.acns.msu.edu> <113ce31b0811211341s10a602bfu5289a7116b024551@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 21, 2008 at 10:41:07PM +0100, Jonatan Evald Buus wrote:

> Hi Jerry,
> Thank you for the swift and very thorough response.
> 
> If I understand you correctly, then I should only create 1 slice of the
> entire disk (seeing as FreeBSD will be the only OS) using fdisk and then
> partition the slice using bsdlabels from sysinstall?

Yes.   Or you don't have to use sysinstall.  You can do it 
manually.   But, using sysinstall makes it easy.

You don't absolutely have to slice or bsdlabel it.
You can either just newfs the device /dev/da0 or you can create a slice
and just newfs that /dev/da0s1.   Then you get that 'dangerously dedicated'
disk which FreeBSD can use, but nothing else can including some non-FreeBSD
boot managers.   Some people do that to save a couple thousand bytes of
space, but on a multi-gigabyte drive, who cares about a couple thousand
bytes.

> Previously I was aiming for 5 slices, each of which had a single partition
> as described below.

Yup.   That won't work.

> >From your explanation I take it that "slices" are what Windows refers to as
> "Primary Partitions"?
> If that's the case then I understand the behaviour I experienced.

Yes.   There is that conflict of terminology.  
But, FreeBSD has called it slices from the beginning.

> Is it possible to make a slice non-bootable?

Yes.   Just don't put in an MBR and don't mark it bootable in 
the fdisk stage.

> And would there be any benefits (less fragmentation, faster access time
> etc.) in using slices rather than partitions to layout the harddrive or
> should slices only be used to represent a physical harddrive?

There is no advantage in making a slice non-bootable, except you might
be able to save a few bytes of storage - storage that is not normally
used anyway.   There is no advantage in speed or access time and
fragmentation is only a MS worry.   It is not an issue in superior
UNIX filesystems - at least in FreeBSD's.

I don't understand the last line of that paragraph.
Pretty much everything is virtual in disk drive addressing nowdays.
It doesn't matter which level you refer to.

The slice and its limit to 4 is a "feature" of standard BIOS basically.
All the other things, partitions, extended partitions, etc are ways
of getting around the limits.    The only real reason nowdays to
have more than one slice on a drive in FreeBSD is if you want to put
more than one bootable system on the drive.   For example, the machine
I am typing on has MS-XP and FreeBSD, plus a Dell diagnostic slice - 
so three slices are used.   I could squish those slices down and add
one more, say for Linux or a different version of FreeBSD if I wanted, 
but I don't.    

Generally, when I make a machine intended only for FreeBSD, I put all
the disk in one bootable slice.   Then I partition that slice to 
suit me.  My pattern is usually:
   a   /  (root)
   b   swap         (125% of memory size)
   c   defines the slice - not a real partition
   d   /tmp         (used as scratch space by many utilities)
   e   /usr         
   f   /var         (size depends on logging and databases which live here)
   g   /home        (user home directories, plus I put some of the things
                     that can grow unexpectedly such as /var/mail, /var/spool
                     /usr/ports, /usr/local  here and make symlinks to them)

Some people make just one big partition for root plus some for swap.
I like the control I have over things my way a little better and I 
can get by with backing up and restoring more manageable chunks my way.

If the machine is to be a "dual boot" as this one is,  I carve it up in
to slices - one for each bootable system.    If it already has some
MS thing loaded, I use some tool such as Gparted or Partition Magic
to shrink the MS primary partition and create two or three or four
of them.   Then I use fdisk to set up the FreeBSD slice to be bootable
and bsdlabel to partition that slice.   
By the way, 'dual boot' is kind of a generic term referring to any
number of bootable slices more than one.   So, it could refer to two,
three or four actual bootable systems on the drive.

Except for something like the "hidden" Dell diagnostic slice (HP and
probably other vendors like to do that as well), MS must be in the first 
slice because it doesn't like to play well with other systems.   But, it 
does overlook the 'hidden' slices OK.  That 'hidden' attribute is ignored 
by FreeBSD.   But, since it doesn't care which slice it is in, that is 
no problem.     

When I have a second (or third, etc) disk on the machine, I generally
do not make those disks bootable.   I make them just one plain slice 
each and generally, since they mostly get used as mass data storage,
I create just one partition in that slice.   But, I have created 
more when it was useful.   One I am thinking about, it was useful to
make more partitions in the second drive because I was using it to
build a system to distribute to other machines and I could isolate
that in one separate partition that way and use other partitionss 
for development space.

If you have more than one drive and you want to put some bootable
slices on each of them, you can do that by putting an MBR on each
one, marking each slice you want bootable as such and putting the
boot block and OS on that drive.  

It is a little a little confusing that there is a Master Boot Record
and a boot block being named in such similar sounding ways.  They 
are each one sector long and are quite related, but are different
and both are needed.    

To boot, the system turns control over to the BIOS.   
The BIOS does a bunch of stuff with the hardware and then looks
  for an MBR in its list of boot devices (which you can normally
  configure in BIOS control utility.  You usually have to break out
  of the boot sequence early on to get in to BIOS)
The BIOS loads the first MBR it finds and then transfers control to it.
The MBR does some minor housekeeping and then looks for slices that
  are marked bootable in its boot table (set by fdisk).  It also looks
  to see it there is another disk down the line with its own MBR.
The MBR makes up a little menu of slices on its own disk and the next
  drive with an MBR, if any.     
Either you select one from the menu or let it take its default.
Then the MBR marks that slice as the latest(current) one booted, loads
  up the boot block and transfers control to it.
The boot block does some housekeeping and causes the system to start.
If you select that next MBR, it does just like the first - lists its
  own bootable slices and a possible next MBR, then loads up what you
  select and transfers control.  You can chain bootable disk this way.

If either the disk's MBR or that slice's boot block are bad in some
way, the boot fails.

Generally, nowdays, most systems commit a whole track to the MBR
and the boot block rather than just the single sector that is officially
called for.   The other sectors are just ignored/wasted.   It is
a trivial amount to waste.   The main reason for doing so (I think) is
it is easier to calculate the addressing on even track or cylinder 
boundaries rather than one sector off.   

But, because of this, there are several third party MBRs out there 
that assume that space will be available and so they use it to create 
fancier MBRs and boot blocks, with more elaborate menu and such.  That 
is nice, but in reality, they ultimately still do exactly what the 
basic MBRs and boot blocks do.    Grub is one of the most well known
of these extended MBRs.

FreeBSD has taken the attitude of being strict about the standard
so it can work with all systems and limits itself to the one sector
MBR and bootblocks.   I have heard some talk of making a FreeBSD
version of extended MBRs and bootblocks, but I don't know if anyone
is really doing it.

////jerry


> 
> Appreciate the clarification
> 
> Cheers
> Jona
> 
> On Fri, Nov 21, 2008 at 8:55 PM, Jerry McAllister <jerrymc@msu.edu> wrote:
> 
> > On Fri, Nov 21, 2008 at 08:03:58PM +0100, Jonatan Evald Buus wrote:
> >
> > > Greetings,
> > > I tried to install FreeBSD 7.0 on an old server earlier today and ran in
> > to
> > > a number of issues related to slicing and labeling the disk using fdisk.
> > > The drive in the machine is a 40GB Seagate Barracude (ST34001A) installed
> > as
> > > a Secondary Master on the IDE bus using LBA.
> > > The BIOS reports that the drive has 16 sectors pr block, but little else.
> > >
> > > When accessing fdisk during install, fdisk complains that the disk
> > geometry
> > > is invalid and sets it to the default geometry for 40GB:
> > > Cylinders: 4865
> > > Heads: 255
> > > Sectors: 63
> > > I've tried with the following configuration based on what was reported by
> > > the BIOS:
> > > Cylinders: 19150
> > > Heads: 255
> > > Sectors: 16
> > > Looking in the manual:
> > > http://www.seagate.com/support/disc/manuals/ata/cuda7200pm.pdf, Seagate
> > is
> > > specifying the following logical characteristic:
> > > Cylinders: 16383
> > > Read / Write heads: 16
> > > Sectors pr track: 63
> > > Which of these settings should be the correct one for the fdisk geometry?
> >
> > Let the system set it and just go with what it does.
> > Geometry is virtual nowdays.   Except in some unusual situations
> > (on IDE) Cylinders, heads and sectors most often do not mean what
> > they used to.   The system drivers have it all figured out.  The
> > important thing for you is the total number of blocks/sectors.
> >
> > If that doesn't work, you will have to do some diagnosis, but in
> > about 10 out of 9 times, accepting how FreeBSD sets it is correct
> > and works.
> >
> >
> > > Additionally I encountered problems during installation if splitting the
> > > disk into more than 4 slices. This would cause the following error to be
> > > thrown during prior to the install files being copied (when sysinstall
> > was
> > > executing the newfs commands):
> >
> > You cannot have more than 4 slices.
> > The system limits you to 4 slices, identified by numbers 1..4
> >
> > Once you divide in to slices, each can be further divided in to
> > up to 8 partitions, although it is really 7 because partition 'c' has
> > special meaning and is not really available to be a real partition.
> > Partitions are identified with alpha letters a..h - with 'c' being
> > used to identify the whole slice.
> >
> > You use fdisk to create the slices (and write the MBR and set
> > the bootable flag).
> >
> > Then you use bsdlabel (formerly called disklabel) to create the
> > partitions within a slice (plus write the slice boot block.
> >
> > Typically, you want to make partition 'a' be the root (/) filesystem
> > and 'b' be swap space on a bootable system slice.   Some things assume
> > these designations.
> >
> > Then you newfs partitions a, d, e, f, g, h or as many as you use.
> > But don't touch c and don't newfs b if it is to be swap.
> >
> > ////jerry
> >
> > > "Error mounting /mnt/dev/X on /mnt/usr. No such file or directory"
> > > Using only 4 slices seems to have solved this error, however I'd like the
> > > disk layout to use 5 slices as follows:
> > > / = 512MB
> > > swap = 2048MB (the machine has 1024MB RAM)
> > > /tmp = 512MB
> > > /var = 2048MB
> > > /usr = whatever remains
> > > I noticed that when having 5 slices, the last slice (/usr) would be named
> > X
> > > rather than ad2s5 as I'd expect (the drive was detected as ad2).
> > > Is this behaviour related to the error in any way?
> > > Also, is the above disk layout good for a server intended to run both a
> > web
> > > server (Apache) and a database server (PostGreSQL) ?
> > >
> > > Finally after installation (using only 4 slices) the system will only
> > boot
> > > if the FreeBSD boot manager is used.
> >
> > That is probably because you have created what is referred to in the
> > documentation as a "dangerously dedicated" disk.   You can make it
> > work that way.  FreeBSD can handle it.   But other systems will not
> > play nicely with it.
> >
> > > This in turn causes a 4 menu options, all of them named "FreeBSD" to
> > appear
> > > during startup despite only the / slice having been set as bootable in
> > fdisk
> > > which appears to be indicated by an "A" in the flag column.
> >
> > Again, because you tried to do it the wrong way.   You created 4 FreeBSD
> > slices, probably each with an MBR and so the BIOS and the first MBR think
> > they are all bootable.
> >
> >
> > > Selecting the first menu item by pressing F1 will make the system boot as
> > > expected.
> > > It seems rather silly though to use a boot manager when FreeBSD is the
> > only
> > > operating system that is installed (and ever will be installed) on the
> > > machine.
> >
> > You can put in the other non-boot manager block during installation
> > if you want and it will only boot FreeBSD.   But, something is needed.
> > I forget what they call it in the sysinstall screen, but you might just
> > as well put in the FreeBSD boot manager (MBR).
> >
> > > If the FreeBSD boot manager is not used however and only the MBR is set
> > > during installation, the system will fail at startup with error "Invalid
> > > Partition Table".
> > > Is this because the harddrive is installed as the Secondary Master on the
> > > IDE bus?
> >
> > No, it is because you did not create any partition table (with bsdlabel).
> >
> > ////jerry
> >
> > >
> > > Appreciate any input on this
> > >
> > > Cheers
> > > Jona
> > > _______________________________________________
> > > freebsd-questions@freebsd.org mailing list
> > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> > > To unsubscribe, send any mail to "
> > freebsd-questions-unsubscribe@freebsd.org"
> >
> 
> 
> 
> -- 
> JONATAN EVALD BUUS
> 
> Executive Vice President Open Systems and Telecommunications
> 
> Mobile US  +1 (305) 331-5242
> Mobile DK  +45 2888 2861
> Telephone  +1 (305) 777-0392
> Fax.          +1 (305) 777-0449
> jonatan.buus@cellpointmobile.com
> www.cellpointmobile.com
> 
> CellPoint Mobile Inc.
> 4000 Ponce de Leon Boulevard
> Suite 470
> Coral Gables, FL 33146
> USA
> 
> 'Mobilizing the Enterprise'
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"



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