Boot FreeBSD ISO from Grub2 USB stick

Having become a little more familiar with Grub and ISO files I have got as far as initiating a FreeBSD boot using loopback using mfsBSD
My Grub entry consists of
Code:
menuentry "mfsBSD" {
set isofile="/iso/mfsbsd-mini-11.0-RELEASE-amd64.iso
loopback loop (hd0,3)$isofile
kfreebsd (loop)/boot/loader
}

(hd0,3) is a FAT32 partition on a USB disk which also has FreeBSD 11 installed on the first partition, so I can't be absolutely certain where the loader is being loaded from... Is there any way to put FreeBSD options for the loader into the Grub entry to verify where it is booting from?
 
Having become a little more familiar with Grub and ISO files I have got as far as initiating a FreeBSD boot using loopback using mfsBSD
My Grub entry consists of
Code:
menuentry "mfsBSD" {
set isofile="/iso/mfsbsd-mini-11.0-RELEASE-amd64.iso
loopback loop (hd0,3)$isofile
kfreebsd (loop)/boot/loader
}

(hd0,3) is a FAT32 partition on a USB disk which also has FreeBSD 11 installed on the first partition, so I can't be absolutely certain where the loader is being loaded from... Is there any way to put FreeBSD options for the loader into the Grub entry to verify where it is booting from?
Don't waste your time on this one, you may use the results of others who have already wasted enough... Read this thread carefully to find out WHY this will not work. And BTW, not all linux-based ISO's can boot this way, but only those having this capability in kernel initrd-included boot-time scripts.

Hint: cannot pass any boot options to GRUB other than what's supported by FreeBSD kernel. So, you CAN build your own customized miniroot fs (normally not used in FreeBSD) and even include some scripts to boot from an mdconfig created loopback device linked to the ISO on your real device... yea, even describing the procedure takes more time than using conventional ways of booting FreeBSD from ISO image...
 
As an alternative to trying to boot FreeBSD from an ISO I created an additional UFS partition and extracted the ISO onto it using tar zxf FreeBSD-11.0-RELEASE (no dash to tar). A grub menuentry using kfreebsd worked fine as far as loading went, the only problem being fstab. Once that was changed FreeBSD booted up to bsdinstall.

My original idea was to have each BSD distro extracted to a separate partition, but since I haven't yet mastered Grub/EFI, I thought I would create separate directories for each distro... Unfortunately I can't get
Code:
kfreebsd /11.0-RELEASE/boot/loader
to work. '11.0-RELEASE' being a subdirectory of '/dev/da0s2a'
 
And how did you happen to have a /dev/da0s2a on your USB flash?? It should have been
/dev/da0p2 or /dev/da0s2, but 2a means you have slices inside a physical partition. Why would you need that on a USB drive??
 
I'm currently using a USB attached Hard Disk with a MBR partition type. I added a FreeBSD partition using
gpart add -t freebsd -s 5G da0.
 
I'm currently using a USB attached Hard Disk with a MBR partition type. I added a FreeBSD partition using
gpart add -t freebsd -s 5G da0.
Well you need to read loader man page about how it works. The short answer is you need it installed, and with MBR there are a couple of tricks how you can avoid installing it as a (only) bootloader into MBR. You install it into MBR, then copy the MBR using dd to your target partition, then you can use that copy of MBR with GRUB chainload command. Not sure though if it exists in GRUB2.
 
I simply extracted the ISO to the additional UFS partition (/dev/da0s2a) and it booted up without any problem (once fstab had been changed) and used
Code:
set root=(hd0,msdos2,bsd1)
kfreebsd /boot/loader
 
Ha, that's interesting. But sure you need to "insmod" a corresponding module into GRUB before it can see your msdos2,bsd1 kind of partition?
 
I didn't need to but maybe that depends on where you have GRUB installed. I installed GRUB as a FreeBSD pkg, and it shows (hd0,msdos1,bsd1) if you run ls from a grub> prompt. That is, if you have GRUB installed on an mbr disk. I've now managed to get grub-efi installed on a gpt disk and use (hd0,gpt2) to boot FreeBSD.
 
Well I tried grub-efi some time ago, but the problem was that its drive notation was totally different, then secondly after boot I couldn't use X mode for some reason. So since EFI wasn't critical for me (I do care about GPT, but not EFI) I forgot about it.
 
With the current mfsbsd you can boot the iso from the grub command line with the following:
N.B. This does not create a menuentry, and is not persistent across reboots.

From your running system, download the iso to e.g. /root (in this case it was a debian stretch installation)
cd /root
wget http://mfsbsd.vx.sk/files/iso/11/amd64/mfsbsd-mini-11.2-RELEASE-amd64.iso


Reboot and enter the grub command line
Change (hd0,1) to the disk with the downloaded iso. This can be checked with ls [HIGHLIGHT](hd0,1)[I][/I][/HIGHLIGHT][I][/I]/root/*.iso
loopback mfs [HIGHLIGHT](hd0,1)[/HIGHLIGHT][FILE]/root/mfsbsd-mini-11.2-RELEASE-amd64.iso[/FILE]
set root=(mfs)
kfreebsd (mfs)[FILE]/boot/kernel/kernel.gz[/FILE]
kfreebsd_module (mfs)[FILE]/mfsroot.gz[/FILE] type=mfs_root
set kFreeBSD.vfs.root.mountfrom=ufs:/dev/md0
boot


mfsBSD should now be starting up
 
Also trying this without success, any tips?

Code:
   kfreebsd (loop)/boot/kernel/kernel -v
   kfreebsd_loadenv (loop)/boot/device.hints
   kfreebsd_module (loop)/data/base.ufs.uzip type=mfs_root
   set kFreeBSD.vfs.root.mountfrom="ufs:/dev/md0"
   set kFreeBSD.xconsole=YES
menuentry "/linux/Freebsd/FreeBSD-13.1-RELEASE-amd64-bootonly.iso" "/linux/Freebsd/FreeBSD-13.1-RELEASE-amd64-bootonly.iso" {
set gfxpayload=keep
insmod bsd
search --no-floppy --set --file $2
loopback loop $2
kfreebsd (loop)/boot/kernel/kernel -v
kfreebsd_module $2 type=mfs_root
set kFreeBSD.vfs.root.mountfrom="cd9660:/dev/md0"
}

It worked in BIOS.But it failed in UEFI mode.What's the problem?
 
Back
Top