Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Mike Clarke
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?

-- 
Mike Clarke
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Joseph Lenox

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.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Wojciech Puchar


I am no expert at this however a quick Google search comes up with:

http://www.freebsd.org/doc/handbook/geom-mirror.html


The procedure shown there produces a mirror that will not boot on FreeBSD 9.


no idea but my procedure certainly would work if you use installer

1) install to first disk
2) gmirror label system /dev/seconddisk
3) bsdlabel -w /dev/mirror/system
4) bsdlabel -e /dev/mirror/system - make partitions as required.
5) bsdlabel -B /dev/mirror/system
6) newfs all created partitions (/dev/mirror/systema etc...)
7) add

vfs.root.mountfrom=ufs:mirror/systema

to loader.conf

edit /etc/fstab and change all things to new places
8) mount and copy files using tar or dump/restore to new place
9) reboot. system will start from gmirror
10) gmirror insert system /dev/firstdisk

all done.

if installer is not used but bootable media with complete system, just 
create gmirror then as usual.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Warren Block

On Thu, 12 Jul 2012, Wojciech Puchar wrote:



I am no expert at this however a quick Google search comes up with:

http://www.freebsd.org/doc/handbook/geom-mirror.html


The procedure shown there produces a mirror that will not boot on FreeBSD 
9.


no idea but my procedure certainly would work if you use installer

1) install to first disk
2) gmirror label system /dev/seconddisk
3) bsdlabel -w /dev/mirror/system
4) bsdlabel -e /dev/mirror/system - make partitions as required.
5) bsdlabel -B /dev/mirror/system
6) newfs all created partitions (/dev/mirror/systema etc...)
7) add

vfs.root.mountfrom=ufs:mirror/systema

to loader.conf

edit /etc/fstab and change all things to new places
8) mount and copy files using tar or dump/restore to new place
9) reboot. system will start from gmirror
10) gmirror insert system /dev/firstdisk

all done.

if installer is not used but bootable media with complete system, just create 
gmirror then as usual.


The current Handbook procedure avoids the copy by using the existing 
disk as-is and just writing the gmirror metadata to the last block.  If 
that last block is already part of an MBR partition, the more strict 
checking stops booting in 9.0.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Wojciech Puchar


The current Handbook procedure avoids the copy by using the existing disk 
as-is and just writing the gmirror metadata to the last block.

Exactly what i do doing instalations manually!


If that last block is already part of an MBR partition, the more strict checking stops 
booting in 9.0.


not making MBR partition would not make problems.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Warren Block

On Thu, 12 Jul 2012, Wojciech Puchar wrote:



The current Handbook procedure avoids the copy by using the existing disk 
as-is and just writing the gmirror metadata to the last block.

Exactly what i do doing instalations manually!

If that last block is already part of an MBR partition, the more strict 
checking stops booting in 9.0.


not making MBR partition would not make problems.


There's no guarantee that bsdlabel checking won't be made more strict. 
No matter what type of partitioning scheme, the metadata should not be

inside the data area.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Wojciech Puchar
If that last block is already part of an MBR partition, the more strict 
checking stops booting in 9.0.


not making MBR partition would not make problems.


There's no guarantee that bsdlabel checking won't be made more strict. No 
matter what type of partitioning scheme, the metadata should not be

inside the data area.


gmirror puts it's metadata at the end of disk.
bsdlabel is at the beginning. what a problem?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Warren Block

On Thu, 12 Jul 2012, Wojciech Puchar wrote:

If that last block is already part of an MBR partition, the more strict 
checking stops booting in 9.0.


not making MBR partition would not make problems.


There's no guarantee that bsdlabel checking won't be made more strict. No 
matter what type of partitioning scheme, the metadata should not be

inside the data area.


gmirror puts it's metadata at the end of disk.
bsdlabel is at the beginning. what a problem?


It's not the label, it's what the label declares for the partitions.  If 
the last partition includes the block of gmirror metadata, that's an 
error.  Pardon the ASCII diagrams.


Wrong:

partition table

partition 1---
| |
 -

...

partition n---
| |
|gmirror metadata |
 -


Right:

partition table

partition 1-
|   |
 ---

...

partition n-
|   |
 ---

gmirror metadata
|   |
 ---
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Wojciech Puchar

last partition includes the block of gmirror metadata, that's an error.


no it doesn't

i do this 2 ways:

method 1) i FIRST do gmirror on whole disk

THEN partition it, so partition sizes sums up to gmirror size which is 1 
sector less disk size.


then bsdlabel -B

method 2) i make same disklabel on both disk, then bsdlabel -B, them 
gmirror each partitions separately.
often i do not mirror all partitions, ew. i do not for squid proxy data if 
used.



both method results in system bootable from both drives and proper 
disklabels.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Warren Block

On Thu, 12 Jul 2012, Wojciech Puchar wrote:


last partition includes the block of gmirror metadata, that's an error.


no it doesn't


You appear to be agreeing with me, but saying that your method does not 
produce that problem.



i do this 2 ways:

method 1) i FIRST do gmirror on whole disk

THEN partition it, so partition sizes sums up to gmirror size which is 1 
sector less disk size.


then bsdlabel -B

method 2) i make same disklabel on both disk, then bsdlabel -B, them gmirror 
each partitions separately.
often i do not mirror all partitions, ew. i do not for squid proxy data if 
used.



both method results in system bootable from both drives and proper 
disklabels.


Yes, these are the same methods that can be used with MBR partitions. 
The second works with GPT partitioning also.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-12 Thread Wojciech Puchar


no it doesn't


You appear to be agreeing with me, but saying that your method does not 
produce that problem.


sorry - possibly i missed something.

both method results in system bootable from both drives and proper 
disklabels.


Yes, these are the same methods that can be used with MBR partitions. The 
second works with GPT partitioning also.


true. first doesn't. for now i use only second method in spite of not 
using GPT. being able to de-mirror selectively a partition or not mirror 
some partitions at all is quite a big adventage.


definitely not possible with hardware RAID.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-11 Thread Mikel King
There's an old article on BsdNews About using gmirrior perhaps that's the sort 
of thing you are looking for? - 
http://BSDNews.net/index.php/2006/08/31/working-with-gmirror-on-a-sun-fire-x2100-part-1/


Regards,
Mikel King



On Jul 11, 2012, at 5:18 AM, miles kuo miles@gmail.com wrote:

 Hi all,
 
 I have two SAS disks for the FreeBSD install. I want to install the freeBSD
 on one disk and mirror to another disk. Just like the AIX Mirror.
 
 Any changes will sync between the two disks. And if  one disk crashed or
 disconnected, the OS could continue running on another disk.
 
 Does the FreeBSD support the disk mirror? How to implement it?
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-11 Thread Warren Block

On Wed, 11 Jul 2012, Kaya Saman wrote:


On Wed, Jul 11, 2012 at 10:18 AM, miles kuo miles@gmail.com wrote:

Hi all,

I have two SAS disks for the FreeBSD install. I want to install the freeBSD
on one disk and mirror to another disk. Just like the AIX Mirror.

Any changes will sync between the two disks. And if  one disk crashed or
disconnected, the OS could continue running on another disk.

Does the FreeBSD support the disk mirror? How to implement it?


I am no expert at this however a quick Google search comes up with:

http://www.freebsd.org/doc/handbook/geom-mirror.html


The procedure shown there produces a mirror that will not boot on 
FreeBSD 9.  The release notes mention a workaround:

http://www.freebsd.org/releases/9.0R/relnotes-detailed.html#AEN1277

(There's work under way to fix that chapter.)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: How to mirror the FreeBSD OS on two disks

2012-07-11 Thread Joseph Lenox
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).


On 07/11/2012 04:18 AM, miles kuo wrote:

Hi all,

I have two SAS disks for the FreeBSD install. I want to install the freeBSD
on one disk and mirror to another disk. Just like the AIX Mirror.

Any changes will sync between the two disks. And if  one disk crashed or
disconnected, the OS could continue running on another disk.

Does the FreeBSD support the disk mirror? How to implement it?
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org



--
--Joseph Lenox, BS, MS
I'm an engineer. I solve problems.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org