ZFS: rebuild zroot in the mirror

Colleagues, tell me, pls, answer my question!

If I installed FreeBSD on a server with zroot on one disk, can I later rebuild it in the mirror?

Speaking of rebuild, I mean to add a physical volume and give the command, rather than doing backup and reinstallation.
Of course, all mirror disks must be bootable.
(Perhaps this is in the documentation, but I could not find such an option.)

Thank you in advance for the answer on the essence of my question.

Ogogon.
 
Of course, you can and it's very simple. Your first disk has a GPT scheme?
If it is, you should post the result of gpart show
 
Here is my nearest server:
root# gpart show
=> 34 1953525101 ada0 GPT (932G)
34 6 - free - (3.0K)
40 1024 1 freebsd-boot (512K)
1064 984 - free - (492K)
2048 134217728 2 freebsd-swap (64G)
134219776 1819303936 3 freebsd-zfs (868G)
1953523712 1423 - free - (712K)
root#


Suppose I added a disk ada1.
 
Ok.. The possibility... You have to:
  1. Add a physical disk.
  2. Duplicate the scheme of the first disk to the new one.
  3. Install the bootcodes on the second disk.
  4. Use zpool attach to mirror the partition of interest.
Then, just wait the resilvering has finished up.

Is it clear?
 
In theory. At the time of mbr and ufs, I did this, but not for gpt and zfs. It will be necessary to understand.
 
Anyway - thank you.

P.S. And I can copy the disc to the same type, using the utility dd?

dd if=/dev/ada0 of=/dev/ada1 bs=1M

This should include steps 2 and 3.

Ogogon.
 
It's why I asked you... Details make difference between something that works and disaster. And please do not use dd at all.

First, do not suppose, just see the facts. You added a disk but is it ada1?
You have to run ls /dev. And if it is like you think, you will see: ada0, ada0p1, ada0p2 and ada0p3 but just ada1.

Then, you'll know what you're doing. The new disk is ada1.

As you have a GPT scheme on your first disk, it's easy to duplicate the thing on you second disk (I assume it's ada1): gpart backup ada0 | gpart restore -F ada1 (the -F option is only needed if the added disk had a partition scheme before).

I saw that you boot under legacy BIOS. So, to make the new disk bootable, you just have to issue this command:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i1 ada1

After that, it's time to mirror ada0p3. You have to run: zpool attach zroot ada0p3 ada1p3
zroot being the name of your zfs pool.
 
Back
Top