Solved How to install FreeBSD onto an extended partition.

linux->bsd

Active Member

Reaction score: 67
Messages: 167

A long time ago I created a virtual machine in VirtualBox that allows me to install a new operating system inside it, and then be able to boot the host into that same OS. It's using a rawdisk vmdk. I've installed and used Fedora, Arch, and Debian in that fashion.

I'd like to do the same with FreeBSD, but during the installation process, the installer issues an error that it can't modify the selected partition. I suspect that's because the partition is an extended partition (MBR). Is there a way around this error?
 

scottro

Daemon

Reaction score: 866
Messages: 2,019

As far as I know, FreeBSD requires, in MBR setups, a primary partition. If you use UEFI you don't have the 4 primary partition limit, but not sure how that works with VirtualBox, which I don't use that often. (And when I do, only for simple setups, such as a Windows system on a Linux machine or Linux system on a BSD machine).
 

kpa

Beastie's Twin

Reaction score: 1,842
Messages: 6,318

Partitions on an extended partition can't be used for the root filesystem as far as I know but they can be used for other filesystems.
 
OP
L

linux->bsd

Active Member

Reaction score: 67
Messages: 167

Thank you both.

I have a couple of other options: I installed FreeBSD on a VM and might be able to transfer the filesystem to the raw disk. I probably won't be able to boot into it though without some GRUB hacking.

Ultimately, I'll probably just make a mirror copy of my main disk and start over on the SSD using GPT.

Today I tried to install FreeBSD onto the spinner I use for files storage. I've got to tweak my easy2boot USB drive to get it to work, though. I found a guide that purports to work with FreeBSD 8 and 9 (or 9 and 10 can't remember which), so I'll give that a go tomorrow.
 

wblock@

Beastie Himself
Developer

Reaction score: 3,729
Messages: 13,851

Partitions on an extended partition can't be used for the root filesystem as far as I know but they can be used for other filesystems.
No. From memory, it is only boot0 that does not like extended partitions. I know I have installed and run FreeBSD on extended partitions, but that was long ago and with GPT there is no need for it now.

Grub can multi-boot GPT. Of course, the other operating systems on the same disk must support GPT also. The cleanest solution is a UEFI implementation that allows defining bootcode and bootable partitions. The UEFI Dell notebooks I've used lately all let you do this.
 
OP
L

linux->bsd

Active Member

Reaction score: 67
Messages: 167

No. From memory, it is only boot0 that does not like extended partitions. I know I have installed and run FreeBSD on extended partitions, but that was long ago and with GPT there is no need for it now.

Grub can multi-boot GPT. Of course, the other operating systems on the same disk must support GPT also. The cleanest solution is a UEFI implementation that allows defining bootcode and bootable partitions. The UEFI Dell notebooks I've used lately all let you do this.

Thanks, wblock.

Trying to install onto a primary partition on the spinner today also failed. Once, it errored out with a 'failed pre-check' message. I entered 'freebsd-ufs' as the type, 20G as the size, and '/' as the mount point. Then, it errored out with an 'invalid argument' message. I tried installing on both the SSD and HDD, both using the guided and manual partitioning methods.

Any ideas on what I can try next? I'm following the official installation guide:

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/bsdinstall-partitioning.html


BTW, I followed this guide to get FreeBSD 10, 10.3, and 11 to run the installer from a multiboot thumbdrive:

http://rmprepusb.blogspot.co.uk/2015/03/easy2boot-163-beta-3-now-supports.html
 

wblock@

Beastie Himself
Developer

Reaction score: 3,729
Messages: 13,851

I suppose "stop using MBR" is not an option?

It should be possible to manually create the extended slice, create the BSDlabel partitions inside it, mount it all, set the shell variable that points to it, then continue the installer. That last part is covered in the man page for the installer, bsdinstall(8).
 
OP
L

linux->bsd

Active Member

Reaction score: 67
Messages: 167

I finally had time to mess with this project again. I still wasn't able to install FreeBSD or even create new slices on the SSD, but I found a workaround:

