Reuse disk, how?

Status
Not open for further replies.

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
I want to create a new pool on a disk which has an unused pool on it. (I migrated all my data from there to a new pool a while ago. The existing pool was just detached without destroying anything.)

What is the easiest way to do this?

I first tried to simply create a new pool on this disk but failed:
[MiddlewareError: Unable to GPT format the disk "ada2": gpart: geom 'ada2': File exists]

I then tried to wipe the disk:
[MiddlewareError: Failed to wipe ada2p1: dd: /dev/ada2p1: Operation not permitted]

I would have imported the old pool and then detached it with the destroy option. But I didn't dare to do this because it has the same name as an existing pool in my system.

After this I checked the guide to no avail.

Finally I'm here ...

EDIT: My Solution. FreeNAS was using the drive as swap device. I used gmirror list to identify which swap device was using the disk (in my case 'Name: mirror/swap0'). I determined the device name using swapinfo and found '/dev/mirror/swap0.eli' and deleted this using swapoff /dev/mirror/swap0.eli. (Note: I had to free memory to get this done because FreeNAS must relocate used swap space somewhere else. This should be easy after a reboot of FreeNAS.) After this I could wipe the disk (quick option didn't work, wiping with zeroes did work). After the wipe I could create a volume on the disk. The swap device got recreated automatically.
 
Last edited:

MrToddsFriends

Documentation Browser
Joined
Jan 12, 2015
Messages
1,338

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Go to View Disks and use the Wipe function to erase the disk before reusing it.
 

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
Thanks for the hints so far!

It seems the disk in question is part of some mirror for a swap device. gmirror list gets me a 'swap0' with consumers ada3p1 and ada2p1. ada2 is the disk I want to reuse. (There is another 'swap1' on other disks.) Output of the command see below.

I guess the 'Operation not permitted' message has some good reason. So now the question is whether / how I can remove this swap device from FreeNAS gracefully?

(I just checked the options in System / Advanced: 'Swap size on each drive in GiB, affects new disks only. Setting this to 0 disables swap creation completely (STRONGLY DISCOURAGED).' I don't expect setting this to 0 would remove swap from an existing drive, right?)

Code:
Geom name: swap0
State: COMPLETE
Components: 2
Balance: prefer
Slice: 4096
Flags: NONE
GenID: 0
SyncID: 1
ID: 1981354412
Type: MANUAL
Providers:
1. Name: mirror/swap0
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r1w1e1
Consumers:
1. Name: ada3p1
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r1w1e1
   State: ACTIVE
   Priority: 0
   Flags: NONE
   GenID: 0
   SyncID: 1
   ID: 3544806466
2. Name: ada2p1
   Mediasize: 2147483648 (2.0G)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r1w1e1
   State: ACTIVE
   Priority: 1
   Flags: NONE
   GenID: 0
   SyncID: 1
   ID: 2710069617

Geom name: swap1
[...]
 

Evertb1

Guru
Joined
May 31, 2016
Messages
700
I have not had this problem yet with a HD that has been a member of a ZFS pool yet. But I had similar problems with disks that have been part of a Raid set. I always transfer such a disk to an older PC without a Raid controller and boot the PC with Gandalf's boot CD (free download and you can put it on a bootable USB stick). I'ts based on Windows 10 PE and host a number of wel known tools to manage partitions etc. and execute a cleaning up. It should be possible do this within Windows with the clean command at the command prompt (an I assume there is an equivalen in Linux) but the tools on Gandalf's cd did not fail me yet.
 
Last edited:

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
Removing the disk and wiping on another PC would surely be the best way. It's just I don't have any PC HW available here. :-/
 

MrToddsFriends

Documentation Browser
Joined
Jan 12, 2015
Messages
1,338
Removing the disk and wiping on another PC would surely be the best way. It's just I don't have any PC HW available here. :-/

Would (temporarily) booting your NAS with an alternative OS image be an option?
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Removing the disk and wiping on another PC would surely be the best way. It's just I don't have any PC HW available here. :-/
Don't be sure of that. GPT partitioning support is still lacking on a lot of other operating systems.

If the built-in disk wipe functionality is not working correctly because swap is in use, that's a bug which needs to be fixed. Please enter a bug for the FreeNAS project at https://redmine.ixsystems.com/projects/freenas?jump=welcome and give the bug number in this thread.
 

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
I'm one step further: Using swapinfo I can see the swap devices. Using swapoff I should be able to remove the swap device (at least temporarily) on the disk I want to reuse. I tried this already however my FreeNAS denies the operation because the swap device is in use und the swapped memory cannot be allocated somewhere else. This should be no problem after a reboot. I will try and report here.

So I'm not even sure whether this is a bug. If I can get around the problem by removing the swap device this may just require some documentation in the Guide. Ok, the error message may be improved or the wipe disk feature may have some enhancement added to 'automagically' handle left over swap devices.
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Swap devices are now mirrored. So it is probably not enough to turn off swap on that drive, you must also remove it from the mirror. These are not ZFS mirrors, but gmirror(8) devices.

This should be handled by the system when a disk wipe is requested. If it is not, that's a bug.
 

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
Ok, a bug then. I cannot add an entry to redmine though! Every time I try to register redmine fails to deliver the activation email.
 

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
I stopped some memory intensive processes (iocage jails, bhyve) to reduce memory usage. Then I verified that the swap usage was indeed reduced significantly. So I removed one swap device using swapoff /dev/mirror/swap0.eli. This device was located on the disk I wanted to wipe. This took a few moments to relocate some of the swap contents. One swap device now remains on two other disks.

After this I retried to wipe the disk. This failed again with an 'operation not permitted' error. After selecting the option to wipe with zeroes (instead of quick) the wipe process is now running. I keep you posted ...
 

-fun-

Contributor
Joined
Oct 27, 2015
Messages
171
This worked. After the wipe was completed this morning I could create a new volume on the wiped disk. Immediately after this FreeNAS recreated the swap device I had deleted before automatically.
 
Status
Not open for further replies.
Top