Splitting zroot mirror

Hi guys,

So we've been testing FreeBSD to act as our web server and we've been running it off a USB drive with ZFS. I have mirrored the USB drive to a HD internal to the server now I want to remove the USB and replace it with another internal HD.

I have used ZFS before (but never with FreeBSD) so I'm aware of the ZFS replace, split, and attach commands but before I move forward I want to make sure there is nothing I'm missing on the FreeBSD side.

Here's the process I plan on taking:

Code:
zpool status tank1
  pool: tank1
 state: ONLINE
  scan: scrub repaired 224K in 0h21m with 0 errors on Fri Feb 22 19:08:02 2013
config:

	NAME        STATE     READ WRITE CKSUM
	tank1       ONLINE       0     0     0
	  mirror-0  ONLINE       0     0     0
	    da0s1   ONLINE       0     0     0
	    ada0    ONLINE       0     0     0

#zpool split tank1 tank2 da0s1
#zpool attach tank1 ada1

Is there anything else I need to do to preserve the zroot? Or and files I need to change on FreeBSD?

Thanks in advance for your advice
 
Don't split, use # zpool detach followed by # zpool attach with the new disk.

# zpool detach tank1 da0s1

# zpool attach tank1 ada0 ada1
 
Hi kpa,

Thanks for the advice. I did this and I got:

Code:
Make sure to wait until resilver is done before rebooting.

If you boot from pool 'tank1', you may need to update
boot code on newly attached disk 'ada1'.

Assuming you use GPT partitioning and 'da0' is your new boot disk
you may use the following command:

	gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

#gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
gpart: No such geom: ada1.

Not too sure what happened. Should I be concerned?
 
Ok just an update. I detached ada1 and used gpart to look at the table.

Code:
# gpart list ada1
Geom name: ada1
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 1250263727
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: ada1s1
   Mediasize: 254803968 (243M)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r0w0e0
   attrib: active
   rawtype: 131
   length: 254803968
   offset: 1048576
   type: linux-data
   index: 1
   end: 499711
   start: 2048
2. Name: ada1s2
   Mediasize: 639877776384 (596G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 256900096
   Mode: r0w0e0
   rawtype: 5
   length: 639877776384
   offset: 256900096
   type: ebr
   index: 2
   end: 1250263039
   start: 501758
Consumers:
1. Name: ada1
   Mediasize: 640135028736 (596G)
   Sectorsize: 512
   Mode: r0w0e0

So the table exists. As such I went ahead and wrote the bootcode and it completed successfully

Code:
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
bootcode written to ada1

Then I went ahead and reattached ada1 to tank1 and I had gpart check again and it can no longer read the gpt on ada1.

Code:
# zpool attach tank1 ada0 ada1
Make sure to wait until resilver is done before rebooting.

If you boot from pool 'tank1', you may need to update
boot code on newly attached disk 'ada1'.

Assuming you use GPT partitioning and 'da0' is your new boot disk
you may use the following command:

	gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

# zpool status
  pool: tank1
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
	continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Wed Apr  3 01:04:47 2013
        212M scanned out of 5.22G at 11.8M/s, 0h7m to go
        212M resilvered, 3.97% done
config:

	NAME        STATE     READ WRITE CKSUM
	tank1       ONLINE       0     0     0
	  mirror-0  ONLINE       0     0     0
	    da0s1   ONLINE       0     0    12
	    ada0    ONLINE       0     0     0
	    ada1    ONLINE       0     0     0  (resilvering)

errors: No known data errors
# gpart list ada0
gpart: No such geom: ada0.
# gpart list ada1
gpart: No such geom: ada1.

I'm assuming part can not access the gpt table of a device attached to a zpool not sure if this is a bug in gpart or ZFS or if it's an issue on m system.
 
You don't have any partitioning on either ada0 or ada1, only on da0s1. I assume that the system is booting now from the external USB disk?

Detach both ada0 and ada1, partition both disks as GPT with freebsd-boot, freebsd-swap (unless you're going to swap on a ZVOL) and freebsd-zfs partitions. Write the bootcode and the protective MBR on both ada0 and ada1.

Then attach the disk that was ada0 to the pool but use the GPT partition instead, it will be either ada0p2 or ada0p3 depending on if you created swap partitions. Do the same with ada1. Once both partitions have been attached and resilvering has finished try to boot from the disk that is now ada0.
 
Back
Top