Migratng a ZFS installation to new disk

Having just installed a fresh 15.0 release of FreeBSD on ZFS and got it configured, I've found a bigger disk which I would like to migrate to.

What are the required steps?

Can I just attach the new disk via a USB enclosure and use the existing installation to copy itself to the new disk?
 
You can mostly do that.
First you partition your bigger disk to have the efi partition, the swap, and a larger freebsd-zfs partition.
I highly suggest to use gpt labels for each of them, this would simplify stuff in the long run.

Then you edit your fstab entry to comment anything that would point to the old drive (like swap, and efi partition)

Then you attach your new freebsd-zfs partition to your zroot to create a mirror.
Once the resilvering complete, do a resilver.
Create an efi fat32 filesystem on the efi partition, then mount it somewhere.
Mount the old efi partition into /boot/efi, and copy the EFI directory inside the new efi filesystem.
Then use efibootmgr to add your new efi boot entry.

Once it is done, use zpool split to split the two drives into 2 distinct pool, so that you still have a backup if something goes terribly wrong.

Shutdown the computer.

Remove your old drive.

Start it again.

If it start, edit back the fstab to use the new drive partition.
 
You can mostly do that.
First you partition your bigger disk to have the efi partition, the swap, and a larger freebsd-zfs partition.
I highly suggest to use gpt labels for each of them, this would simplify stuff in the long run.

This sounds fairly complicated especially for someone not familiar with ZFS, so I think I need to break the process down, because it sounds error prone for a new user.

On my original disk I have the following partitions:

efi
freebsd-boot
freebsd-swap
freebsd-zfs

I presume the sizes, apart from zfs should be the same.
 
This sounds fairly complicated especially for someone not familiar with ZFS, so I think I need to break the process down, because it sounds error prone for a new user.

On my original disk I have the following partitions:

efi
freebsd-boot
freebsd-swap
freebsd-zfs

I presume the sizes, apart from zfs should be the same.

Does this look right?

sh:
gpart destroy -F da0
gpart create -s gpt da0
gpart add -t efi -s 260M -l efi1 da0
gpart add -t freebsd-boot -s 512K -l boot1 da0
gpart add -t freebsd-swap -s 2G -l swap1 da0
gpart add -t freebsd-zfs  -l zfs1 da0
 
I presume I need to create a zpool with a different name on the new disk. The old one has ZROOT, so calling the new one TANK would be OK?

I'm way out of my depth with all this so forgive the newbie type questions
 
If you just want to clone your installation to a bigger drive, then you just clone your disk with dd and then run gdisk repair to update GPT header stuff, and that's it. Somebody correct me if I'm wrong. I did this with Linux, I think, so there's no reason it shouldn't work with FreeBSD.
Oh, I guess you'd also need to grow your gpt partition and grow your ZFS to fill the extra space.
 
Does this look right?

sh:
gpart destroy -F da0
gpart create -s gpt da0
gpart add -t efi -s 260M -l efi1 da0
gpart add -t freebsd-boot -s 512K -l boot1 da0
gpart add -t freebsd-swap -s 2G -l swap1 da0
gpart add -t freebsd-zfs  -l zfs1 da0
This looks right, don't forget to create the efi filesystem.

Doesn't zpool split require a mirror to start ?
It does that is why the previous instruction is to make a mirror.

If you just want to clone your installation to a bigger drive, then you just clone your disk with dd and then run gdisk repair to update GPT header stuff, and that's it. Somebody correct me if I'm wrong. I did this with Linux, I think, so there's no reason it shouldn't work with FreeBSD.
Oh, I guess you'd also need to grow your gpt partition and grow your ZFS to fill the extra space.
This is not recommended if you are not extra cautious about which pool you import since then when doing the copy with dd the two pools will be the same, with the same unique id which can be messy.
And growing up the size of zfs like this will likely result in a kernel panic. I had to disable the auto grow feature enabled in cloud ready image just for that.
 
I presume I need to create a zpool with a different name on the new disk. The old one has ZROOT, so calling the new one TANK would be OK?

I'm way out of my depth with all this so forgive the newbie type questions

You don't need to rename your pool if I recall, you just give another name for the old one.
zpool split [-gLlnP] [-o property=value]… [-R root] pool newpool
[device]…

Splits devices off pool creating newpool. All vdevs in pool must be
mirrors and the pool must not be in the process of resilvering. At the
time of the split, newpool will be a replica of pool. By default, the
last device in each mirror is split from pool to create newpool
The optional device specification causes the specified device(s) to
included in the new pool and, should any devices remain unspecified, the
last device in each mirror is used as would be by default.
So basically: zpool split zroot old-zroot gpt/zfs0
 
Do I need to install FreeBSD on the new disk?

Or a freebsd-boot partition?

I have one on my current disk and installed using bsdinstall.
 
If you are booting with uefi, you just need to copy the uefi stuff, and update the efi entries in the bios.
As for legacy boot, you need to run the appropriate commands.
 
Having just installed a fresh 15.0 release of FreeBSD on ZFS and got it configured, I've found a bigger disk which I would like to migrate to.

What are the required steps?

Can I just attach the new disk via a USB enclosure and use the existing installation to copy itself to the new disk?
Have done it many times. This is just straightforward. Partition a new disk. Add new partition as a mirror to an existing pool with
zpool attach zpool-attach(8). Also set the zpool set autoexpand=on for your pool. Then let it resilver and remove the old disk and delete it from mirror..

Do not forget to copy boot loader to the disk.
 
Back
Top