Resource icon

Creating a degraded pool

WARNING: HERE BE DRAGONS. IF YOU DON'T KNOW EXACTLY WHAT YOU'RE DOING, DO NOT FOLLOW THESE INSTRUCTIONS.

IN FACT, IF YOU NEED THESE INSTRUCTIONS, YOU PROBABLY SHOULDN'T FOLLOW THEM.


There are a few cases where it may make sense to create a degraded pool in your FreeNAS server. One of the most common would be a case where you have all the disks you need for your pool, but one of them already has data on it. The degraded pool would let you create, for example, a three-disk RAIDZ1 pool without the third disk. Once you've transferred the data from the third disk onto the pool, you can then resilver that disk into the pool, giving you redundancy. To do it right takes a few steps to match the way FreeNAS creates pools.

The example below will create a RAIDZ1 pool on da18 and da19 (both 2 TB disks), and a 2 TB sparse file. It can be adapted to any RAIDZ level or number of disks.

Start by creating the sparse file:
Code:
root@freenas2:~ # truncate -s 2T /root/sparsefile


Then create the GPT partition table and the necessary partitions on da18:
Code:
root@freenas2:~ # gpart create -s gpt /dev/da18
root@freenas2:~ # gpart add -i 1 -b 128 -t freebsd-swap -s 2g /dev/da18
da18p1 added
root@freenas2:~ # gpart add -i 2 -t freebsd-zfs /dev/da18
da18p2 added

Repeat for the other disk(s). Then get the gptids:
Code:
root@freenas2:~ # glabel status
									   Name  Status  Components
(snip)
gptid/d326a289-c056-11e8-90eb-002590caf340	 N/A  da18p1
gptid/d508abf6-c056-11e8-90eb-002590caf340	 N/A  da19p1
gptid/dee8fa86-c056-11e8-90eb-002590caf340	 N/A  da18p2
gptid/e1e2ba67-c056-11e8-90eb-002590caf340	 N/A  da19p2

You'll use the gptids for the second partition on each of the disks (da18p2 and da19p2), in the following command:
Code:
root@freenas2:~ # zpool create -f testpool raidz1 /root/sparsefile gptid/dee8fa86-c056-11e8-90eb-002590caf340 gptid/e1e2ba67-c056-11e8-90eb-002590caf340

The pool will be created:
Code:
root@freenas2:~ # zpool status -v testpool
  pool: testpool
 state: ONLINE
  scan: none requested
config:

   NAME											STATE	 READ WRITE CKSUM
   testpool										ONLINE	   0	 0	 0
	 raidz1-0									  ONLINE	   0	 0	 0
	   /root/sparsefile							ONLINE	   0	 0	 0
	   gptid/dee8fa86-c056-11e8-90eb-002590caf340  ONLINE	   0	 0	 0
	   gptid/e1e2ba67-c056-11e8-90eb-002590caf340  ONLINE	   0	 0	 0

errors: No known data errors

Then offline the sparsefile, and check the pool status again:
Code:
root@freenas2:~ # zpool offline testpool /root/sparsefile
root@freenas2:~ # zpool status -v testpool
  pool: testpool
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
   Sufficient replicas exist for the pool to continue functioning in a
   degraded state.
action: Online the device using 'zpool online' or replace the device with
   'zpool replace'.
  scan: none requested
config:

   NAME											STATE	 READ WRITE CKSUM
   testpool										DEGRADED	 0	 0	 0
	 raidz1-0									  DEGRADED	 0	 0	 0
	   5574075682424664614						 OFFLINE	  0	 0	 0  was /root/sparsefile
	   gptid/dee8fa86-c056-11e8-90eb-002590caf340  ONLINE	   0	 0	 0
	   gptid/e1e2ba67-c056-11e8-90eb-002590caf340  ONLINE	   0	 0	 0

errors: No known data errors


Now export the pool using zpool export testpool, and import it through the GUI. Once the missing disk is available, you can replace it into the pool using the GUI.
Author
danb35
Views
64,348
First release
Last update
Rating
5.00 star(s) 6 ratings

More resources from danb35

Latest reviews

Super helpful.
I had a Stripe pool of 2x 6TB disks that I considered "expendable" if it failed (only movies, shows, etc) but then I growed my RAIDZ pool from 8TB to 6TB and was left with a spare 6TB drive - suddenly that Stripe could be a RAIDZ too...

So I offloaded most of the data to the bigger pool, created a temporary Stripe on the spare drive for the rest that did not fit.
Then after having duplicated all of the data elsewhere, I destroyed the 2x6 Stripe, created 3x6 degraded RAIDZ, copied data from the temp Stripe, replaced the sparse file with the spare and let it resilver, and finally copied the rest of the data to the now-fully healthy RAIDZ :)
I know how to do this, and why to do this, but its very very useful having the recipe outlined this clearly.

I did notice that I don't seem to be able to replace a "FILE" disk in the GUI using CORE 12U8-1 unfortunately.

The CLI works fine with a GUI imported pool though.

[code]
zpool replace testpool /root/<sparsefilename> gptid/<guid>
[/code]
Best warning ever and excellent follow-up:
If you're going to write down instructions that people should never follow, then write them in a clear and complete manner.
Wanted to say thanks for this, very useful advice for a super niche case most people probably won't (and shouldn't) really need!

In my own use-case I had an awkward juggling match to deal with; when I got my four bay box, in an ideal world I would have got four disks and just setup a RAIDz2 on day one (for half capacity with two disk redundancy and maximum read performance not a concern) but because of the disk prices at the time it wasn't within my budget to get four smaller drives, biggers ones were better value but I could only get two so had to go for a basic mirrored pair.

Fast forward to when I can afford another two and my choice was either add another mirrored pair and just accept single disk (guaranteed) redundancy, or use what your guide showed. In my case I created a RAIDz2 with two disks and two sparse files, offlined both files, copied my data into the degraded pool, then replaced the sparse files with the disks from the original mirror one at a time.

While doing it this way meant there were technically always two full copies it was still pretty hair-raising, but my offsite backup doesn't keep as many historic snapshots so I really wanted to preserve them if I could.
Excellent resource! Thank you so much! In my case, I have a backup of all data, so this is a safer way of creating the pool without going down to one copy of my data.
Excellent instructions for something most people should never, ever do - but if you're going to point a loaded gun at your own foot, this at least gives you a chance not to blow off your toes.
Top