Solved Copying installation from one system (zfs send | recv)

Hi all,

I've got a FreeBSD installation on my VPS, it uses ZFS as its file system. At the end of last year I wanted to clone it onto a local VirtualBox VM, so I did something like the following:
Code:
# zfs snap -r zroot@2018-11-06
# zfs send -R zroot@2018-11-06 | gzip | ssh my.home.system "cat > /data/backup/vps/vps_2018-11-06.zfs.gz"

Now I got a bit busy so put this down for a bit, and I've come to revisit it. I've created a VirtualBox VM with similar specs to my VPS and loaded up mfsbsd. I've partitioned the disk similar to my VPS:

Code:
root@mfsbsd:~ # gpart show
=>       40  167772080  ada0  GPT  (80G)
         40       2008        - free -  (1.0M)
       2048       1024     1  freebsd-boot  (512K)
       3072       1024        - free -  (512K)
       4096    4194304     2  freebsd-swap  (2.0G)
    4198400  163571712     3  freebsd-zfs  (78G)
  167770112       2008        - free -  (1.0M)

I then created a zpool called "zroot", mounted it under /mnt, enabled root SSH login (in mfsbsd), and started doing a ZFS:

Code:
cat /data/backup/vps/vps_2018-11-06.zfs.gz | gunzip | ssh root@172.16.0.224 zfs receive -vF zroot

This took a fair while (there's ~44GB of data) but eventually completed without error.

Lastly, I wrote the boot code (from the received ZFS dataset, in case there was anything special. I've tried from the mfsboot and I get a very similar issue), exported the pool and rebooted:

Code:
root@mfsbsd:~ # gpart bootcode -b /mnt/boot/pmbr -p /mnt/boot/gptzfsboot -i 1 ada0
partcode written to ada0p1
bootcode written to ada0

When I rebooted I was greeted by the following:

Code:
|
Can't find /boot/zfsloader

FreeBSD/x86 boot
Default: zroot:/boot/kernel/kernel
boot:
/
Can't find /boot/kernel/kernel

FreeBSD/x86 boot
Default: zroot:/boot/kernel/kernel
boot: ?poudriere

FreeBSD/x86 boot
Default: zroot:/boot/kernel/kernel
boot:

I'm now at a loss as to where I went wrong. I'm pretty sure I've heard people doing the above, but my Google-fu doesn't seem to be working as I can't find any documentation/blog posts on it…

Any pointers would be most grateful,
Ben
 
Last edited:
I would say that gptzfsboot can't read the root zfs or it doesn't know where it is.
You can make some diagnotics at the prompt you get. If you type ? you should have a list of the root zfs files. If you type status, you will see if your pool has been discovered (but I think it's not the problem). See gptzfsboot().

I advise you to verify that the property bootfs of your pool is set to "zroot/ROOT/default". See zpool().
 
Thanks for your response, Emrion. Typing status, I get "pool: zroot", typing ? I get "poudriere". I've set the bootfs as you suggested and now I get an error:

Code:
Mounting from zfs:zroot/ROOT/default failed with error 45.

Looking at this thread (https://forums.freebsd.org/threads/cant-boot-restored-server.49479/) I'm thinking that this snapshot was from before the 12.0-RELEASE, so the server would have been running 11.2-RELEASE, because the mfsbsd I used was based on 12.0-RELEASE the zpool is newer than the one the snapshotted datasets lived in…

I'll try with an 11.2-RELEASE mfsbsd tomorrow and see :)
 
The error 45 is "Operation not supported". But this doesn't help.

The gptzfsloader of the 12.0 version is incompatible with a 11.2 system (see here). So be sure to install the one inside your saved zpool.
 
And now it works 😀 Indeed it was because I used a later version of FreeBSD (via mfsBSD). I created an 11.2-RELEASE ISO and recreated the zpool, then after another zfs send the system boots successfully!

Thanks for the pointers, Emrion
 
Back
Top