Non-booting 9.0 installed on FireWire800 attached to Mac Mini 2011

Hi,

I am new to FreeBSD. I successfully installed ftp://ftp.freebsd.org/pub/FreeBSD/re...amd64-dvd1.iso on external HD attached to a Mac Mini 2011 i5 2.5GHz with AMD Radeon HD 6630M via a Mc Ally FireWire800/USB2.0 enclosure PHR-S250UAB.

Installation using USB 2.0 worked fine and I was able to reboot to a working FreeBSD. (With help on the Xorg mailing list, I now have Gnome working too. Great!) While this works, use of FireWire800 would be preferred speed-wise.

Installation using FireWire800 required me to choose option 3 on the menu with the mascot showing up following boot from CD, enter "load sbp" and then "boot" to be able to see the FireWire800-attached HD during the installation process. Upon rebooting the Mac following installation on this HD and using rEFIt, I chose the Windows looking icon to boot FreeBSD just as I did with the USB connection. I ended up with FreeBSD apparently not booting. Instead a black screen showing "No bootable device -- insert boot disk and press any key" appeared with no further success.

I have been unable to find online confirmation that one can boot FreeBSD 9.0 (or any other release) when installed on a FireWire800 enclosure attached to a Mini. Should this be supported and if so, what could I do to make this work?

Thank you,
MaxiMini
 
Well it turns out the message I see on the black screen is a Mac OSX message. I found an explanation at the following link: http://www.crystalorb.net/mikem/linux_mbp_external.html (thank you Mike :) ). Though this is for Linux it should be adaptable to FreeBSD without too much pain. I just need to figure it out, which I must confess scares me a little as I'd rather not screw up my Mac OSX install. I would really appreciate any help someone familiar with both the FreeBSD boot process and OSX could provide, otherwise I will report when I make progress.

Looking into OSX's Disk Utility, I see my relatively new Mac came with one partition on its internal SATA drive that uses GPT as its partition map scheme. I could resize that, create a new tiny partition and place I assume FreeBSD's /boot/boot0 in it. Not sure how to do that as the Mac does not recognize the FreeBSD install on the Firewire drive when I am logged into an OSX session but perhaps I can do that from the FreeBSD install using USB to access it on the external drive in the Firewire/USB enclosure. I guess the next step would be to make that extra partition bootable from FreebSD (not sure yet how to do that either) and then perhaps FreeBSD will know the kernel is on the external Firewire drive when I reboot the Mac (why would it "know" that?). I see some trial and error moving forward with hopefully no data loss on the OSX side! Need to update my backup first ;)

Thank you,
Maximini
 
Torfinn,

Thank you for the pointer. I happen to have had more luck with an MBR partitioning than a GPT one. On my external drive connected to the Mini via USB, an MBR install boots fully albeit slowly. A GPT install stops at mountroot and I am yet to figure out how to make it go farther. Not only that but I have to use rEFIt for the Mac to see the GPT disk while I can bypass that and just press Alt at startup of the Mac without rEFIt to see and then boot the MBR install. Of course at least for now all bets are off when I connect the external HD via FireWire (as described above).

I guess what I need is to experiment with MBR and GPT. I need to find a way to place /boot on a 512K partition of the internal drive and hope that sees the external drive both with USB and FireWire. I am not too sure yet how to do that. I can use 'gpart show' to see all my drives and the small internal partition for now. (BTW, I have a clone of my internal drive to play with to avoid screwing up my internal drive. This is what I use for now.)

Alternatively at the link I posted above it is said one could boot using a CD (but then how does one place /boot on that CD? Is an iso needed first; what command line can make an iso out of /boot?). Doing that I assume I could wait for the boot to complete, access a shell, enter 'load sbp' then 'boot' to continue the booting process (i.e. get the kernel to load) from the FireWire drive.

As you can see, I am struggling to determine the appropriate procedure.

Thank you,
Maximini
 
