• 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

mkswap Command Examples in Linux

by admin

The mkswap command is used to create swap space on a storage partition. It is typically used when you wish to move swap space to a different partition than the one that was created during system installation. For example, you might want to save space on a low-capacity boot drive.

It provides options to perform various tasks.

Option Used To
-c Verify that the device is free from bad sectors before mounting the swap space.
-p Set the page size to be used by the mkswap command. A page is a chunk of memory that is copied to the storage device during the swap process.
-L {label} Activate the swap space using labels applied to partitions or file systems.

mkswap Command Examples

1. To make the swap:

# mkswap /dev/sdf 

2. To check the device (if it is a block device) for bad blocks:

# mkswap -c /dev/sdf 

3. To Force – go ahead even if the command is stupid:

# mkswap -f /def/sdf 

4. To Specify the page size to use:

# mkswap -p PAGESIZE 

5. To specify a label, to allow swapon by label:

# mkswap -L LABEL 

6. To specify the swap space version:

# mkswap -v0
# mkswap -v1 

7. To specify the UUID to use:

# mkswap -U UUID 

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 6 : How to disable Transparent Huge pages (THP)
  2. find WWN Number of HBA Card in Redhat Linux and CentOS
  3. CentOS / RHEL : How to find kernel parameters used while booting
  4. hostname Command Examples in Linux
  5. CentOS / RHEL 6 : How to force a NTP sync with the NTP server(s)
  6. lvresize command examples in Linux
  7. Understanding rsyslog Templates
  8. Unable to Run X Applications Through SSH in Linux
  9. Monitor HDD and SSD with smartd and smartctl
  10. pvcreate error : Can’t open /dev/sdx exclusively. Mounted filesystem?

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright