Hi,
Here is a little tutorial on how to add a disk to your zroot zfs-on-root pool, so that it will become a mirror instead of a single disk (stripe) pool. Had some troubles myself, so I thought let's share how to do this.
Once you have connected the new harddrive, we'll have to create a partition table that is exactly the same as on the main harddrive.
First let's find the harddrive using:
It will most likely appear as ada1.
Let's check out how the partition table looks like on the old drive:
To clean the existing partition table on the new drive execute:
Create the partition table on the new drive:
Run
Now attach the new drive to the zroot pool:
Install the bootloader onto the new disk so that when one disk crashes, you'll still be able to boot the system:
Now you can see the pool resilvering:
OPTIONAL - MIRROR SWAP
Make sure you have enough memory to turn off the swap temporarily.
Find the name of the swap device:
Turn off the swap partition:
Load the geom_mirror kernel module in order to create RAID devices:
Create the mirrored swap:
Modify
From:
To:
Activate the swap partition:
Here is a little tutorial on how to add a disk to your zroot zfs-on-root pool, so that it will become a mirror instead of a single disk (stripe) pool. Had some troubles myself, so I thought let's share how to do this.
Once you have connected the new harddrive, we'll have to create a partition table that is exactly the same as on the main harddrive.
First let's find the harddrive using:
camcontrol devlist
It will most likely appear as ada1.
Let's check out how the partition table looks like on the old drive:
gpart show ada0
Code:
=> 34 156301421 ada0 GPT (75G)
34 1024 1 freebsd-boot (512K)
1058 4194304 2 freebsd-swap (2.0G)
4195362 152106093 3 freebsd-zfs (73G)
To clean the existing partition table on the new drive execute:
gpart destroy -F ada1
Create the partition table on the new drive:
gpart create -s GPT ada1
gpart add -t freebsd-boot -l boot2 -s 512K ada1
gpart add -t freebsd-swap -l swap2 -s 2G ada1
gpart add -t freebsd-zfs -l zfs2 ada1
Run
zdb
and get the GUID of the disk in the zroot pool. Copy this GUID, we need it in the next step.Now attach the new drive to the zroot pool:
zpool attach zroot $guid /dev/gpt/zfs2
Install the bootloader onto the new disk so that when one disk crashes, you'll still be able to boot the system:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
Now you can see the pool resilvering:
zpool status zroot
OPTIONAL - MIRROR SWAP
Make sure you have enough memory to turn off the swap temporarily.
Find the name of the swap device:
swapinfo
Turn off the swap partition:
swapoff /dev/gpt/swap0
Load the geom_mirror kernel module in order to create RAID devices:
kldload geom_mirror
echo 'geom_mirror_load="YES"' >> /boot/loader.conf
Create the mirrored swap:
gmirror label -b prefer -F swap gpt/swap0 gpt/swap2
Modify
/etc/fstab
so when the system boots up, it mounts the right swap partition:From:
/dev/gpt/swap0 none swap sw 0 0
To:
/dev/mirror/swap none swap sw 0 0
Activate the swap partition:
service swap start