UFS device busy trying to remove partition

The situation is the following:
Code:
# lsblk
DEVICE      MAJ:MIN SIZE TYPE               LABEL MOUNT
da0           0:92   36G GPT                    - -
  <FREE>      -:-    33M -                      - -
  da0p3       0:95  1.0G freebsd-swap  gpt/swapfs -
  <FREE>      -:-    37G -                      - -
md0           0:106 4.0G ufs                    - /

I want to delete da0p3. So I try that:
sh:
# gpart delete -i 3 da0
gpart: Device busy

Ok, maybe I need to turn off swap?
sh:
# swapoff /dev/da0p3
swapoff: /dev/da0p3: Invalid argument

So swap is already turned off. Maybe it is mounted somewhere?
sh:
# mount
/dev/md0 on / (ufs, local, soft-updates)
devfs on /dev (devfs)

Looks like it also isn't mounted. At this point I have no clue how to delete this partition. Any ideas?

I am running FreeBSD 14.1. I moved the filesystem to a RAM disk so I could delete the current filesystem and re-do it.
 
What does swapinfo show? Did you already remove the swap from fstab?

Swap isn't mounted, it's not a filesystem.
Code:
# swapinfo
Device          1K-blocks    Used   Avail Capacity
/dev/gpt/swapfs   1048576  564040  484536    54%

Fstab:
Code:
# cat /etc/fstab
# custom /etc/fstab for FreeBSD VM images
/dev/gpt/rootfs    /    ufs    rw    1    1
#/dev/gpt/swapfs    none    swap    sw    0    0
#/dev/gpt/efiesp    /boot/efi    msdosfs    rw    2    2
 
I allocated too much for my RAM disk, so the swap refused to turn off.
Yes. That certainly won't help. It had 54% in use, and it tried to put it back to memory in order to be able to remove the swap. You obviously can only remove swap if it's not active. If you leave the entry in fstab you can easily turn it off with swapoff -a (provided there's enough free memory of course).
 
Back
Top