Dual and Multi Booting FreeBSD, Linux, and OpenBSD
with GNU Grub
Of the three operating systems discussed here, FreeBSD has the most
robust and flexible partitioning software and the greatest flexibility
of where it can be placed. FreeBSD's fdisk can
detect and display four slices as well as the disk boot sectors and
any unused space if the slices have not consumed it all. Fdisk can
delete any disk partition it sees and can put a slice into any free
space, up to the four permitted. If the first four partitions leave
sufficient free space, fdisk appears to create a fifth if you try, but
the name is an 'X' instead of a valid device name such as 'ad0s4', the
last valid partition on the first hard disk.
One weakness of the FreeBSD install is that it provides no "Back"
options. You can press [Ctrl+Alt+Delete] at any time during a FreeBSD
install, and the install process will give you a choice of Abort,
Restart, or Continue which do what you'd expect. Abort immediately
drops you out of the install and reboots the system. Restart puts you
back at the begining of the install; any choices you've made are lost.
Continue returns you to where you were.
Neither FreeBSD's fdisk or disklabel write any changes to the disk
until you have selected a distribution to install, such as Developer
or User and begun to install the software. Unlike choices in Linux's
fdisk or either OpenBSD's fdisk or disklabel, all of which require
pressing enter to activate a selection after an option key has been
pressed, FreeBSD's disk partitioning tools use hot keys. As soon as
you press a key the corresponding action is taken.
Though the use of "OK" and "Cancel" is sometimes confusing in the
FreeBSD install, it's hard to get much simpler or reliable than
FreeBSD's fdisk and disklabel programs. When you enter fdisk, if
you're starting with a clean disk there is a single highlighted line
indicating the total free space. Regardless of how the disk may
already be partitioned, pressing 'a' immediately deletes any existing
slices and creates a single FreeBSD slice occupying the entire hard
disk. If slices are defined you can use the up and down arrows to
highlight one. Pressing 'd' deletes that partition and makes this
space available. If contiguous slices are deleted or a slice next to
free space is deleted the free space is combined.
When any line describing free space is highlighted, pressing 'c'
starts the dialog to create a slice. The number of available sectors
is displayed, and if you press enter, all available space is used by
the new slice. If the disk were empty, the slice would fill the disk.
If the free space was between two existing slices, the new slice would
fill the space between the existing slices.
You may reduce the size to make two or more slices from the available
space. The prompt indicates that you may change the numbers from
sectors to megabytes by entering a number followed by an 'm' but 'g'
for gigabytes also works. After entering the slice size, you are
prompted for type, defaulted to 165 which is a FreeBSD slice in
decimal. FreeBSD accepts slice types only in decimal notation. Only
the following are needed for OpenBSD and Linux: 166 = OpenBSD, 131 =
Linux files, 130 = Linux swap, and 5 = extended. If you are starting
a dual or multi boot install, you can and should use FreeBSD to
allocate the slices for the others.
You can use 'z' to toggle the size display from the default sectors to
kilobytes or megabytes.
When you've finished allocating slices, use 'q' to leave OpenBSD's fdisk.
No changes will be made to the disk but your choices are saved in memory
until they are needed. If you restart a FreeBSD install, you will
need to repeat the hard disk partitioning.
Following fdisk is FreeBSD's boot manager prompt. The default is to
install FreeBSD's boot manager. Options to install a standard MBR
with no boot manager or to make no changes to the MBR are also
provided. FreeBSD's boot manager is pretty decent. It will recognize
Linux and OpenBSD primary partitions and create entries for them in
its list of systems to boot. It does not recognize a Linux system
installed entirely into an extended partition without a separate
primary boot partition and it doesn't recognize a second FreeBSD
system installed into the same slice as another as bootable. More
specifically it appears to recognize the partition with a device name
that ends in "a", such as ad0s1a, as bootable. There do not appear to
be any configuration options that will allow it to boot more than one
partition in a slice or boot a partition inside an extended partition.
GRUB which was first developed as an extension of FreeBSD's boot
loader, before it was rewritten, has these capabilities.
FreeBSD's boot manager works well when there are 2 to 4 FreeBSD
systems, each installed into its own slice or 1 to 3 FreeBSD systems
with one OpenBSD system. It will also work with a Linux system
installed the "standard" way with the boot partition in a primary
partition. In each of these cases, it will automatically be set up
correctly, for those partitions that exist at the time it is
installed. After the first use, the FreeBSD boot loader records which
system was last booted and uses that as the default on the next boot.
The first time it's used, whatever system is in the lowest numbered
primary partition is the default. GRUB can also be configured to use
the last loaded system as the default. See FreeBSD's "man boot0cfg"
for instructions on configuring FreeBSD's boot loader.
If the system being installed with FreeBSD is already setup with GRUB,
then you should change the default form installing FreeBSD's boot
loader to "None" so as to make no changes to the MBR. If you'll be
installing more than one FreeBSD and or OpenBSD system before Linux,
then install the FreeBSD boot manager and replace it with GRUB when
you install the first Linux system. A standard single system, FreeBSD
install, would normally use a standard MBR without a boot loader.
After the boot manager prompt is disklabel. The FreeBSD disklabel
program, shows only FreeBSD slices, ignoring slices set up for and the
internal details of any other operating system install. The top of the
screen will be one or more lines listing every FreeBSD slice in the
system. Use the up and down arrows to highlight a slice. If a
highlighted slice has free space , you can press 'c' and start a
dialog that prompts you for the amount of space to allocate. Like
slices, this defaults to sectors, but can be entered in megabytes or
gigabytes. After providing the size you are prompted whether the
partition should be a file system or swap partition. If you select
the default file system, you are prompted to provide a mount point.
If you don't enter a mount point no partition is created.
If you've made a mistake while creating a new partition, you can press
the Escape key or select cancel at the next prompt to abandon the
partition without creating it. If you do create a partition you don't
want, just delete it. If you delete a new partition that you
wanted, just recreated it.
If you accidentally delete a partition from a previous install, this
can be undone, but not without some difficulty. Pressing 'u' to Undo
in FreeBSD's disklabel will prompt you to confirm that you're "SURE
you want to Undo everything". If you continue with undo, it will undo
all your disklabel and fdisk changes and return you to fdisk as it was
when you started the install program. You will need to repeat any
slice changes you made, repeat your boot manager selection, and redo
any disklabel changes that you might have made.
With FreeBSD 5.0 and 5.1 an new UFS2 file system has been introduced
as the default file system. As Nov. 2003 Grub does not support and
cannot start a FreeBSD system booting from a UFS2 partition. There are two or possibly
three work arounds for this problem. The disklabel program for 5.1 allows
allows the UFS type to be toggled by pressing the "1" or "2" key.
These are not listed in the available options, but on any partition
marked for a new filesystem, pressing 1 toggles it it to UFS1 which
Grub can boot. Pressing 2 returns it to the default UFS2.
Using UFS1 will obviously sacrifice whatever benefits prompted the
development of UFS2. This may not be significant on a test or
experimental machine implied by a multiboot system. One approach is
to create a small /boot partition as UFS1 with most of the system installed
into one or more larger UFS2 partitions. This will obviously reduce
the number of possible systems, if you are doing a many boot system,
but otherwise is probably the best solution. Some of the posts archived
at mail.gnu.org seem to suggest that some
variation of the chainloader command will work with UFS2, but my
limited experiments with this were not successful. I chose a single
large UFS1 partition which worked fine.
On new partitions and those marked to be formated with the newfs flag,
there is an obscure option available. This is the "toggle
Softupdates" option. This is an option that on most file systems will
increase speed quite significantly for some disk operations, while
also improving disk integrity. This sounds like a contradiction but
there is significant research
to support its validity. Softupdates are BSD systems' response to
journaled file systems. See the bottom of the F1 help for more
information. The help suggests that small "/" file systems should not
use softupdates and explains why.
If a previous FreeBSD install created a swap partition, there is no
need to create a new one. The install will recognize and
automatically use the existing swap partition. Since we are
discussing multi boot systems, the performance issues of a swap file
that may be somewhat too small or not physically close to the current
system should not be important. If you are building a system where
arrangement of partitions for performance issues is a serious
consideration, you shouldn't be doing this on multi boot systems and
thus don't need to be reading this. Any system that's important
enough to warrant performance tuning should not be part of a multi
FreeBSD allows up to seven partitions per slice. Like FreeBSD's
fdisk, disklabel uses a 'X' instead of a valid partition name such as
'ad0s1a' if you create too many. If you do create an 'X' partition,
you need to delete it because disklabel will let you continue. A
system installed into disk partition with more than seven FreeBSD
partitions will not complete the boot sequence. Instead it displays
error messages and drops into single user mode. /etc/fstab will be
created containing the mount points given disklabel, but for the 'X'
devices, no valid devices to mount these file systems exist. You must
edit /etc/fstab to remove the invalid file system entries before the
boot sequence can complete. This is almost exactly like Linux's
Disk Druid creating excess invalid partitions.
FreeBSD's disklabel will let you create a new device or partition in
any FreeBSD slice that has physical room and one or more available
partition letters. To install a new FreeBSD system, you must create a
new '/' file system at a minimum. If you do this in a slice with an
existing '/' partition the previous system will become inaccessible.
You can normally tell that there is a previous '/' mounted in the
current slice, if any existing partition name ends in an 'a'. If
you're working on disk ad0 in the slice 2, i.e., ad0s2, and there is
an ad0s2a partition in the left column, that is a previous system's
'/' file system. If you create a new partition and mount '/' on it,
the old system's root device will be renamed to another partition name
if there are any available letters between 'b' and 'h' (except 'c').
If you make a note of this new letter you can adjust GRUB's
configuration to point to this as a bootable system. Since the new
system has replaced the previous one in GRUBs nomenclature, it will
already be configured in GRUB. To successfully complete a boot of the
old system, you will need to start the new system, mount the old
system's root device and edit the file that was /etc/fstab on the old
system. Simply change the 'a' in the old device name that '/' mounts
on to the new name, and the old system will be bootable again,
assuming you have not deleted the necessary pieces with fdisk or
If there are no available letters when you make a new "/" system, then
the old root partition name will become 'X'. If an 'X' partition is
created and allowed to remain, the disk space it occupies will not be
accessible to any FreeBSD system because there is no valid device
which can be used to access it. It should be deleted and the space
made available. This will of course destroy the previous system. If
it had separate file systems for /home or other areas where you had
data you wish to preserve, these can be mounted without initializing
the file systems either via disklabel or manually after starting the
In addition to creating new partitions from free space, disklabel will
let you make use of existing partitions from previous FreeBSD
installs. 'm' will let you specify a mount point. You can for example
share a large /tmp partition between multiple systems. The 't', toggle
newfs, will cause an existing partition to be initialized as if it
were new. This effectively takes the partition from the previous
system but unless the old system's /etc/fstab is cleared, the old
system will try to mount a file system on the device initialized by
the new install. If you toggle newfs by mistake, toggling again won't
undo the change, but pressing 'm' then canceling will undo the newfs
option; if you don't plan to mount a file system, you don't plan to
You can also create large swap and /tmp partitions in a FreeBSD slice
near the middle of the disk and share them among any and all FreeBSD
systems on the drive. The install will automatically recognize and
use any existing swap partition from a previous FreeBSD install. To
use the shared /tmp you might recognize it by its size or simply make
a note of the partition name when it's created. After the first system
is up an running, mount or df will display the /tmp device name. After
creating a shared /tmp in the first installed FreeBSD system, you can
use disklabel's 'm' option to mount the existing partition in the new
Four independent FreeBSD installs on the same disk is simple and I've
created multiple quad boot systems including two FreeBSD systems.
With assistance from GRUB, the maximum number of bootable FreeBSD
systems on a single disk is the number of FreeBSD partitions that can
be created by fdisk and disklabel (28) less one for a swap partition
or 27. It's clear that on a 30GB drive you could allocate one 1GB swap
partition, then install 7 separate, 1GB, single '/' file system
systems in each slice except the one with the swap partition which is
limited to 6.
FreeBSD's boot loader might not be able to load these, but GRUB can.
It's just a matter of specifying a - h (less c) as the BSD disklabel
subpartition in grub.conf. To prevent disklabel from dynamically
renaming devices when a new "/" is mounted, assign all the devices
when the first system in the slice is created. Start with '/' then
continue with "/two" up to "/seven" if this slice doesn't have the
On subsequent installs, highlight the non swap partitions, toggle
newfs, and assign the mount point as '/'. Depending on how many
systems like this you are planning, and how soon you will create them,
you may if it seems efficient, create all the GRUB entries at the same
time because you will know in advance what device letters you will be
using. If perhaps you created /home, /usr/local, or /tmp file systems
that you will be sharing between systems, the devices these are
mounted on would not be entered into GRUB because they will never be
bootable. You would also avoid the newfs toggle to preserve existing
data on such partitions.
Do not simply mount '/' on an existing partition without toggling the
newfs flag. The install will fail because without the newfs flag, the
devices won't exist and will not be created. Device creation is part
of the newfs processing if a '/' file system will be mounted.
Once you've created all the partitions and assigned mount points for
your new FreeBSD system, 'q' will take you to the next step of the
FreeBSD install which is the distribution selection. Except for
perhaps time setup, the remainder of a multi boot install is like any
other FreeBSD install.
If you are installing FreeBSD in a system with OpenBSD, when you set
the time, tell it the system (CMOS) clock is using UTC time. OpenBSD
insists on this, and if you don't set this in FreeBSD, the FreeBSD and
OpenBSD will display different local times, unless your time zone
happens to be GMT.
Top of Page -
Copyright © 2000 - 2012 by George Shaffer. This material may be
distributed only subject to the terms and conditions set forth in
These terms are subject to change. Distribution is subject to
the current terms, or at the choice of the distributor, those
in an earlier, digitally signed electronic copy of
http://GeodSoft.com/terms.htm (or terms.pl) from the time of the distribution.
Distribution of substantively modified versions of GeodSoft content is
prohibited without the explicit written permission of George Shaffer.
Distribution of the work or derivatives of the work, in whole
or in part, for commercial purposes is prohibited unless prior
written permission is obtained from George Shaffer. Distribution in
accordance with these terms, for unrestricted and
uncompensated public access, non profit, or
internal company use is allowed.