Linux Move swap space from one location to another location

‮al.www‬utturi.com
Linux Move swap space from one location to another location

To move swap space from one location to another on a Linux system, you will need to follow these steps:

  1. Check the current location of the swap space using the swapon command:
swapon -s

This will display the name of the swap file or partition, as well as its size and priority.

  1. Deactivate the current swap space using the swapoff command:
swapoff -a

This will deactivate all swap spaces on the system.

  1. Create a new swap file or partition in the desired location. You can do this using the dd command to create a swap file, or by creating a new partition using a tool such as fdisk or parted.

  2. Activate the new swap space using the swapon command, followed by the name of the new swap file or partition:

swapon /path/to/new/swap
  1. Update the /etc/fstab file to reflect the new location of the swap space. Open the /etc/fstab file in a text editor and locate the line for the swap space. Replace the old path with the new path, then save and close the file.

  2. Check that the new swap space is active using the swapon command:

swapon -s

This should display the new swap file or partition, along with its size and priority.

Keep in mind that moving swap space can have consequences on the performance and stability of your system, so it is recommended to make a backup of your data before proceeding. It is also a good idea to test the new swap space thoroughly to ensure that it is working correctly.

For more information on managing swap space on a Linux system, you can refer to the documentation or man pages for the swapon, swapoff, and fstab commands.

Created Time:2017-10-30 10:17:36  Author:lautturi