I don't have any EFI Mac machine, so I can't help you with that, sorry.
I do have one machine with UEFI which shows a similar problem: if the disk installed is GPT-partitioned, UEFI (on this machine) assumes that the disk must have an EFI boot partition, tries to locate that (and fails, because there isn't any) and reports: "ERROR: No boot disk has been detected or the disk has failed.".

My workaround for this is that I insert a usb memory stick (which has the FreeBSD install image on it) boot from that, interrupt the boot loader, sett currdev to the correct device (in my case set currdev=disk1p2:), then I load the kernel and boot via
Code:
load /boot/kernel/kernel
boot

Not ideal, but it works for testing.
 
Thanks Torfinn.

I am unfortunately away from the machine for a while but I will give this a try using the CD (I think I tried booting from a USB but got nowhere on the Mini). Could you just precise which partition of the FreeBSD install I should use: freebsd-boot?

Thank you,
Maximini
 
Your mac seems powerful enough to run FreeBSD via VirtualBox for Apple, are using FreeBSD for a specific reason or just playing around with it?
 
Yes the Mini i5 is plenty powerful for virtual box but I need the system to not be physically in the same box. Too much could go wrong otherwise as the Mini is also used as a HTPC and regular computer for day to day tasks at home by others, not to mention burglars love to take those apple products away when they break in in my neighborhood.
 
maximini said:
Could you just precise which partition of the FreeBSD install I should use: freebsd-boot?

It should be the root partition of your FreeBSD install, so usually a freebsd-ufs for a GPT drive.
But your question is interesting; what happens if you try to boot from the freebsd-boot partition? That is where the FreeBSD bootstrap code lives, after all.
 
Torfinn,

Am back to the machine. Followed the handbook instructions to create a bootable USB from the amd64 memstick.img and it boots. Good (I used a new USB stick as my previous attempt with an old one failed).

Once at the beastie menu, I chose 2. lsdev there shows the USB as disk0 with one disk0a FFS partition, the internal disk as disk1 and the GUIDs tell me it is Mac OSX. Fine. The problem is I do not see the external FireWire-attached drive. Entering 'load sbp' does not make the disk visible to lsdev (though I have to use 'load sbp' if I want to be able to select the external drive for install). So I am not sure what parameter to give to a 'set currdev'. Road block.

I guess I need to find a way to mount the external drive. When I enter 'lsmod' I see a "FireWire.1" module under "0x200000: /boot/kernel/kernel (elf kernel, 0x11cd9b0)" and I see "sbp.1" under "0x13ce000: /boot/kernel/sbp.ko (elf obj module, 0x107b8)".

Thank you,
MaxiMini
 
Alright! I am now able to boot to the external Firewire using Torfinn's suggestion. Here is where I am.

Using rEFIt (though I suspect it would work without), I was able to boot to the FreeBSD system on the external USB drive, hit '2' when the "beastie" menu appeared, enter "load sbp", "set currdev=disk2p2", then "boot". ("disk2p2" or any other value such as "disk2p1" appeared to lead to the same result since "lsdev" only showed disk0 and disk1, i.e. I still do not know how to mount the FireWire drive for it to be accessible at this step.)

After a few moments of kernel loading from the USB stick, the process stopped at the "mountroot>" prompt. (Entering '?' showed available "GEOM managed disk devices", including "da0" - the external FireWire - along with "da1" - the USB stick - and "ada0" - the internal Mac OSX GPT drive.) (Entering "ufs:/dev/da0p1" - presumably "freebsd-boot" - failed to mount with error 5. I tried that to answer Torfinn's last question.) Entering "ufs:/dev/da0p2" successfully mounted root from the external Firewire drive, giving me FireWire access from then on (with FreeBSD still working fine when I unplugged the USB stick).

Though the above works, it is a kludge requiring a USB stick (or a CD). Could the next step be to create a partition on the internal drive and "dd" a minimal FreeBSD system to it? (Not sure yet what block size parameter to give to dd, "bs=64k" worked for the USB stick but would it work for the internal hard drive install? Need to read the man page.) I don't know if the rEFIt bootloader would see it without any modification to the internal GPT, and then assuming rEFIt does see it, and the Mac boots from it, the same steps would have to be followed, not optimal.

(BTW, is there a tool to benchmark the system when it is brought on line via either USB or FireWire? Would be nice to see how much FireWire accelerates things.)

Thank you,
MaxiMini
 
The loader comes from the freebsd-boot partition, so it makes sense that it doesn't need/want it at that point--it is looking for a UFS partition.

Having a separate boot partition is what the GELI setup does: http://forums.freebsd.org/showthread.php?t=29652. This would be similar, just loading the sbp(4) driver and setting
Code:
vfs.root.mountfrom="ufs:/dev/da0p2"
in /boot/loader.conf.

64k is fine for a dd(1) buffer size, but be very careful with that, it's way too easy to wipe out something that you'd rather not. Do a full backup of the drive first. This is one occasion where a binary copy of the whole thing with dd(1) would be worthwhile, unless there's some other way to easily recreate the entire drive including weird boot blocks and binary partitions. Even if there is an easy way to do that, come to think of it.

A quick, cheap, overly optimistic benchmark can be done with diskinfo(8)'s -t and -v options. This will show best-case, read-only performance that you'll never really see in actual use. benchmarks/bonnie++ is a realistic benchmark, but the results can be incorrect due to caching.
 
Status update...

I used http://www.rodsbooks.com/ubuntu-efi/index.html as an inspiration for what follows.

1/ In Mac OSX Disk Utility, created a 1GB FAT partition after my OSX partition on the Mini's internal drive.
2/ Restarted and booted from the USB stick containing FreeBSD.
3/ Entered '2' at the "Beastie" screen.
4/ Entered "load sbp".
5/ Entered "set currdev=disk2p2".
6/ Entered "boot".
7/ Entered "ufs:/dev/da0p2" at the "mountroot>" prompt.
8/ Logged in as root on the FreeBSD install in the external FireWire HDD.
9/ Entered "newfs /dev/ada0p4" to create a UFS2 file system in the partition I created on the internal drive (one weird thing is that this partition still mounts automatically in OSX as if it still was a FAT partition so it probably still is and I need to do something - what? - to convert it to UFS so that it does not show in OSX).
10/ Entered "mkdir /fbboot".
11/ Entered "mount /dev/ada0p4 /fbboot" to access the file system I created at 9/.
12/ Entered "cp -R /boot /fbboot" to allow booting FreeBSD from the partition created at step 1/.
13/ Entered "mkdir /fbboot/boot/efi" to create a mount point for the EFI System Partition (ESP on ada0p1).
13/ Entered "/sbin/mount_msdosfs /dev/ada0p1 /fbboot/boot/efi". The ESP contained (from memory) a log and /boot/efi/EFI/APPLE/ with some Apple files as I had used OSX's Internet Recovery feature in the past.
14/ Entered "mkdir /fbboot/boot/efi/EFI/FreeBSD" where I am now hoping to have Grub2 files "boot.efi" and "grubx64.efi" that can be seen by if not rEFIt then rEFInd (or just by pressing the alt/option key at startup of the Mini).

I would then try configuring grub2 as in http://forums.freebsd.org/showthread.php?t=5918 to chainload or directly load FreeBSD from ada0p4 (with a "/boot/loader.conf" containing both "load_sbp="YES"" and "vfs.root.mountfrom="ufs:/dev/da0p2" for automatic loading of the kernel from the external Firewire).

The problem is that I am not 100% sure how to install grub2 safely. I entered "pkg_add -r grub2" to make grub2 executables available for use but was unable to access any man page for them. I located grub-install but am not sure it will only install EFI-compatible versions of "boot.efi" and "grubx64.efi" in /fbboot/efi/EFI/FreeBSD (in the ESP) if I execute it there. I say "only" because I wonder whether running "grub-install" would also try to modify the MBR or some other area of the internal drive other than the /boot/efi/EFI/FreeBSD/ repertory on ada0p1.

So my questions, assuming going the grub2 route is fine, are: how do I force grub-install to use EFI and not MBR, and will executing it from /boot/efi/EFI/FreeBSD/ on ada0p1 only install "boot.efi" and "grubx64.efi" in this repertory?

Thank you,
Maximini
 
I have tried for days to progress with Grub2 unsuccessfully.

So started from scratch. Created both freebsd-boot and freebsd-ufs partitions on my internal HDD. Copied /boot to freebsd-ufs. Use "gpart bootcode -p /boot/gptboot -i 5 ada0" where '5' is the index of the freebsd-boot partition. This lead to nothing special.

Tried "gpart bootcode -b /boot/pmbr ada0" and this got me booting on the internal HDD only when I had my USB stick with FreeBSD in a slot. Problem was that upon rebooting with no USB stick inserted, the Mac showed the dreaded icon of a folder with a question mark. Was able to use OSX Disk Utility from a clone of my internal HDD to Repair the internal HDD and be able to boot to OSX again.

Inspired by http://http://www.glenbarber.us/2011/11/12/Dual-Booting-OS-X-and-FreeBSD-9.html, I tried "gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 5 ada0". I noticed that the output was "Bootcode written to ada0" instead of the expected "Bootcode written to ada0p5". This command appeared to do the same as "gpart bootcode -b /boot/pmbr ada0", i.e. the part "-p /boot/gptboot -i 5" went ignored, just as I thought it would from the manual page for gpart (that reads "bootcode Embed bootstrap code into the partitioning scheme's metadata on the geom (using -b bootcode) or write bootstrap code into a partition (using -p partcode and -i index)."

So how can I force the EFI to search/see the freebsd-boot partition in the GPT and run the next bootstrap stage from it. My GPT looks like this:

Code:
Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI system partition
   2          409640       971388591   463.0 GiB   AF00  Customer
   3       971388592       972658127   619.9 MiB   AB00  Recovery HD
   4       972658128       972920271   128.0 MiB   AF00  Apple HFS/HFS+
   5       972920272       972920399   64.0 KiB    A501  FreeBSD boot
   6       972920400       973968976   512.0 MiB   A503  FreeBSD UFS
And the protective MBR data looks like:
Code:
Number  Boot  Start Sector   End Sector   Status      Code
   1                     1    976773167   primary     0xEE
Can I/Do I need to dd if=/boot/pmbr somewhere?

Thank you for any hint,
Maximini
 
After much trial and error, I have FreeBSD 9.0 booting on the internal drive of the Mini :beergrin
(Note this is a Hybrid MBR install, not an EFI install, which would have my preference but I can't find out how to create .efi files to boot freebsd from the EFI partition; perhaps I can do this with grub2 but no joy so far.)

I still do not know how to set up the system to boot from the external FireWire800-attached drive.

Following are the steps I took to do the internal bootable install.
- I first created free space using OSX Disk Utility, created a 128M ef02 BIOS boot partition using gpt disk (for Grub2).
- I then installed FreeBSD from a USB key using manual partitioning (64K freebsd-boot partition on ada0p5, 4G freebsd-swap partition on ada0p6, 4G freebsd-ufs partition mounted at / on ada0p7).
- I booted into this install (via first booting to the FreeBSD system on the USB key, choosing option 2, set currdev=disk2p2, boot, ufs:/dev/ada0p7).
- Entered (though not sure this was needed) gpart bootcode -p /boot/gptboot -i 5 ada0.
- Entered mkdir /efi, mount_msdosfs /dev/ada0p1 /efi, gpart bootcode -b /boot/pmbr ada0, dd if=/dev/ada0 of=/efi/ada0.mbr bs=512 count=1.
- Rebooted to a USB-attached clone of my internal drive created using CCC in OSX (had to do that as installing the pmbr made it impossible for the Mac to see partitions; it displayed a folder icon with a blinking question mark.
- Repaired the internal drive in OSX Disk Utility.
- (Tried installing then using grub2 from the FreeBSD 9.0 but was unsuccessful as I am not used to it so decided to install Ubuntu that installs its own setup of Grub2, hence the kludge that follows.)
- Used gpt disk to replace partitions 5, 6, 7 with a single partition 5 whose last sector ended at that of partition 7 (this was needed as otherwise the Ubuntu 12.04 installer would complain about sda7 having an unrecognized file system (sic) and aborting installation).
- Inserted the Ubuntu DVD in my cheap external Samsung USB DVD drive and chose the Ignore option in the dialog box OSX displayed (if you don't do that at reboot, the Ubuntu installer may fail to start.)
- Rebooted to the Ubuntu DVD (using alt option or pressing C if not using rEFIt).
- Installed Ubuntu with manual partitioning (/boot reiserfs 500M in sda8, / ext4fs 5000M in sda9, swap 4096M in sda10, /home ext4fs rest of the drive in sda11) and selecting the internal drive for where the boot loader goes.
- Reinstalled FreeBSD using manual partitioningto first delete ada0p5 then create a 64K freebsd-boot partition on ada0p5, a 4G freebsd-swap partition on ada0p6, and a 4G freebsd-ufs partition mounted at / on ada0p7.
- Rebooted choosing the Ubuntu HD icon in rEFIt (Windows icon when pressing alt option).
- Pressed 'c' in Grub2, and entered the following:
root=(hd0,7)
chainloader (hd0,1)/ada0.mbr
boot
- Waited a few sec. and was able to log into my FreeBSD install.

I was then able to modify the grub2 install from Ubuntu to add an option for FreeBSD (basically creating a new file "07_freebsd" under /etc/grub.d/ containing the following:
#!/bin/sh -e
cat << EOF
menuentry "FreeBSD 9.0" {
set root=(hd0,7)
chainloader (hd0,1)/ada0.mbr
}
EOF
and refreshing grub2 using "update-grub" then rebooting).

As mentioned above, I was unable to automatically boot my external FreeBSD install using that grub2 option. I tried to set load_sbp=YES" and "vfs.root.mountfrom="ufs:/dev/da0p2"" in loader.conf in vain.

Can someone help me set up my internal FreeBSD install (now fully bootable :e) to redirect its booting process to that of the external FreeBSD install?

Thank you,
Maximini
 
Success!!!

I now have the system booting to the external drive automatically. :beergrin :beergrin :beergrin

All I had to do was to 1) edit /boot/defaults/loader.conf to have sbp_load="YES" (instead of "NO") and 2) edit /etc/fstab in the FreeBSD installed on the internal drive to essentially replace the two entries it contained for the internal swap and / to the external ones. Easy enough. (Now that the system boots the internal system then redirects the process to the external drive, all I have to do to access the internal system is to unplug the FireWire drive and use ufs:/dev/ada0p7 at the mountroot prompt.)

I am not too happy with all of the hoops I had to go through to make this work. I wish I could just configure rEFIt (or rEFInd or something else) for a FireWire drive to be recognized the same a USB drive is.

Apart from that, I guess I can proceed to the next step in my discovery. First perhaps GELI on the external then ZFS on the external. I assume the internal install will have to be modified to preload GELI and ZFS modules allowing the two features to be usable once the system tries to load the kernel from the external drive. (Re. ZFS, I played with PC-BSD 9.1 installed on the external drive attached with USB. Installing it using GPT boots painfully slowly - 2 minutes+ spent in the BTX phase with /-\|/-\ moving extremely slowly when at all - while not using GPT and okaying boot0 install results in the boot process completing in the expected timeframe.Is this a known GPT bug when using ZFS? That had me wondering whether I could use boot0 with gpt to boot my external drive based on what I read at http://forums.freebsd.org/showpost.php?p=136356&postcount=5. Not sure I can...)

Thank you,
Maximini
 
Back
Top