Recovering a zfs root pool from backup

Karli Sjöberg karli.sjoberg at slu.se
Sun Nov 22 08:47:16 UTC 2015


Den 22 nov. 2015 8:24 fm skrev Chris Stankevitz <chris at stankevitz.com>:
>
> I have a 'zroot' as setup by the FreeBSD install procedure on "Machine
> A".  I back it up like so:
>
> zfs snapshot -r zroot at backup
>
> zfs send -Rv zroot at backup > /path/to/external/drive/zroot.backup.bin
>
> Let's assume that "Machine A" zroot pool is destroyed.  On "Machine B" I
> issue these commands:
>
> zpool create zroot /dev/new/drive
>
> cat /path/to/external/drive/zroot.backup.bin | zfs receive -d zroot
>
> I do not believe that this will create a working drive for Machine A
> because:
>
> 1. I doubt I can create a new pool called "zroot" on Machine B since it
> is already running a pool called "zroot"
>
> 2. I doubt that this process will create the appropriate "boot sector"
> stuff (I do not know what I am talking about here).

Exactly. You'd need to boot the machine from CD/USB to be able to receive the stream. About the boot stuff. That would need to be handled when partitioning the new drive:
# gpart create -t gpt (a)?da[0-9]+
# gpart add -t freebsd-boot -s 64k -l boot0 (a)?da[0-9]+
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 (a)?da[0-9]+
# gpart add -t freebsd-swap -b 2048 -s xg -l swap0 (a)?da[0-9]+
# gpart add -t freebsd-zfs -a 4k -l sys0 (a)?da[0-9]+
# sysctl vfs.zfs.min_auto_ashift=12

Also you need to set the "bootfs" property after the receive:
# zpool set bootfs=zroot zroot

/K

>
> Can you provide a solution to either of these problems and/or identify
> other problems with my backup/restore procedure?
>
> Thank you,
>
> Chris
>
> PS: The system is a file server with nearly all data stored on a zpool
> that is not "zroot".
> _______________________________________________
> freebsd-fs at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-fs
> To unsubscribe, send any mail to "freebsd-fs-unsubscribe at freebsd.org"


More information about the freebsd-fs mailing list