3

when I do the:

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

how to perfrom mkswap anyway , David

2 Answers 2

7

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

Err.

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.

2

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.

2
  • I must learn to be as polite as you. :-) Jul 25, 2011 at 11:37
  • You can check if it is already used as swap with cat /proc/swaps
    – Kl4m
    Dec 31, 2011 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .