Saturday, 29 November 2014

How to dual boot Linux (CrunchBang Linux) and PC-BSD 10 with ZFS file system

This is a tutorial which shows how to dual boot Linux and PC-BSD 10. PC-BSD 10 uses ZFS as the file system and grub for the boot manager. I was able to successfully dual boot PC-BSD and CrunchBang Linux in my laptop.

I was able to achieve this after lots of trial and error methods. I have not found a valid guide in the internet to do it. All the tutorials were outdated or at least not working for me. I have spend a lot of time in the pc-bsd/freebsd irc channels and finally able to achieve this after trying out different suggestions from the irc members. Thanks to them all for the guidance.


If you want to dual boot PC-BSD, first install the Linux os (in this case, CrunchBang Linux) and then install PC-BSD 10. This is because most of the Linux OS won't be able to detect ZFS (the default file system in PC-BSD 10). But PC-BSD grub will be able to detect EXT4 the default file system in most of the Linux distros. If you are looking for a tutorial for PC-BSD with UFS and Linux, you can find lot of guides in the interwebs. My guide only applies to PC-BSD with ZFS file system.

1. Install Crunch Bang Linux
2. Copy the relevant part from the Crunch Bang Linux grub menu.  You can get it from the configuration file  /boot/grub/grub.cfg . There will be lot of unwanted details in this menu but we will only need the one starts after the line "### BEGIN /etc/grub.d/10_linux ###" in this file .

For example, below given is the relevant part from my Crunch Bang Linux grub configuration :

menuentry 'CrunchBang GNU/Linux, with Linux 3.2.0-4-amd64' --class crunchbang --class gnu-linux --class gnu --class os {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos5)'
    search --no-floppy --fs-uuid --set=root 1fa97d1a-97c2-45ab-ba94-1f692ce86756
    echo    'Loading Linux 3.2.0-4-amd64 ...'
    linux    /boot/vmlinuz-3.2.0-4-amd64 root=UUID=1fa97d1a-97c2-45ab-ba94-1f692ce86756 ro  quiet
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd.img-3.2.0-4-amd64
}


And upload this to online website like http://pastie.org/ and take a note of the link. This is because we need to get this after we install PC-BSD and configuring it's grub

3. Install PC-BSD 10 with ZFS as the file system
4. You won't see any option to boot Crunch Bang Linux after you install PC-BSD
5. Once you boot to PC-BSD, edit the grub configuration for PC-BSD
Open /usr/local/etc/grub.d/40_custom and add the earlier copied Crunch Bang Linux grub configuration to this file so that it will look like this. 

cat /usr/local/etc/grub.d/40_custom

menuentry 'CrunchBang GNU/Linux, with Linux 3.2.0-4-amd64' --class crunchbang --class gnu-linux --class gnu --class os {
       load_video
       insmod gzio
       insmod part_msdos
       insmod ext2
       set root='(hd0,msdos5)'
       search --no-floppy --fs-uuid --set=root 1fa97d1a-97c2-45ab-ba94-1f692ce86756
       echo    'Loading Linux 3.2.0-4-amd64 ...'
       linux   /boot/vmlinuz-3.2.0-4-amd64 root=UUID=1fa97d1a-97c2-45ab-ba94-1f692ce86756 ro  quiet
       echo    'Loading initial ramdisk ...'
       initrd  /boot/initrd.img-3.2.0-4-amd64
}

5. Update the grub configuration in PC-BSD with the below command

grub-mkconfig > /boot/grub/grub.cfg

Then reboot and make sure that grub is showing the above entries.

Some times you need to do “Hold Left-Shift for menu entries” to display all the boot entries.





5 comments:

  1. It would be useful to see what the pc-bsd entry in grub.cfg looks like.

    ReplyDelete
  2. This tutorials are of great help, it would surely give some more knowledge about linux.

    ReplyDelete
  3. Your text seems similar to my problem. My problem is listing at http://www.debianHELP.org/node/1970. I'll try your words. My linux partition is Debian Stretch with grub2. Thanks!

    ReplyDelete
  4. The Stretch grub.cfg looked a lot different! I followed the directions, but PCBSD didn't see any different. I'm looking at bugs.pcbsd.org too. I'm not done yet.

    ReplyDelete
  5. Thank you, it worked just fine!

    ReplyDelete