Replacing a drive using CLI - what happens to swap-partition and ashift on new drive?

Status
Not open for further replies.

StephenFry

Contributor
Joined
Apr 9, 2012
Messages
171
This afternoon I assisted a panicked friend who had a failed HDD in his FreeNAS and it led me to an interesting question. To me, at least, because I don't know the answer...

He uses 9.2.1.9, the last 32-bit version, for reasons I'm not aware of.
The setup is a 4-drive RAID-Z2. Again, I don't know why, but that's not the issue here.
He had already pulled the failed drive and put a new drive in its place.

The reason for his panic was that the GUI, which I told him to use, didn't offer the options it normally does in this case. I verified and indeed, the GUI was of no help. It said the pool was degraded, but all drives showed online and there was nothing to take offline, all very weird. No idea why and there was no time to find out, there was a problem to fix, and that I did. OR DID I?

I used the CLI to offline the old drive, and online the new drive. It resilvered immediately and all was fine and dandy. OR WAS IT?

My friend was happy and I was feeling pretty good about myself, until I started having doubts about what I did and performed a simulation on a virtual FreeNAS of exactly this scenario.

The results are that 'gpart show' tells me only 3 drives have a freebsd-swap of 2 gigabyte. Should I have manually created a swap partition?
Also, even though the pool was created with an ashift of 12, and still reports this is the case, shouldn't I have manually controlled/checked this? Especially on pools with mixed 512/4K drives, this makes sense.

As usual, my enthusiasm wasn't tempered by any actual knowledge. How would I have gone about this *properly* on the CLI?
 

StephenFry

Contributor
Joined
Apr 9, 2012
Messages
171
Thanks for that, I guess. But I fail to understand how it is pertinent.

The GUI was completely useless and nowhere in the entire doc does it say anything about manually creating a swap partition or setting an ashift on a replacement drive.

Maybe this isn't necessary at all, but it also doesn't say that - and it's a reasonable question, I feel, from someone with enough knowledge to wonder about it, but not enough to realize what exactly is going on.
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
When you replace or add drives, the creation of a swap partition is governed by the status of the relevant GUI setting (I forget exactly where the setting lives). If it's non-zero, you get a swap partition, if it's 0 you don't.

ashift is a property of the pool, not individual drives.
 

StephenFry

Contributor
Joined
Apr 9, 2012
Messages
171
Interesting, thank you. Because of the damaged/non-working GUI in this particular strange case, the new drive doesn't have a swap partition, even though it is set in the GUI.

Everything seems to be working well enough, so I'm leaving it alone for now. Should be easy to fix with an new/upgraded FreeNAS installation and another 'refresh' of this drive.
 
Joined
Jul 3, 2015
Messages
926
Its a good question. I discovered the same thing recently but I was creating the pool and replacing disks from the CLI so that I could use label each drive as I had quite a lot of them. It seems that when you create a pool from the UI it sorts all this stuff out for you so if you want to let FreeNAS do its thing (which I recommend) but at the same time have a requirement to manage the pool from the CLI I'd suggest next time you create a new pool from the UI using the new replacement disk and then detach the volume but DO NOT mark disks as new. Then when replacing from the CLI be sure to add the -f as the disk is already a member of a pool. Its still worth noting that the swap won't expand until you next restart your machine or if you wish export and import the pool from the UI.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Its a good question. I discovered the same thing recently but I was creating the pool and replacing disks from the CLI so that I could use label each drive as I had quite a lot of them. It seems that when you create a pool from the UI it sorts all this stuff out for you so if you want to let FreeNAS do its thing (which I recommend) but at the same time have a requirement to manage the pool from the CLI I'd suggest next time you create a new pool from the UI using the new replacement disk and then detach the volume but DO NOT mark disks as new. Then when replacing from the CLI be sure to add the -f as the disk is already a member of a pool. Its still worth noting that the swap won't expand until you next restart your machine or if you wish export and import the pool from the UI.
Huh don't do this, it's nonsense. Use the gui! It sounds kind you just couldn't find the replace button. You can still offline the messed up drive and replace it to get the gptid and swap file correct. You should probably do this so your friend has a system that is expected and nothing crazy for when the next thing goes wrong.

Sent from my Nexus 5X using Tapatalk
 
Joined
Jul 3, 2015
Messages
926
I agree, use the UI where possible but the OP said his UI went weird hence why he did what he did. There is an argument however to say perhaps you should have sorted your UI issue first before replacing the disk on CLI. I find service nginx restart and service django restart sort most UI weirdness but failing that a restart.
 
Joined
Jul 3, 2015
Messages
926
Status
Not open for further replies.
Top