# Dualboot with 2 FreeBSD installation



## ericc (Mar 11, 2014)

Hello 

I have probably a stupid question. 
If on a machine I install 2 different version of FreeBSD on 2 different partition (slice?). Let say : FreeBSD 8.4 on partition 2 and FreeBSD 10.0 on partition 3 (partition 1 is the boot)

Do I have something special to do to have the choice between the 2 at boot time ? (in the menu)
How can I define the default one ?

ericc


----------



## SirDice (Mar 11, 2014)

There are no stupid questions, only stupid answers 

No, there shouldn't be anything special needed. You do need the FreeBSD bootmanager boot0cfg(8) but it should work. It's also possible to share one swap partition between the two.

Mind you, you can't use ZFS this way, the bootmanager doesn't understand it. In that case you should have a look at sysutils/beadm.


----------



## ericc (Mar 11, 2014)

Thanks for the fast answer !



			
				SirDice said:
			
		

> No, there shouldn't be anything special needed. You do need the FreeBSD bootmanager boot0cfg(8) but it should work. It's also possible to share one swap partition between the two.


This is what I believed to have understood when I read the documentation of bootcfg, but I would like to be sure

So I will have the possibility to choose directly in the boot menu ?!
And how do I select the default one ? (the one to boot if I didn't press anything)



			
				SirDice said:
			
		

> Mind you, you can't use ZFS this way, the bootmanager doesn't understand it. In that case you should have a look at sysutils/beadm.


Well, I have no special need to use ZFS anyway ...

ericc


----------



## SirDice (Mar 11, 2014)

ericc said:
			
		

> So I will have the possibility to choose directly in the boot menu ?!


Yes, you get two options, both FreeBSD and you press F1 or F2.


> And how do I select the default one ? (the one to boot if I didn't press anything)


It's been a while since I used it but last time I used it it booted whatever was chosen the last time if you didn't press anything. I'm not sure if you can set a fixed default.


----------



## ericc (Mar 11, 2014)

Ok, thanks

I will try, will see if I have a problem a this moment   

Thanks for your time 

ericc


----------



## ericc (Mar 13, 2014)

Finally it doesn't work ! 
I installed first 9.0 on one partition and 9.2 on a second with following setup:
ada0p1 -> swap (I always put the swap partition at the beginning of the disk as its the fastest part)
ada0p2 -> boot
ada0p3 -> FreeBSD 9.0
ada0p4 -> FreeBSD 9.2 

After installation of 9.2, I rebooted and I couldn't choose anything else than 9.0!!!

Also, I absolutely need to be able to set the default partition (before reboot), as the machine is a headless server that I operate remotely.

ericc


----------



## wblock@ (Mar 13, 2014)

The FreeBSD multiboot loader (boot0) only works on MBR disks.  Partitions named with a "p" like ada0p1 show that the disk uses GPT partitioning.

If you must use GPT partitioning, another multiboot loader must be used.  Grub can do it, and I think there are articles here that show how.

On the other hand, there is not much difference between FreeBSD 9.0 and 9.2, and it might be easier to just combine them than to mess with multibooting.


----------



## tingo (Mar 13, 2014)

Multibooting with gpart() isn't very difficult; i do it all the time. Here is an example:

```
root@kg-v7# gpart show -p ada1
=>       34  250069613    ada1  GPT  (119G)
         34        128  ada1p1  freebsd-boot  (64K)
        162   62914560  ada1p2  freebsd-ufs  (30G)
   62914722    8388608  ada1p3  freebsd-swap  (4.0G)
   71303330          6          - free -  (3.0K)
   71303336   62914560  ada1p4  freebsd-ufs  [bootme]  (30G)
  134217896  115851751          - free -  (55G)
```
This disk has FreeBSD 9.2-stable on ada1p2, and FreeBSD 10.0-release on ada1p4.
Currently the machine is running from ada1p4:

```
root@kg-v7# uname -a
FreeBSD kg-v7.kg4.no 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014
     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
root@kg-v7# df -h
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada1p4     29G    3.3G     23G    13%    /
devfs          1.0K    1.0K      0B   100%    /dev
```
Now, if I want to boot into ada1p2, I set the bootonce flag on that partition: `# gpart set -a bootonce -i 2 ada1` and reboot the machine.
On any boots after that I'm back into ada1p4 unless I do anything else with the boot flags first.
This work for any number of partitions, quite handy for testing out various versions of FreeBSD. Seen the gpart(8) man page for more details.


----------



## ericc (Mar 13, 2014)

tingo said:
			
		

> Now, if I want to boot into ada1p2, I set the bootonce flag on that partition: `# gpart set -a bootonce -i 2 ada1` and reboot the machine.


This could be indeed the good solution for me. 
I will check this tomorrow, I will be near the machine, so if something goes wrong ...  :OOO 



			
				wblock@ said:
			
		

> On the other hand, there is not much difference between FreeBSD 9.0 and 9.2, and it might be easier to just combine them than to mess with multibooting.


Unfortunately, this is not as simple ! 
This machine is supposed to run a software which was tested only on FreeBSD 7.2 and the development is stopped since 1 or 2 years, so I can't ask for support.
At first, I installed FreeBSD 10.0, but I had a lot of trouble that I was unable to solve.

Now I reinstalled completely the machine with 9.0 and everything seems to works fine. 
So before updating to 9.2, I want to test everything and be sure that it will not broke anything (or my boss will kill me  :\ )

Thanks to have reformatted my message (bad habits  :r )

ericc


----------