1. Turns out the reason the HDD wasn't accepting a new slice was that I was selecting an existing partition (that was lacking a filesystem -- seemed reasonable) instead of selecting the root device and letting the installer figure out where to add the new partition itself. I deleted the empty partition, then selected the root device as the target (using the 'Guided' method). The installer created the new slice, then I let it automatically create the new partitions within it (just two: / and swap).

2. I then added the new OS to my Linux Grub menu.

3. And lastly, I used the dd program to copy the data from the HDD to the SSD.


Grub entry inside /etc/grub.d/40_custom -
Code:
# add custom menu entry for freebsd os installed on /dev/sda7
menuentry "FreeBSD on SSD"{
  insmod ufs2
  insmod bsd
  set root=(hd0,7)
  kfreebsd /boot/kernel/kernel
  kfreebsd_loadenv /boot/device.hints
  set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s5a
  set kFreeBSD.vfs.root.mountfrom.options=rw
  set kFreeBSD.hw.psm.synaptics_support=1
}

To find the proper devices and partitions, I booted into Grub, pressed `e' to enter edit mode instead of selecting a menu entry to boot, then typed:
root (hd<Tab>,sd<Tab>)

The <Tab>s are the Tab key, not the text. That auto complete-listed the devices and partitions according to how Grub sees them. Partition #7 is the BSD slice, and /dev/ada0s5a is where the installer installed both the boot code and root system.

http://www.mepis.org/docs/en/index.php?title=GRUB_from_command_line


Cloning from HDD to SSD -
dd if=/dev/sdb3 of=/dev/sda7 bs=64K conv=noerror,sync


Now I have to remember how to create a virtual machine in VirtualBox that can access that new installation to make migrating from my current OS to FreeBSD quick and easy.
 
Last edited:
OP
L

linux->bsd

Active Member

Reaction score: 67
Messages: 167

I figured I'd wrap this thread up by posting the steps I took to get a virtual machine up and running the FreeBSD installed on my hard drive -- that is, while logged into my Linux host, I can boot up my FreeBSD installation inside a VirtualBox virtual machine. Why? To make migrating easier.

Code:
# create vm
vboxmanage createvm --name $VMNAME --ostype $OSTYPE --register --basefolder $FOLDERPATH

# modify empty vm
vboxmanage modifyvm $VMNAME --memory $MEMORYSIZE --acpi on --ioapic on --hwvirtex on --cpus $CPUCOUNT --cpuhotplug on --nic1 bridged --nictype1 82540EM --vrdeport $VRDEPORT --bridgeadapter1 eth0

# add storage controller
vboxmanage storagectl $VMNAME --name ide --add ide --portcount 2

# this extracts the MBR from your boot-flag'd disk for use with your vmdk
dd if=/dev/zero of=dummy.img bs=1M count=50
losetup /dev/loop0 dummy.img
dd if=/usr/lib/syslinux/mbr.bin of=/dev/loop0

# extract the boot loader
dd if=/dev/loop0 of=$VMNAME.mbr bs=512 count=1

# detach the loop device
losetup --detach /dev/loop0

A long time ago I screwed up my boot sequence on my desktop, so I now had to use a rawvmdk that points at the root device instead of a single partition (the one with FreeBSD installed: /dev/sda7).

Code:
# create storage device
# vboxmanage internalcommands createrawvmdk -filename $VMNAME.vmdk -rawdisk /dev/sda -partitions 1,7 -mbr $VMNAME.mbr
vboxmanage internalcommands createrawvmdk -filename $VMNAME.vmdk -rawdisk /dev/sda

# attach storage devices
vboxmanage storageattach $VMNAME --storagectl ide --port 0 --device 0 --type hdd --medium $VMNAME.vmdk
vboxmanage storageattach $VMNAME --storagectl ide --port 0 --device 1 --type dvddrive --medium $ISOIMAGE
vboxmanage storageattach $VMNAME --storagectl ide --port 0 --device 1 --type dvddrive --medium emptydrive
 

Attachments

  • freebsd.png
    freebsd.png
    25.3 KB · Views: 559
Top