Friday, May 18, 2018

partitioning - How can I remove a swap partition on FreeNAS?

I have a FreeNAS 11.1-U6 installation for testing purposes. It has two 500GB SSDs and one 4TB USB drive. I installed FreeNAS to ada0 (the first 500GB SSD) and set up a volume on da0 (the 4TB drive) with the ada1 (the second 500GB SSD) as an L2ARC.


That was all fine, but I wanted to restart from scratch. So, I deleted the volume (wiped it and treated it as "new"), and tried to create a new volume. That's when I hit some problems. When I tried to create a new volume, I got this error:


[MiddlewareError: Unable to GPT format the disk "da0": gpart: geom 'da0': File exists]

I did some reading and I found out how to delete partitions off of the drives, using gpart. I was able to clear da0, but not ada1:


[MiddlewareError: Unable to GPT format the disk "ada1": gpart: geom 'ada1': File exists]

But, I can't do what I did before with ada1, because I can't get rid of one of the partitions. Specifically, a swap partition.


root@stszfs:/ # gpart show ada1
=> 40 976773088 ada1 GPT (466G)
40 88 - free - (44K)
128 4194304 1 freebsd-swap (2.0G)
4194432 972578696 - free - (464G)

When I try to delete it, I get this:


root@stszfs:/ # gpart delete -i1 ada1
gpart: Device busy

When I try to destroy it, same thing:


root@stszfs:/ # gpart destroy -F ada1
gpart: Device busy

I still get this after running


swapoff -a

I also see in /etc/fstab I have this:


root@stszfs:/ # cat /etc/fstab
freenas-boot/grub /boot/grub zfs rw,noatime 1 0
fdescfs /dev/fd fdescfs rw 0 0
/dev/da0p1.eli none swap sw 0 0

I commented out the swap line and rebooted, and to no avail -- it was changed right back the way it was after a reboot. I can't find any evidence of any process using that swap partition. I tried using dd to destroy the drive, but that didn't work either:


root@stszfs:/ # dd if=/dev/zero of=/dev/ada1 bs=512
dd: /dev/ada1: Operation not permitted

So, a few questions. How did this swap partition get there? I was using this drive as L2ARC originally, so why does it suddenly have a swap partition there that can't be removed? How do I get rid of this pesky swap partition without booting to another OS to do it? (I don't have physical access to the box at the moment.)

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...