Swapon Fails To Mount Swap – Gives Invalid Argument Error

Symptoms will include (but are not limited to):

  • After turning off swap or after a reboot, one or more swap partitions fail to mount
  • Issuing the swapon command to mount the failed partition results in an Invalid argument error

 

Solution

 

The affected swap partition has been deleted or has become corrupt.

 

1. Ensure swap is really off for the problem partition.

# swapoff /dev/md2

 

Alternately, you can use “swapoff -a” to turn off all swap partitions.

 

2. Create a new file system on the target device. The -c flag checks for bad blocks.

# mke2fs -c /dev/md2

 

If creating the file system fails due to bad blocks, the actual device may be bad. In this case, you may need to contact RedHat support for recovery.

 

3. Create the swap partition on the new file system.

# mkswap /dev/md2

 

4. Turn the new swap on.

# swapon /dev/md2

 

Alternately, you can use “swapon -a” to turn on all swap partitions.

# swapon -a

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)