Using gpart with a dual boot device

How can I safely use gpart() to partition a disk that already contains another OS that I don't want to get rid of?

In my case, I'd like to dual boot Windows 8 and FreeBSD 10 on my HDD. I'm already dual booting Windows 8 and Linux on the drive, so I've already shrunk the Windows 8 partition; disabled SecureBoot, FastBoot, and QuickBoot; and already have an EFI System Partition (ESP). I want to replace Linux with FreeBSD.

Since I'm dual booting, I don't want to destroy the GPT table ( gpart destroy -F <device>); that sounds dangerous. I want to modify the existing GPT table. Would I use gpart delete for each Linux partition, and then gpart add the FreeBSD partitions I need? Is gpart destroy and gpart create unnecessary in my case?

How do I make FreeBSD use the existing ESP? When it comes time to installing a boot loader, do I just install it to the ESP and that's that?

If I want to backup all the GPT data, should I dd() the ESP, the beginning of the disk (how much), and the end of the disk (how much)? Or will gpart backup take care of all that for me (and I'll move the backup to a USB)?

I want to use ZFS with geli() encryption, so I assume I need to do the following:
Code:
gpart delete the Linux partitions.
gpart add -t freebsd-boot -s 512K <device>
gpart add -t freebsd-swap -s 4G <device>
gpart add -t freebsd-zfs <device>
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i <index_of_freebsd-boot_partition> <device>
geli init [options] <freebsd-zfs_partition>
geli attach <freebsd-zfs_partition>
zpool create <name> <eli_partition>
(just having the one default dataset is fine for me for now)

Please correct me if I'm wrong. :)

Thanks!
 
freebeastie said:
Since I'm dual booting, I don't want to destroy the GPT table ( gpart destroy -F <device>); that sounds dangerous. I want to modify the existing GPT table. Would I use gpart delete for each Linux partition, and then gpart add the FreeBSD partitions I need? Is gpart destroy and gpart create unnecessary in my case?
That's correct. A gpart destroy would remove the entire partition table, which would also remove any existing partitions (Windows, Linux, everything).

How do I make FreeBSD use the existing ESP? When it comes time to installing a boot loader, do I just install it to the ESP and that's that?
You don't. It's not possible to UEFI boot FreeBSD at this time. You will need to use "Legacy boot". There's work being done in this respect but it's not finished yet.

If I want to backup all the GPT data, should I dd() the ESP, the beginning of the disk (how much), and the end of the disk (how much)? Or will gpart backup take care of all that for me (and I'll move the backup to a USB)?
A gpart backup should be all you need.

I want to use ZFS with geli() encryption, so I assume I need to do the following:
For FreeBSD 10.0 I would try the installer, it should be able to create an encrypted ZFS automatically using the available space.
 
SirDice said:
For FreeBSD 10.0 I would try the installer, it should be able to create an encrypted ZFS automatically using the available space.

The FreeBSD handbook (2.6. Allocating Disk Space) says automatic ZFS partitioning "only works with whole disks and will erase the contents of the entire disk." :(

SirDice said:
It's not possible to UEFI boot FreeBSD at this time. You will need to use "Legacy boot". There's work being done in this respect but it's not finished yet.

I think I understand: I need to do gpart bootcode -b /boot/pmbr -p /boot/gptboot -i <index_of_freebsd-boot_partition> <device> and enable legacy booting in my BIOS (my UEFI?), which will allow FreeBSD to kick off the boot process from my protective MBR (rather than my ESP, which it currently can't).

Since I'm encrypting my root partition, I should also add an unencrypted /boot partition using the freebsd-ufs partition type. To get FreeBSD to install /boot to my unencrypted partition, should I mount my unencrypted partition to /boot (or mount somewhere else and create a symlink) before proceeding with installation? If I use ZFS instead of UFS for my boot partition, I wonder if it's enough to just set the partition's mountpoint to /boot when I create the zpool.

Now, I guess I just need to figure out how to use sysutils/grub2-efi, so that I can easily switch been OSs.

Thanks for the help!
 
Back
Top