"Operation not permitted" when trying to wipe disks

Not open for further replies.
Aug 10, 2018
tl;dr: How can I wipe a disk?

I'm running FreeNAS 11.1-u5, I imported the config from another FreeNAS install that was attached to another volume so as to get all of the previously configured users and groups and I'm trying to setup a new mirrored ZVOL with two 1TB disks that I had previously deleted the existing partitions of using parted in linux but the process fails during the initial wipe phase.

It appears that FreeNAS has created itself a swap partition on one of the blank disks and, no matter what I do to the FreeNAS config or to the disk, I can't get it to relinquish the disk.

I managed to successfully wipe one of the disks from the webGUI after enabling 'shoot myself in the foot mode' in the shell with: sysctl kern.geom.debugflags=16 but the other disk still fails with an error and if I attempt to delete its partitions with gpart, it reports that it is busy.

If I try and wipe in the webGUI, I get:

[MiddlewareError: Failed to wipe ada3p1: dd: /dev/ada3p1: Operation not permitted]

If I try and inspect from the shell I notice that there is a (live) swap partition on ada3 but disabling it does not make any difference to the above errors when attempting to wipe.

root@freenasbackup:~ # mount -v
freenas-boot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid 17f017f6dea35f55)
devfs on /dev (devfs, local, multilabel, fsid 00ff007171000000)
tmpfs on /etc (tmpfs, local, fsid 01ff008787000000)
tmpfs on /mnt (tmpfs, local, fsid 02ff008787000000)
tmpfs on /var (tmpfs, local, fsid 03ff008787000000)
freenas-boot/grub on /boot/grub (zfs, local, noatime, nfsv4acls, fsid ef7017c9dee2386c)
fdescfs on /dev/fd (fdescfs, fsid 05ff005959000000)
tmpfs on /var/db/collectd/rrd (tmpfs, local, fsid 06ff008787000000)

root@freenasbackup:~ # gpart show ada3
=>		40  1953525088  ada3  GPT  (932G)
		  40		  88		- free -  (44K)
		 128	 4194304	 1  freebsd-swap  (2.0G)
	 4194432  1949330696		- free -  (930G)

I tried setting Swap size to 0 in the GUI System->Advanced settings and saving and rebooting but it doesn't appear to actually disable swapping - the swap was remounted on reboot and present in /etc/fstab. I tried manually writing over the GPT and swap partition with 2.5GB of zeroes by putting the disk into a linux system (which was unable to see any partitions at all) and running dd if=/dev/zero of=/dev/sdb bs=1M count=2500 - this made no difference, booting back up with FreeNAS showed the same 2GB freebsd-swap partition had been created and mounted again.

Attempting to disable swapping in the shell and then deleting the partitions using GPART is met with 'device busy' although I can't see with what.

root@freenasbackup:~ # swapoff -a
swapoff: removing /dev/ada3p1.eli as swap device
root@freenasbackup:~ # swapctl -l
Device:	   1024-blocks	 Used:
root@freenasbackup:~ # gpart create -s GPT ada3
gpart: geom 'ada3': File exists
root@freenasbackup:~ # gpart delete -i 1 ada3
gpart: Device busy
root@freenasbackup:~ # gpart destroy -F ada3
gpart: Device busy
root@freenasbackup:~ # fstat /dev/ada3
root@freenasbackup:~ # lsof /dev/ada3
lsof: WARNING: compiled for FreeBSD release 11.0-RELEASE; this is 11.1-STABLE.
root@freenasbackup:~ # dd if=/dev/zero of=/dev/ada3 bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes transferred in 0.559097 secs (187548300 bytes/sec)
root@freenasbackup:~ # ls /dev | grep ada3
root@freenasbackup:~ # gpart delete -i 1 ada3p1
gpart: arg0 'ada3p1': Invalid argument
root@freenasbackup:~ # gpart delete -i 2 ada3
gpart: index '2': No such file or directory
root@freenasbackup:~ # gpart delete -i 3 ada3
gpart: index '3': No such file or directory
Last edited:


Oct 31, 2014
I've run into similar problems re-using disks that had previously been used in a ZFS system. It turns out that some of the ZFS metadata is actually stored in the last sectors of the disk.

You were on the right track using dd to zero out the first part of the drive, but you also need to do that to the end of the disk.

Start by using fdisk to find the sector size and count:
fdisk -l /dev/sdc

Disk /dev/sdc: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 98AE0AD3-352A-4341-A706-897D7AF063C8

Then zero out the last 100 sectors of the drive using the seek setting of dd to jump to the end (subtract 100 from the total sector count):
dd if=/dev/zero of=/dev/sdc bs=512 count=100 seek=976773068 
Not open for further replies.