• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Boot FreeBSD ISO from Grub2 USB stick

balanga

Daemon

Thanks: 49
Messages: 1,742

#51
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?
 

free-and-bsd

Aspiring Daemon

Thanks: 66
Messages: 633

#52
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...
 

balanga

Daemon

Thanks: 49
Messages: 1,742

#53
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'
 

free-and-bsd

Aspiring Daemon

Thanks: 66
Messages: 633

#54
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??
 

balanga

Daemon

Thanks: 49
Messages: 1,742

#55
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.
 

free-and-bsd

Aspiring Daemon

Thanks: 66
Messages: 633

#56
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.
 

balanga

Daemon

Thanks: 49
Messages: 1,742

#57
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
 

free-and-bsd

Aspiring Daemon

Thanks: 66
Messages: 633

#58
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?
 

balanga

Daemon

Thanks: 49
Messages: 1,742

#59
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.
 

free-and-bsd

Aspiring Daemon

Thanks: 66
Messages: 633

#60
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.