This is just to show not much have changed over the last 15 years as far as booting is concerned.

The needs
I am assembling a server for FeeNAS in a new PC with the Ryzen 1900 Threadripper with 64GB ram. FreeNAS is basically a terminal operating system although a fair amount of work can be done by it GUI web page. Most of the work like files transfer is done by NFS share which typically is to allow a Linux within the same network to mount its ZFS filing system so the files can be move around in the desktop environment. That is why I need a Linux to start with.

The Ryzen 1900 is new to me so to ensure I can check latest support, say for some drivers, I need Windows access.

FreeNAS uses ZFS filing system which is the best filing system I have come across. Linux supports ZFS so there is no problem to mount it over the network but the gigabit transfer rate gives 1000/8 or around 120MB/s maximum and typically I only get about 60 to 80MB/s transfer speed normally. Thus copying a 8TB hard disk needs 8,000,000/60 = 133,333 sec or over 1.5 day! My server has 5x8TB so I do have a big problem when it comes to back up. FreeNAs is based on FreeBSD which allows the user install Gnome. My plan is to do the file transfer internally with a computer case that can accommodate 16 hdd bays. Thus I need a FreeBSD too. Internal bus can stretch a hard disk to the 200MB/s speed as quoted by the manufacturer. With a Raid set-up the speed can be even faster.

I am using a M2 SSD with 525GB (yes Crucial does offer 10GB more than the stanard 512GB). The intention is to have 150GB for each of the 3 systems.


Windows 10 to be installed first

I installed Win10 first. Was thinking of using GPT which both Linux and FreeBSD have no problem. However Windows prefers MSDOS partition table citing my SSD isn't large enough for GPT. So MSDOS partition table work fine eventually with a bit of trial and error. The reason is both Windows and FreeBSD can only be installed in primary partitions and a MSDOS partition table has a maximum of 4 primaries. Windows needs a system-reserved (sda1) plus its own (on sda2) , BSD has to have one (sda3) leaving the 4th partition as the extended partition (sda4) in which I created sda5 (150GB) for Linux and sda6 for the swap partition. There is a small reminder of the hard disk space left.

Windows 10 installer as usual use the entire disk for Windows installation. That is fine by me because once installed I used its "Disk management" software to shrink the sda2 back to 150GB. Thus after the Windows 10 installation I have its boot loader siting inside the MBR and with 375GB unallocated space inside my 525GB SSD.

LinuxMint to be installed as the 2nd systm

I booted up the Mint installation CD and ran it as a Live CD first to use a terminal command of FDISK to create sda3 as 150GB primary partition of Type a5 for FreeBSD and then the rest as sda4 as the extended partition. Inside the extended partition I specified 150GB for sda5 as Type 83 for Linux. Lastly I used 1GB sda6 as Type 82 as swap. Here is my partition table.

saikee@saikee-Ryzen ~ $ sudo fdisk -l
[sudo] password for saikee: 
Disk /dev/sda: 489.1 GiB, 525112713216 bytes, 1025610768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xaced7000

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2048   1026047   1024000   500M  7 HPFS/NTFS/exFAT
/dev/sda2         1026048 308807679 307781632 146.8G  7 HPFS/NTFS/exFAT
/dev/sda3  *    308807680 623380479 314572800   150G a5 FreeBSD
/dev/sda4       623382526 940054527 316672002   151G  5 Extended
/dev/sda5       623382528 937955327 314572800   150G 83 Linux
/dev/sda6       937957376 940054527   2097152     1G 82 Linux swap / Solaris
In the above sda1 was created by Windows installer. I just used Windows' own system software to squeeze the space for other systems. This is the quickest and the neatest way.

I then clicked the LinuxMint installer icon and told its installer to use sda5 to mount as /, format to ext4 and went for a cup of tea.

When I returned with my cup of tea LinuxMint as expected arranged to dual boot both systems. This is because every Linux installer must check every partition and include it for booting if a boot loader is found. This is how Grub2 become so powerful and successful in PC operating system. I didn't have to lay a finger for this to happen.

Lastly install FreeBSD

I installed FreeBSD pretty much the same way I installed Windows or LinuxMint. FreeBSB installer did not like the sda3 I arranged and instructed me to delete it and then re-create it with the help of the installer (most installers do not trust us to get it right!) FreeBSD installer does not want me to mount the partition for / citing it will have more than one sub-partition inside and I should leave the rest to the installer.

The installation was straight forward but like I expected the installer did not modified Grub2. Thus my FreeBSD does not boot upon completion of the installation. I could only run two OSes then.

Grub2, Grub2 I love you

For years of using Legacy Grub and Grub2 I know most operating systems when being installed into a multi-system PC would not know how to arrange the multi-boot. Each will by default leave the boot loader installed inside the boot sector of the system partition. In the FreeBSD it is in sda3 or the third partition.

Grub, both Legacy version and the current Grub2, can boot any installed operating system manually. It operates like a mini operating system with a rich set of commands sharing a lot of similarities as the BASh terminal. All it takes is when being present with a Grub menu to boot systems, don't select any but press the "c" key as indicated by the boot menu. This drops the user into a Grub prompt.


Just like BASH the above command ls will display all the partitions and disks available. The Grub convention for a partition is (hd0,msdos2) for MSDOS partition table and (hd0,gpt3) is the disk has been partitioned with gpt. The first number is for disk starting with zero. Partition number on the other hand always starts from 1.

ls (hd0,msdos3)

The above command instruct Grub to tell us the details of the partition. Among its uuid number which is needed if we boot a Windows partition Grub will tell its filing system. For FreeBSD it is ufs filing system so I now have confirmation (hd0,msdos3) is my FreeBSD system needed to be booted. I fire it up by the following commands in the Grub prompt one line at a time.

set root=(hd0,msdos3)
chainlaoder +1

Last piece of the jigsaw

I don't want to manually boot FreeBSD every time so I fire up LinuxMint and added these lines to /boot/grub/grub.cfg using a terminal command like "sudo nano /boot/grub/grub.cfg"

menuentry 'FreeBSD 11.1 (on /dev/sda3)' {
set root='hd0,msdos3'
chainloader +1

Now my Grub menu boots all three systems.

If you need explanations here they are

(1) MS Windows is a selfish system that does not support/recognize/co-exist with other OSes. It will nuke everything in its sight wanting the user to use no other system except itself. So let it have its dream by installing it first. Then take the hard disk space back.

(2) Use Linux's Grub to controlling booting. Linux will always and automatically dual boot MS Windows unless you point a gun at its head. Managing Grub is just editing a text file which is always the /boot/grub/grub.cfg

(3) In chainloading technique Grub simply puts another operating system's boot loader into the memory and bugger off itself.

(4) In the above 3 systems each of MS Windows and FreeBSD has its own bootloader inside the system partition. Grub can also do the same but Grub2 discourages such move saying the method is not always reliable. In Legacy Grub any Linux can also be chainloaded.

(5) Only Linux doesn't mind residing in a logical partition (inside the extended partition). Both MS Windows and FreeBSD require to be installed in a primary partition and their bootloaders are not as capable as Grub that can fire up a Linux no matter where you put it in a hard disk.