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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Move Swap From Disk Partition to LVM Volume in Linux

by admin

There is no command or method exists that allows you to move swap space from one location to another. You can turn off the current swap space with swapoff command in the original location.

1. Turn swapoff on old disk:

# swapoff /dev/device
Note – Assuming there is free space in volume group, we will continue with LVM volume creation. Also, ensure that you do this when you have a maintenance window. (All applications are not running)

2. Create LVM Partition:

# lvcreate -L  -n logical_volume vol_group

3. Format the new swap space:

# mkswap /dev/[vg_name]/[lv_name]

4. Test that the swap has been created on logical volume.

# cat /proc/swaps

5. Enable the extended logical volume:

# swapon /dev/[vg_name]/[lv_name]

6. Add the swap entry in /etc/fstab.

Filed Under: Linux

Some more articles you might also be interested in …

  1. Ngrok how to share localhost to world
  2. CentOS / RHEL 6 : How to disable Transparent Huge pages (THP)
  3. emerge Command Examples in Gentoo Linux
  4. cradle deploy: Manage Cradle deployments
  5. LVM Configuration : Physical Volume (PV) Operations/Utilities
  6. How to disable swap in Linux
  7. chage: command not found
  8. flatpak Command Examples in Linux
  9. eval: Execute arguments as a single command in the current shell and return its result
  10. complete: Provides argument autocompletion to shell commands

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright