my ideas in action
how to add/replace disk to FreeNAS mirror
November 3, 2014Posted by on
I recently had to add new disks to my FreeNAS storage. I mounted the disks but I was not able to add them as mirror from GUI interface. But I found this Russian website with very simple and easy to follow tutorial. I copied here mainly for me as a reminder but may be also useful for others.
I hope the original author will not be upset.
The original post is here :
The high-level steps are:
Add the new disk to the system – (means connect the cables)
Partition the disk with gpart – (from FreeNAS terminal)
Attach the new partition to ZFS as a mirror
Create the GPT
Use the GUI to find the device ID of the new drive or use camcontrol.
# camcontrol devlist
at scbus2 target 0 lun 0 (ada0,pass0)
at scbus3 target 0 lun 0 (ada1,pass1)
at scbus4 target 0 lun 0 (ada2,pass2)
at scbus5 target 0 lun 0 (ada3,pass3)
at scbus7 target 0 lun 0 (da0,pass4)
let assume that our target is ada1. Create the GUID partition table for ada1.
# gpart create -s gpt ada1
Add the Swap Partition
Create a swap partition matching what FreeNAS created on the original drive. FreeNAS puts a swap partition on every data drive by default, stripes them together, and encrypts with a temporary key each boot. I’m not sure how that works when a drive fails, but it’s the recommended configuration.
# gpart add -b 128 -i 1 -t freebsd-swap -s 2G ada1
Add the Data Partition
Use the remaining space for the data partition.
# gpart add -i 2 -t freebsd-zfs ada1
Get the GPTID for the Partition
A device may change names depending on the connected port but the GPTID doesn’t change. FreeNAS uses the GPTID to track disks and so we want the rawuuid field of ada1p2.
# gpart list ada1
Geom name: ada1
1. Name: ada1p1
Mediasize: 2147483648 (2.0G)
2. Name: ada1p2
Mediasize: 1998251364352 (1.8T)
Attach to ZFS as mirror
Attach the partition using zpool which will begin the resilvering process. You will need the GPTID of the encrypted original disk parition.
# zpool attach
# zpool attach storage /dev/gptid/1c5238f9-5e2d-11e3-b7e0-08606e6e53d5 /dev/gptid/40380205-4794-11e4-b95b-08606e6e53d5