Attempting to Dual Boot Arch-Linux with FreeBSD 10

Hello FreeBSD community!

I have been attempting to successfully dual boot my current Arch Linux install with the new FreeBSD I want to add to it. I will begin with listing my hardware situation. This is a new computer I recently got, running an Intel i5-4660. I currently have two drives installed in it. One of them is a 1 TB hard disk drive with only Windows 8.1 installed on it. The other disk is an SSD (formatted to GPT), and that's the one which currently has an operable Arch Linux install on it. The BIOS is the new UEFI.

I currently have four of the first partitions dedicated to Arch in this order: 40GB for /, 12GB swap, 60GB /home, 512MB /boot. All the partitions are listed in the actual order.

When I did the install (for Arch Linux, a little while ago) I followed the Arch Linux wiki for getting it to work and all was fine until I started playing with FreeBSD. At first I installed the new OS and I created many partitions (mostly for the fun of it) following the instructions in the handbook. So on the same disk following the fourth partition of Arch I currently have: 512KB /boot, 20GB /, 4GB swap (yes, now I know that I could have just used the swap I have already created), 10GB /var, 2GB /tmp, 20GB /usr, 40GB /home (and yes now I have learned that I could just have used the home I created for Arch).

So after partitioning and being surprised at how simple the installer made it out to be in the end, I rebooted, not knowing what the outcome of that would be. At first it booted me right back into Arch Linux, I rebooted again and went into the BIOS to see if I'm able to manually specify to boot into FreeBSD, obviously I couldn't. I was running some simple boot loader on Arch, so I removed it and installed a more robust grub2. With grub2 now in place, I searched the web to see how I could add a new entry to the boot screen, therefore I now have this in my /etc/grub.d/40_custom. (And yes I did remake the grub config after saving this)
Code:
menuentry "FreeBSD" {
	set root=(hd0, 5)
	chainloader +1
}

This added a new FreeBSD entry to the GRUB selection screen, but every time it would say hd0 not found. After this experience and looking around the web for a few hours I have a few questions and am in need of help.
  1. How does the automatic installer handle sharing swap between Linux and FreeBSD? I didn't see an option to specify that? And the same thing for /home partition sharing, I'm not really certain how I would share them between the OSs.
  2. Since I need to create this weird configuration, will the installer know how to generate the fstab correctly?
  3. I'm confused on the difference between an EFI partition and a /boot partition. I understand that the /boot contains the kernel and everything that is needed by the boot-loader to bootstrap the OS into the memory or something along those lines. And on my Linux /boot partition is also where the boot-loader itself is installed I believe (or its configuration files) and also the whole /boot partition is recognized as a EFI System partition, instead of the normal /boot or at least just a Linux data partition. So this distinction is very confusing and is not helping me. I read that the BIOS at first executes the first 512 bytes on the disk to determine the partition table and I guess where the boot loader is located? Well, for some reason, the first 32 sectors of my disk are in use by something, and the sector size is 512 bytes so something is definitely bigger in there. I might have activated something when I was partitioning the drive initially for Arch, because gdisk tells me that GPT fdisk (gdisk) version 0.8.10

    Code:
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    
    Command (? for help): p
    Disk /dev/sda: 488397168 sectors, 232.9 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): CB34316F-F57A-45F4-A0C1-B7208388E6E6
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 488397134
    Partitions will be aligned on 2-sector boundaries
    Total free space is 51139885 sectors (24.4 GiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1              34        83886113   40.0 GiB    8300  
       2        83886114       109051937   12.0 GiB    8200  
       3       109051938       234881057   60.0 GiB    8302  
       4       234881058       235929633   512.0 MiB   EF00  
       5       235929634       235930657   512.0 KiB   A501  
       6       235930658       277873697   20.0 GiB    A503  rootfs
       7       277873698       286262305   4.0 GiB     A502  swap
       8       286262306       307233825   10.0 GiB    A503  varfs
       9       307233826       311428129   2.0 GiB     A503  tmpfs
      10       311428130       353371169   20.0 GiB    A503  usrfs
      11       353371170       437257249   40.0 GiB    A503  homefs
    (I include all of this, it might help) And also what exactly mounts the EFI system partition? I'm just really cloudy in this area, and I want to better understand this whole process so If I can be directed in the right direction or somebody clarify this to me I would be immensely in debt.
  4. Does FreeBSD automatically install its bootloader in the /boot?
  5. The filesystem for the /boot is freebsd-boot, I'm not sure if that's the UFS, since I was not able to mount the FreeBSD's /boot running Arch Linux.
I'm very confused on the whole topic and I really want to get this FreeBSD going and I can't wait to read into the handbook everyone touts as great :) Hopefully I provided enough information for somebody to understand my situation and help me out in the end. If I forgot to state something feel free to probe me for more info.

