ZFS Migrating zpool from HDD to SSD

Ran into a small issue and I'm hoping that I am just overlooking the obvious answer.

I have a machine that is running on a single drive pool, on 500GB spinning rust. I purchased what I thought was a 500GB SSD, which had an actual capacity of 480GB:

Code:
=>       40  976773088  ada0  GPT  (466G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    4194304     3  freebsd-swap  (2.0G)
    4728832  972044288     4  freebsd-zfs  (464G)
  976773120          8        - free -  (4.0K)

=>       40  937703008  da0  GPT  (447G)
         40     409600    1  efi  (200M)
     409640       1024    2  freebsd-boot  (512K)
     410664        984       - free -  (492K)
     411648    4194304    3  freebsd-swap  (2.0G)
    4605952  933095424    4  freebsd-zfs  (445G)
  937701376       1672       - free -  (836K)

My original plan was to add the SSD as a mirror of the HDD, then once it was resilvered, break the mirror, and boot on the SSD. Unfortunately, that 20GB was just too much of a difference to create the mirror. So I am looking at the most efficient strategy to clone the data onto the SSD. I had thought about doing a zfs send | zfs recv, but it does not seem the best (or even close to the best) way to go about it.

Suggestions?
--vr
 
20GB was just too much of a difference to create the mirror.
Even one single block does the difference.
A mirror always orientates at its smallest partition. So your idea could only had worked if the new disk (partitions) were exactly >= the former one.

It may also work if you clone the whole disk with dd to a new one, setting bs=5...10M, to get the job done within a couple of hours, of course using a disk >= the former one, and ensure you really cleaned the disk completely before it. ( nvmecontrol sanitize -a block nvd0 on a nvme,
camcontrol on a SSD [refer to camcontrol's man page for details])

Otherwise you have to install new, or as Alain De Vos mentioned, do the traditional way:
Reboot an external system (so your disks "sleep"), copy the partition tables (gpart -> HB, man pages) also won't work if the sizes differ; but adding new partitions to a new disk is quickly done (it's all in the HB).
Then copy/clone the filesystems (dump-restore, rsync, tar, something like that) to the new partions.
 
had thought about doing a zfs send | zfs recv, but it does not seem the best (or even close to the best) way to go about it.
And why do you think so? That's the canonical tool to transfer ZFS datasets exactly as is...

You might want to use some "frontend script" adding comfort and (hopefully) doing things right, I recently tested sysutils/zxfer for my backup and it seems to work quite well (add misc/clpbar for some sort of progress indicator ...).

In a nutshell, you'd do a recursive send/receive for every top-level dataset on your pool, just excluding the root dataset itself (which is empty anyways).
 
Follow-up question. Verified that the pool was properly copied, then I swapped disks, booted on the FreeBSD 14.0 in live cd mode, and I did the following:

Code:
newfs_msdosfs -F 32 -c 1 /dev/ada0p1
mount -t msdpsfs /dev/ada0p1 /mnt
mkdir -p /mnt/EFI/BOOT
cp /boot/loader.efi /mnt/EFI/BOOT/BOOTX64.efi

Then I restamped the bootcode:

Code:
gpart bootcode -b /boot/pmbr -p /boot/gbtzfsboot -i 1 ada0

And yet, when the tries to boot on the SSD, it reports "No operating system found".

I figure I missed a step somewhere, but haven't a clue what I missed,
 
Using gpart bootcode is for installing a BIOS (not EFI) boot loader; you likely overwrote your fat fs and efi loader on ada0p1.

Are you booting EFI or BIOS mode? Is the bootfs zpool property correctly set on your root pool?
 
Using gpart bootcode is for installing a BIOS (not EFI) boot loader; you likely overwrote your fat fs and efi loader on ada0p1.

This is a brand new SSD, so there was no msdos partition to step on. This is why I did the newfs, mounted the partition and copied loader.efi...Are there other things that need to be copied?

Are you booting EFI or BIOS mode? Is the bootfs zpool property correctly set on your root pool?
Booting EFI. I tried setting the efibootmgr to boot from FreeBSD, still got the same "no os found" message.

I still have the old spinning rust drive, should I plug it in and copy the stuff from the msdosfs partition to hte SSD?
 
This is a brand new SSD, so there was no msdos partition to step on. This is why I did the newfs, mounted the partition and copied loader.efi...Are there other things that need to be copied?

This step, which you indicated you did after — "Then I" — you created and populateed the msdos (EFI) boot partition ada0p1:
Code:
gpart bootcode -b /boot/pmbr -p /boot/gbtzfsboot -i 1 ada0
overwrites ada0p1 with the contents of /boot/gptzfsboot, which is not what you want for EFI boot.

From gpart(8):
bootcode Embed bootstrap code into the partitioning scheme's metadata on the geom (using -b bootcode) or write bootstrap code into a partition (using -p partcode and -i index).

Assuming my following of your order-of-operations is correct, you need to recreate the msdos FS on /dev/ada0p1, remount it, and make the directories / copy in the EFI loader as you did previously. Also make sure the bootfs zpool property on your new pool points to the appropriate root (zfs) filesystem.
 
This step, which you indicated you did after — "Then I" — you created and populateed the msdos (EFI) boot partition ada0p1:
Code:
gpart bootcode -b /boot/pmbr -p /boot/gbtzfsboot -i 1 ada0
overwrites ada0p1 with the contents of /boot/gptzfsboot, which is not what you want for EFI boot.

Interesting.

I tried doing it in the reverse order, so the gpart bootcode -b, and then rebuilt the msdos partition on ada0p1. (I did both, in this order. just to be sure.)

Assuming my following of your order-of-operations is correct, you need to recreate the msdos FS on /dev/ada0p1, remount it, and make the directories / copy in the EFI loader as you did previously. Also make sure the bootfs zpool property on your new pool points to the appropriate root (zfs) filesystem.

All of the ZFS properties were transferred in the copy with sanoid step above.
 
Back
Top