Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

when I do the:

     mkswap /dev/sda3
     mkswap: error: /dev/sda3 is mounted; will not make swapspace.

how to perfrom mkswap anyway , David

share|improve this question

"Swap off - swap on, Daniel-San", said Miyagi in Karate Kid.


What are you trying to do? Recreate swap space for an existing swap partition? Add more swap space by nuking an existing other partition? Please be way more specific. If you are for some reason recreating an already existing swap partition, use

swapoff /dev/sda3
mkswap /dev/sda3
swapon /dev/sda3

With mkswap -f /dev/sda3 you can probably proceed, but please read carefully what the man page tells you about it:

Force - go ahead even if the command is stupid.  

In other words: if that partition contains something important, it WILL get nuked. I hope your next question isn't about restoring backups.

share|improve this answer

Are you sure you want to create swap on /dev/sda3? That message would imply that /dev/sda3 is already being used for a real filesystem and may contain data.

First, check whether /dev/sda3 is in use as a mounted filesystem by issuing the mount command. If /dev/sda3 is listed as a mounted filesystem stop, you pretty certainly don't want to do what you are trying to do.

If it is listed, and you still wish to proceed and erase all the data on the partition then you must first umount /dev/sda3 before you mkswap /dev/sda3.

If it is not listed then it is already swap, and is already in use. If you need to rebuild it (unlikely) then you must swapoff /dev/sda3 before you mkswap /dev/sda3.

Once you have a successful mkswap /dev/sda3, you must finally do swapon /dev/sda3.

Remember to also edit your /etc/fstab to reflect the change of use of /dev/sda3.

share|improve this answer
I must learn to be as polite as you. :-) – Janne Pikkarainen Jul 25 '11 at 11:37
You can check if it is already used as swap with cat /proc/swaps – Kl4m Dec 31 '11 at 9:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.