• About
  • Manuals
  • Network
Confessions of a FreeBSD hacker Various tips & tricks about computers in general and FreeBSD in particular
Confessions of a FreeBSD hacker

Restore a FreeBSD installation through ZFS send/recieve

November 11, 2011 16:49 / Leave a Comment / Magnus Strahlert

Boot into RescueCD onto receiving machine. Then create GPT partitioning scheme (If a new machine and assuming ad0 is the disk)

gpart create -s gpt ad0
gpart add -t freebsd-boot -s 64K ad0
gpart add -t freebsd-swap -s 2G -l swap0 ad0
gpart add -t freebsd-zfs -l disk0 ad0
gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptzfsboot -i 1 ad0

Set up ssh keys and copy them over to the sending machine

ssh-keygen -t dsa
cat .ssh/id_dsa.pub|ssh <sending machine> dd of=/root/.ssh/authorized_keys

Load the necessary kernel modules

kldload /dist/boot/kernel/opensolaris.ko
kldload /dist/boot/kernel/zfs.ko

Make snapshots on sending machine

zfs snapshot -r <zpool>@now

Create zpool on receiving machine

zpool create <zpool>

Find out which snapshots to send

zfs list -t snapshot|grep now

Send/Receive snapshots

for fs in <output from above>; do
  ssh <sending machine>
  zfs send ${fs}|zfs receive -d -F <zpool>
done

Set flags (compression, exec, …). Then set mountpoints.

export LD_LIBRARY_PATH=/dist/usr
zfs unmount -a
zfs set mountpoint=legacy <zpool>
zfs set mountpoint=/tmp <zpool>/tmp
zfs set mountpoint=/usr <zpool>/usr
zfs set mountpoint=/var <zpool>/var
Posted in: FreeBSD / Tagged: backup, freebsd, ssh, zfs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

Post Navigation

← Previous Post
Next Post →

Recent Posts

  • Takeaways utilising VFIO in a KVM virtual guest
  • Converting VM from ESXi to KVM with iSCSI storage
  • Deploying oVirt in self-hosted mode
  • Ansible playbook for handling perl on FreeBSD
  • iSCSI: Migrating from istgt to ctld

Tags

ansible backup carp chroot cluster cross-server esxi freebsd ftp ftpchroot gpt grub hast install iscsi kvm linux lun lvm mirror network nfs nfsroot ovirt pxe raid ramdrive raspberrypi snapshot ssd ssh terminalserver usb vfio virtio virtualbox vlan vmware volumes winxp zfs zpool zroot

Archives

  • July 2019
  • March 2018
  • February 2018
  • July 2017
  • February 2016
  • January 2015
  • August 2014
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • September 2012
  • July 2012
  • April 2012
  • March 2012
  • November 2011
  • August 2011

Recent Comments

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    © Copyright 2013-2016 - Magnus Strahlert
    Infinity Theme by DesignCoral / WordPress