Skip to content

Instantly share code, notes, and snippets.

@aaronlauterer
Created September 5, 2016 18:49
Show Gist options
  • Save aaronlauterer/e7ba132f01d0f863dfd908ee12309c4e to your computer and use it in GitHub Desktop.
Save aaronlauterer/e7ba132f01d0f863dfd908ee12309c4e to your computer and use it in GitHub Desktop.
# Google translation from http://victor-sudakov.livejournal.com/328562.html
# Here so I will find it again
FreeBSD bare metal restore (GPT, ZFS raidz)
victor_sudakov
November 8th, 2015
1. Full dump
zfs snapshot -r zroot @ backup
zfs send -R zroot @ backup> /mnt/backup.zfs
zfs destroy -r zroot @ backup
2. Bare metal restore to ZFS
Loads with mfsBSD or the LiveCD, and further drives da3 - untagged where to deploy the system.
gpart create -s gpt da3
gpart add -s512k -t freebsd-boot da3
gpart add -s2G -t freebsd-swap -l swap0 da3
gpart add -t freebsd-zfs -l disk0 da3
gpart bootcode -b / boot / pmbr -p / boot / gptzfsboot -i 1 da3
Repeat for da4, if the system is in the mirror, or da4, da5, if raidz. The preferred use of the mark (-l), but not the names of the physical device, or when you change the hardware configuration "bukovki go" and pool will UNAVAIL. Swap partition is also more convenient to connect on labels.
zpool destroy zroot
zpool create zroot mirror / dev / gpt / disk {0,1}
or
zpool create zroot raidz / dev / gpt / disk {0,1,2}
zfs receive -Fdv zroot </mnt/backup.zfs
zpool set bootfs = zroot / ROOT / default zroot
reboot
On the restored system:
zfs destroy -r zroot @ backup
If it is a clone, do not forget
rm / etc / hostid / etc / ssh / * key *
Thanks for some tips here , in particular the need to specify the drives in the zpool in the form of labels in the / dev / gpt, rather than the physical device names. In particular swap point fstab like this:
# Device Mountpoint FStype Options Dump Pass #
/ Dev / gpt / swap0 none swap sw 0 0
/ Dev / gpt / swap1 none swap sw 0 0
/ Dev / gpt / swap2 none swap sw 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment