J
jpaetzel
Guest
While FreeNAS has the ability to import arbitrary pools, in some cases it's nice to be able to build a pool from the CLI exactly how the system would do it.
From a high level, FreeNAS uses gpart to partition the disks, then uses the gptid's on the partitions as the pool devices. There are two reasons for this. 1) It allows a bit of swap to be placed on the disk. 2) It removes any dependency on the hardware device naming for pool import. If your disks get reordered or renamed imports will proceed as usual.
Say I want to create a pool called tank that is a mirror of two drives, /dev/ada0 and /dev/ada1
I'm going to start by clearing any labels that may be on the disks.
Next I'm going to create labels and partition the disks.
Now I'm going to get the gptid values for each disk. I'll use these when creating my pool.
I've found the values I want, they are the gptids that correspond to ada1p2 and ada2p2 (-i 2 to gpart add sets the index to 2, which is the data partition)
So it's time to create a pool
Why did I cd /dev? So I could tab complete!
Now I have a pool named poolname, which I will export
And finally, bring it in to the GUI with the autoimporter so FreeNAS can use it.
Protip. If you want backwards compatibility with your pools you can set the version number of the pool in the create statement, something like this:
From a high level, FreeNAS uses gpart to partition the disks, then uses the gptid's on the partitions as the pool devices. There are two reasons for this. 1) It allows a bit of swap to be placed on the disk. 2) It removes any dependency on the hardware device naming for pool import. If your disks get reordered or renamed imports will proceed as usual.
Say I want to create a pool called tank that is a mirror of two drives, /dev/ada0 and /dev/ada1
I'm going to start by clearing any labels that may be on the disks.
Code:
# gpart destroy -F /dev/ada0 # gpart destroy -F /dev/ada1
Next I'm going to create labels and partition the disks.
Code:
# gpart create -s gpt /dev/ada0 # gpart add -a 4096 -i 1 -s 2g -t freebsd-swap /dev/ada0 # gpart add -a 4096 -i 2 -t freebsd-zfs /dev/ada0 # gpart create -s gpt /dev/ada1 # gpart add -a 4096 -i 1 -s 2g -t freebsd-swap /dev/ada1 # gpart add -a 4096 -i 2 -t freebsd-zfs /dev/ada1
Now I'm going to get the gptid values for each disk. I'll use these when creating my pool.
Code:
# glabel status Name Status Components gptid/c2c333a8-7af3-11e3-afda-3c970e1092f6 N/A ada0p1 gptid/d2c333a8-7af3-11e3-afda-3c970e1092f6 N/A ada0p2 gptid/e2c333a8-7af3-11e3-afda-3c970e1092f6 N/A ada1p1 gptid/f2c333a8-7af3-11e3-afda-3c970e1092f6 N/A ada1p2
I've found the values I want, they are the gptids that correspond to ada1p2 and ada2p2 (-i 2 to gpart add sets the index to 2, which is the data partition)
So it's time to create a pool
Code:
# cd /dev # zpool create -R /mnt poolname -o failmode=continue mirror gptid/d2c333a8-7af3-11e3-afda-3c970e1092f6 gptid/f2c333a8-7af3-11e3-afda-3c970e1092f6
Why did I cd /dev? So I could tab complete!
Now I have a pool named poolname, which I will export
Code:
# zpool export poolname
And finally, bring it in to the GUI with the autoimporter so FreeNAS can use it.
Protip. If you want backwards compatibility with your pools you can set the version number of the pool in the create statement, something like this:
Code:
# zpool create -R /mnt poolname -o version=28 -o failmode=continue mirror gptid/d2c333a8-7af3-11e3-afda-3c970e1092f6 gptid/f2c333a8-7af3-11e3-afda-3c970e1092f6