Booting from usb stick

andre64

New Member


Messages: 1

Hi everyone. I'm a newbie in the *nix world and in command line, but my question is very simple. I would like to know how I can create an USB stick to boot FreeBSD - I don't mean a stick with an image or an ISO to install that, because the system is installed already, I want to know how to boot the installed FreeBSD from an USB stick in order to avoid booting from MBR - in my hard disk FreeBSD is installed with Windows 10, so the proper question would be about the installation of a bootloader for these two systems in an USB stick. Thanks and thanks for adding me in the forum.
 

roccobaroccoSC

Aspiring Daemon

Reaction score: 163
Messages: 648

You can't boot from a MBR because this kind of boot requires putting your computer in Legacy boot mode and Windows 10 does not boot in legacy mode.
If you want to double-boot Windows 10 and FreeBSD, then your boot mode needs to be UEFI.

Preparing the disk: It does not make any difference if you put the boot loader on a USB disk or a hard drive. Both are block devices and are treated the same, provided your computer's BIOS can boot from USB.
Preparing a UEFI device is described in the Wiki: https://wiki.freebsd.org/UEFI
Just make sure, doublecheck and triplecheck that you are working on the correct device: gpart show - make sure the device you are working on is the USB disk (for example, da1).

Bash:
# You need to create a GPT partition table on da1:
gpart create -s gpt da1

# Then create an EFI system partition:
gpart add -t efi -s 256M da1 # It needs to be formatted with FAT16, so do not use the whole USB drive (it's probably too large for FAT16).

# No need to create a root partition (you already have it on your hard drive).
newfs_msdos -F 16 -c 1 /dev/da1p1 # I am not sure but FAT32 might also work with EFI, check this to be sure

mount -t msdosfs /dev/da1p1 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi
umount /mnt
This will enable you to boot FreeBSD when booting from the USB drive.
If you want to dual boot, then you need to put both FreeBSD's loader.efi and Windows 10's EFI program on the EFI system partition. Then you could use the program efibootmgr(8) to add two boot entries to your BIOS and you'll be able to select which OS to boot on startup.

A word of warning - dual booting, especially with Windows, is quite tricky. So you need to be patient to get it right.
 

andre portes

New Member


Messages: 1

I have Windows 10 and Freebsd installed in my notebook under Legacy Mode and recently I've made an Usb stick with the same dual boot
 

Jose

Active Member

Reaction score: 107
Messages: 226

You can't boot from a MBR because this kind of boot requires putting your computer in Legacy boot mode and Windows 10 does not boot in legacy mode.
Huh? My childrens' Windows 10 machines boot from legacy BIOS. I see no reason to use the UEFI monstrosity if given a choice. I have an Asrock motherboard where the CSM straight up doesn't work. That's the only UEFI machine in my house.
 
Top