Moving root on ZFS on GELI so GELI is no longer used

Trond Endrestøl trond.endrestol at ximalas.info
Sun Dec 29 23:34:08 UTC 2019


On Sun, 29 Dec 2019 17:37-0000, Kralj Karlo wrote:

> Trond Endrestøl writes:
> > man zfs, searching for zfs snapshot, zfs send, and zfs receive.
> >
> > My take usually is:
> >
> > 1. Make sure boot partitions are present and populated on the new disk(s).
> >    The same for any swap partitions.
> 
> Could you elaborate on this step or refer to relevant man pages?
> This is the step I don't know how to do.

Assuming da0 and da1 are your new disks, and you want these disks to 
be bootable on both legacy (BIOS) and UEFI systems, then I would do 
something like this:

# Create GPT on da0 and da1
gpart create -s gpt da0
gpart create -s gpt da1

# Create legacy boot partition and ESP for UEFI on da0
gpart add -a 4K -s 512K -t freebsd-boot -l gptboot0 da0
gpart add -a 4K -s 800K -t esp          -l esp0     da0

# Ditto for da1
gpart add -a 4K -s 512K -t freebsd-boot -l gptboot1 da1
gpart add -a 4K -s 800K -t esp          -l esp1     da1

# Write bootcode to da0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot   -i 1 da0
gpart bootcode               -p /boot/boot1.efifat -i 2 da0

# Ditto for da1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot   -i 1 da1
gpart bootcode               -p /boot/boot1.efifat -i 2 da1

Further, I probably would add a couple of swap partitions for swap, 
and another couple of swap partitions for dumps (though only one of 
them will actually be used), and a couple of ZFS partition for a 
mirrored root pool:

gpart add -a 4K -s 16G -t freebsd-swap -l swap0  da0
gpart add -a 4K -s 16G -t freebsd-swap -l swap1  da1

gpart add -a 4K -s 16G -t freebsd-swap -l dump0  da0
gpart add -a 4K -s 16G -t freebsd-swap -l dump1  da1

gpart add -a 4K        -t freebsd-zfs  -l zroot0 da0
gpart add -a 4K        -t freebsd-zfs  -l zroot1 da1

Consult gpart(8) for more information on the syntax.

For SSDs, you might want an alignment of 1M. And if you don't have or 
plan on using 4Kn drives, you can omit specifying alignment 
altogether.

You could move the swap and dump partitions to a dedicated disk. I use 
such a setup for my VMs where conservation of physical disk space is 
something to consider.

Next, create your ZFS pools as you normally would.

In the case of 4Kn drives, you might want to do sysctl 
vfs.zfs.min_auto_ashift=12 before creating any new pools. Run the 
sysctl command after you have run kldload zfs, unless your kernel has 
internal/static support for ZFS.

I prefer to take advantage of the GPT labels. That way I can shuffle 
my disks around without any ill results. The gpart add commands above 
will lead to:

/dev/gpt/gptboot0
/dev/gpt/esp0
/dev/gpt/swap0
/dev/gpt/dump0
/dev/gpt/zroot0

/dev/gpt/gptboot1
/dev/gpt/esp1
/dev/gpt/swap1
/dev/gpt/dump1
/dev/gpt/zroot1

You can expand on the GPT labels, e.g. letting them include the 
hostname, if desired.

GPT labels are limited to 36 characters stored as UTF-16LE.

-- 
Trond.


More information about the freebsd-questions mailing list