To remove a swap partition:
The hard drive can not be in use (partitions can not be mounted, and swap space can not be enabled). The easiest way to achieve this it to boot your system in rescue mode. Refer to Chapter 9 Basic System Recovery for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.
Alternately, if the drive does not contain any partitions in use, you can unmount them and turn off all the swap space on the hard drive with the swapoff command.
At a shell prompt as root, execute the following command to make sure the swap partition is disabled (where /dev/hdb2 is the swap partition):
swapoff /dev/hdb2 |
Remove its entry from /etc/fstab.
Remove the partition using parted or fdisk. Only parted will be discussed. To remove the partition with parted:
At a shell prompt as root, type the command parted /dev/hdb, where /dev/hdb is the device name for the hard drive with the swap space to be removed.
At the (parted) prompt, type print to view the existing partitions and determine the minor number of the swap partition you wish to delete.
At the (parted) prompt, type rm MINOR, where MINOR is the minor number of the partition you want to remove.
Warning | |
---|---|
Changes take effect immediately; you must type the correct minor number. |
Type quit to exit parted.
To remove a swap file:
At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file):
swapoff /swapfile |
Remove its entry from /etc/fstab.
Remove the actual file:
rm /swapfile |