-alex
 
Make that
Code:
menuentry "FreeBSD" {
  set root="(hd0,gpt5)"  # GPT partition 5
  kfreebsd /boot/loader
}
 
I tried your suggestion, but when selecting the FreeBSD option in GRUB it told me:
Code:
error: no such partition
Which is strange considering that I'm very certain that there is such a partition.

-alex
 
There is a bunch of confusion here, so let's clear up some of it:

There are two major disk partitioning schemes. MBR, the old crappy standard, and GPT. You are using GPT, which is good.

FreeBSD generally does not use a partition for /boot. Instead, the freebsd-boot partition seen here is to contain the boot loader. It has no filesystem, so there is no way to mount it. This is different from the files in /boot, which is usually in /, or the partition called "rootfs" shown here.

The first block on the disk is traditionally a 512-byte boot block. On GPT, this is a sort-of fake "protective" MBR, to keep the old BIOS from messing with GPT partitions it does not understand. When booted, it transfers control to the bootcode in the freebsd-boot partition, which then looks for a bootable UFS partition.

Grub2 uses a different naming system for GPT partitions.

You also said you had two drives, so the one with FreeBSD might actually be hd1 or even hd2. Grub numbering has not always been consistent.
 
Interesting, I see what you are saying, and I assume Linux does it the same way for the boot thing? But how does the EFI partition thing play into this game?

By the way, I guess I didn't need to make the freebsd-boot at all then, since I already have the partition that mounts on /boot in Arch, which I guess has grub2 on it?

I tried the things that you proposed and I finally got the right "address". Changing it to hd1 and then going into the 6th partition did the trick(since the 6th partition is the one with /). But not I have a new problem: I get this text(part of it, I think the first letter on each line is cut off)
Code:
onsoles: Internal video/keyboard
IOS 630kB/3310592kB available memory

reeBSD/x86 bootstrap loader, Revision 1.1
root@snap.freebsd.org, Thu Jan 16 22:18:05 UTC 2014)
an't work out which disk we are booting from.
uessed BIOS device 0xff not found by probes, defaulting to disk0:

an't load 'kernel'

ype '?' for a list of commands, 'help' for more detailed help.
OK
And I can't type a single thing. The keyboard is completely unresponsive which is strange... again. So any clues what might be causing this now?

-alex
 
zisilius said:
Interesting, I see what you are saying, and I assume Linux does it the same way for the boot thing? But how does the EFI partition thing play into this game?

It doesn't matter to us, as far as I know. You will still be booting in "legacy" mode. The EFI partition is there for custom code, presumably to run in the setup screens.

By the way, I guess I didn't need to make the freebsd-boot at all then, since I already have the partition that mounts on /boot in Arch, which I guess has grub2 on it?

It's possible that Grub2 can replace the need for FreeBSD's gptboot(8). However, it's important to remember that FreeBSD is different. It's not just a funny-looking Linux, but does many things differently.

I tried the things that you proposed and I finally got the right "address". Changing it to hd1 and then going into the 6th partition did the trick(since the 6th partition is the one with /).

It should be possible to chainload to the FreeBSD bootcode in partition 5. I'm not sure how to do that with Grub2, although there are probably web references for it.
 
Back
Top