swapon failed: Device or resource busy on mounted disk
Solution 1
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.
Solution 2
The problem is not adding the swap; the problem is your assumption that all swap space shows up in the output of df
.
Only partition-type data shows up in that, and as you're using in-system swapping, aka a swapfile, it doesn't show up. The swap space was activated by the first swapon
you did; you were just looking in the wrong place to confirm that. The second swapon
failed, quite rightly, because you can't add the same file a second time. When you looked in /proc/swaps
, which is the definitive system summary of all swap space, you saw that your new space was up and running.
Solution 3
You need to sync
out the block cache after the mkswap
command.
Its explanation is the following.
If you write data, but they aren't written out into the disk physically, they will be dirty pages. It means, that their content was created here, on your system, and wasn't read in from the hard disk. Thus you can't swap on dirty pages.
Related videos on Youtube

SantiArias
Updated on September 18, 2022Comments
-
SantiArias 4 months
I recently started to learn React in more depth, and something is triggering me because I cant understand this syntax (I know is a ES6 thing)
So I got this component, lets call it and this component will receive an onClick function as a prop with one param, so we have <Component onClick={() => handleClick("clicked")}/>
This Component, has a callAll function and is implemented like this
const callAll = (...fns) => (...args) => fns.forEach(fn => fn && fn(...args)) const Component = ({children: child}) => { return React.cloneElement(child, { onClick: callAll(() => setIsOpen(true), child.props.onClick), }) }
My question is where does the ...args come from, in the sense of how does the inner function of 'callAll' receive all the args of each specific function magically just by typing '...args'?
I hope I explained myself, thanks!
-
poc over 7 yearsyour solution not works :(
-
peterh over 7 years@poc In similar cases it is the solution, but MadHatter's idea seems very fruitful.
-
Philippe Remy over 2 yearsIt works for me.
-
SantiArias over 1 yearSo, if I understand only the event object will be passed? If I use the component like in my example <Component onClick = {() => handleClick("clicked")}/> , the handleClick function will be called by callAll but the "clicked" param would be lost? If not, what I do not understand is how the ...args spread "exctracts" the params of each function call
-
T.J. Crowder over 1 year@SantiArias - The call to
callAll
creates a function. Whatever calls that function is what sets theargs
that the function sees. So if you hook it up directly (onClick={theFunctionFromCallAll}
), it'll receive the event object. If you hook it up indirectly (onClick={() => theFunctionFromCallAll("click");}
), it'll receive"click"
. -
SantiArias over 1 yearOk I think I get it now, thank you for your time!