• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Swapon Fails To Mount Swap – Gives Invalid Argument Error

by admin

The Problem

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

Example:

# swapon -a
swapon: /dev/md2: Invalid argument

The 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

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to disable ssh for non-root users (allowing ssh only for root user)
  2. flash Command Examples in Linux
  3. route: command not found
  4. qrcp Command Examples in Linux
  5. How to Back Up and Restore XFS File Systems (xfsdump / xfsrestore)
  6. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 7 to scan more than 16,383 LUNs
  7. How to resize (extend) a partition-based file system in Linux
  8. CentOS / RHEL 7 : How to configure cache-only nameserver
  9. The System Continuously Displayed the Error Message from the “avahi-demon” in /var/log/messages
  10. apt-mark: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright