Ubuntu – swapon failed: Device or resource busy on mounted disk

Ubuntu

I want to make a swap on mounted external EBS, /workspace

And I got Device or resource busy

swapon: /workspace/swap.1: swapon failed: Device or resource busy

sudo /bin/dd if=/dev/zero of=/workspace/swap.1 bs=1M count=10240
sudo /sbin/mkswap /workspace/swap.1
sudo /sbin/swapon /workspace/swap.1


Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      7.8G  5.1G  2.3G  70% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            2.0G   12K  2.0G   1% /dev
tmpfs           396M  336K  395M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/xvdb       6.0T  1.7T  4.1T  29% /workspace

Still not working after running sync command

➜  ~  sync
➜  ~  sudo /sbin/swapon /workspace/swap.1
swapon: /workspace/swap.1: swapon failed: Device or resource busy

Here's the swap information

➜  ~   cat /proc/swaps
Filename                Type        Size    Used    Priority
/workspace/swap.1                       file        10485756    0   -1

Best Answer

I had a similar issue trying to make a swap partition on sda2. My solution was to type

#: swapoff /dev/sda2
#: mkswap /dev/sda2
#: swapon /dev/sda2

This seemed to reset whatever issue I was having. To make sure this worked, use "lsblk" to check the mountpoint.

Related Topic