I've been using FreeBSD for almost an year now, and Linux dual-booting all this time. First along with Arch Linux, then replaced it for Ubuntu 16.04 last october.
I normally do my partitioning with gparted live but read that it won't work with BSD
You'll need unpartitioned space on which FreeBSD will be installed. I suppose you don't have free space for no reason so you'll shrink some of your Debian partitions. GParted will do this just fine (I used it myself). Now you do have some free space. Suppose Debian is partitioned like this:
/dev/sda1 (/)
/dev/sda2 (/home)
/dev/sda3 (swap)
And that the disk is full. Then something has to be shrinked. Let's say you shrink each of them to half its original size, then allign them to the left. That could be troublesome as moving and resizing partitions should be done with caution. You can easily Google about this matter. After that, you'll end up with something like:
/dev/sda1 (/)
/dev/sda2 (/home)
/dev/sda3 (swap)
Unallocated Free Space
From this point onward GParted will be of no use. Download FreeBSD image from the website and burn it to a pendrive. Boot from USB so to run the
bsdinstaller. Proceed to the partitioning step. Four options will be presented. Choose "Manual". Now it depends whether you have GPT or MBR. If you have GPT I probably forgot a /boot partition in the aforementioned scheme. I do have MBR so that's what I can help you with
a priori. Once you select "MBR" you'll have your current partitioning on screen:
- ada0 MBR ---> you can think of that as the Linux sda equivalent
- ada0s1 ext4 ---> that's first slice on ada0 disk, therefore ada0s1. It's basically what Debian called /dev/sda1
- ada0s2 ext4 ---> likewise, for /dev/sda2
- ada0s3 linux-swap ---> "former" /dev/sda3
You'll also have an amount of free space under ada0. use the arrow keys to select it, then "create". "Type" will be "freebsd", as indicated. "Size" can be the whole free space unless you have plans for a triple-boot anytime soon. Leave the "mountpoint" empty and "OK".
There you go: ada0s4 was created, with a "BSD" label before it. Select it and you'll notice you can partition the slice itself. That's the "tricky" part I suppose, but you just have to remember that the BSD slice can be further partitioned whereas the other can not (or, at very least,
should not).
For your first partition "under" ada0s4, let's have the root. Change the size accordingly and type "/" as the mountpoint. The partition type is "freebsd-ufs". Once you're done you'll have an ada0s4
a. That is:
- ada0 disk
- fourth slice, which is also a BSD label
- partition 'a' where you'll mount the root
Repeat the process but choose "/home" as the mountpoint. I think you know what I mean and, this time, you'll have added ada0s4
b. Its type is "freebsd-ufs" as well. As for the size, leave some room for the swap (hint: you can just forget about it then manually set up Debian swap partition as swap editing
/etc/fstab). This last partition has a "freebsd-swap" type and its mountpoint should be left blank. It maybe skips a letter (e.g. being ada0s4d instead of ada0s4c) or at least it does in my computer, but makes no difference. Once you have all these created, go to "finish" then "commit". Proceed with the installation normally.
Now there is a little problem: you'll need a second USB stick with a copy of GRUB installed on it. The point is, you'll have the BSD bootloader overwriting GRUB. You can try skipping it and having GRUB probe FreeBSD without this step but I couldn't do it. Therefore, you'll need to select "yes" at the very end, when the installer asks if you want to open a shell to perform further modifications before reboot. Once in the shell, enter these two commands:
Code:
boot0cfg -B ada0
gpart bootcode -b /boot/mbr ada0
Then reboot. You'll see BSD bootloader, but won't have your Debian. In order to fix this, boot from the USB stick having the GRUB copy. Beware the copy will switch disks labeling and you'll have to Google about booting from GRUB prompt. Once you've done it, there's a last piece of work to do: modify GRUB configuration files so to add freebsd as an option and recognize it. Debian is fond of
os-prober
but that alone won't do the job. You must edit the files yourself, then grub will probe "an unknown linux at /dev/whatever". Provided that:
- This "unknown linux at /dev/something" is probed;
- You edited correctly the files so to add a freebsd entry at the menu and its parameters for chainloading are also correct;
- grub was reinstalled to /dev/sda (
# grub-install /dev/sda
) and reconfigured (# grub-mkconfig -o /boot/grub/grub.cfg
)
There you have it: a Linux/BSD dual-boot.
I know it sounds confusing but it's not really that hard. Even if you have a GPT scheme, consider using this as a starting point. I'm sure it's just as possible.
Good luck.