From owner-freebsd-questions@FreeBSD.ORG Thu Jul 12 14:21:59 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 04C81106566B for ; Thu, 12 Jul 2012 14:21:59 +0000 (UTC) (envelope-from lordofhyphens@gmail.com) Received: from mail-gg0-f182.google.com (mail-gg0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id AC7E18FC08 for ; Thu, 12 Jul 2012 14:21:58 +0000 (UTC) Received: by ggnm2 with SMTP id m2so2827530ggn.13 for ; Thu, 12 Jul 2012 07:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type; bh=oPq9Dfo41QxKPPKR8zHmxX7rgNc1S9SiOEiRUlCAZmw=; b=lGtKROAQJqlNzQDjw3DBnvWiV9nfjFzcueTDFS/idREHBqoCMsYCEn9Wg3BM7ogn/+ 5uqplA5WVERmVuGNwC+QBskuAuu8yxike5NrGSWzzfxlbTKidCIb4wsQIzqBsh1PYeQT 95msk1jjAt9/vjbi24nSE52aJZhDndRO9mSATa+sbtBrRKUACtCrn6KgLcUV9AEwxLPN uIBc45RGxFuJ6UBZyDjxTfnUJ6SQEyP2M36W9OZRcjrTttj6vL9KnOq8FaS78rbiWD2N 7ARJRzjcBFsR4i1XEv1LLeotZJh7Xiv92zqxOPdX2HtC4zadmm+sIVu7BxHV3p1vH79i cpdQ== Received: by 10.42.158.10 with SMTP id f10mr27707916icx.51.1342102917734; Thu, 12 Jul 2012 07:21:57 -0700 (PDT) Received: from [131.230.191.154] (lenneth.engr.siu.edu. [131.230.191.154]) by mx.google.com with ESMTPS id k6sm8661953igw.14.2012.07.12.07.21.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jul 2012 07:21:57 -0700 (PDT) Message-ID: <4FFEDD83.20702@gmail.com> Date: Thu, 12 Jul 2012 09:21:55 -0500 From: Joseph Lenox User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120704 Thunderbird/14.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <201207121147.48614.mike@milibyte.co.uk> In-Reply-To: <201207121147.48614.mike@milibyte.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: How to mirror the FreeBSD OS on two disks X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: lenox.joseph@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2012 14:21:59 -0000 On 07/12/2012 05:47 AM, Mike Clarke wrote: > On Wednesday 11 July 2012 16:20:41 Joseph Lenox wrote: >> What about a ZFS root? Just make sure both disks are in the BIOS/EFT >> boot order. >> http://www.aisecure.net/2011/11/28/root-zfs-freebsd9/ >> >> Something else we noticed on our site is that backup of a system >> snapshot can be quickly restored using just a live CD (do up to step 5, >> then replace steps 6-7 with a zfs receive of the desired snapshot). > Since the system is to be restored from the snapshot then I suppose most of > steps 8 to 12 wouldn't be needed either. But what about step 5 before the > restore: > > zpool export zroot > zpool import -o cachefile=/var/tmp/zpool.cache zroot > > And then step 10 after running zfs receive > > cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache > > Are these steps needed when restoring from a snapshot? I believe preserving the zpool cache is important, but I haven't tested not doing so. Logically, the zroot is still new, and the restore from snapshot would still populate the cachefile (which would default to writing in the live CD's /var/tmp, not the target system's /var/tmp. Here's my suggested instructions, adapted from http://www.aisecure.net/2012/01/16/rootzfs/ and my own experimentation, for restoring from a snapshot. It can also be used to clone a system configuration from one system to another (very convenient). This is for single-drive, just set up a mirror in the initial steps if you are going that route. 1. Boot from a FreeBSD9 installation DVD or memstick and choose "Live CD". 2. Create the necessary partitions on the disk(s) and add ZFS aware boot code. gpart create -s gpt ada0 gpart add -b 34 -s 94 -t freebsd-boot ada0 gpart add -t freebsd-zfs -l disk0 ada0 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 3. Align the Disks for 4K and create the pool. gnop create -S 4096 /dev/gpt/disk0 zpool create -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot /dev/gpt/disk0.nop zpool export zroot gnop destroy /dev/gpt/disk0.nop zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache zroot 4. Set the bootfs property on zroot. zpool set bootfs=zroot zroot 5. Mount the memory stick containing the snapshot. Most memory sticks are formatted fat32 or ntfs, and the LiveCD will at least read ntfs. mount -t ntfs /da0s1 /media/ * This assumes that the memory stick is NTFS formatted and it ends up as da0 in the system. 6. Receive snapshot. gunzip -dc /media/snapshot_name.gz | zfs receive -vF zroot * snapshot_name.gz is a placeholder for the actual name of the file on the media. I've assumed that the snapshot is gzip'd, otherwise cat the snapshot file. 7. Copy zpool.cache (very important!!!) cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache 8. If this is a clone of another system, edit pre-existing rc.conf and rc.local.conf files to suit new network configuration. * Specifically, the hostname and the IP need to change if the new system is on the network. 9. Reboot * Remember to set the correct boot drive in new system BIOS. -- --Joseph Lenox, BS, MS I'm an engineer. I solve problems.