如何撤消“mkswap”?

Zer*_*x18 2 swap

我的 mysql 有问题,我需要制作一个交换文件来修复它。我运行了这段代码

# dd if=/dev/zero of=/swap.dat bs=1024 count=512M
# mkswap /swap.dat
# swapon /swap.dat
## Edit the /etc/fstab, and the following entry.
/swap.dat      none    swap    sw      0       0 
Run Code Online (Sandbox Code Playgroud)

它制作了一个交换文件,我认为是 512mb。现在我的 VPS 说我正在使用 19.56gb 的 99.9%。

我试图运行swapoff /swap.dat/swap.dat从 /etc/fstab 中删除,但它仍然说我正在使用 99.9%

我无法安装任何其他软件,例如 gparted,因为它说设备没有剩余空间

小智 5

首先,从/etc/fstab. 然后:

sudo swapoff /swap.dat
# Wait for all resources paged to that swap file to be moved to other swap files or to RAM.
sudo rm -f /swap.dat
Run Code Online (Sandbox Code Playgroud)

如果在不再使用之前删除文件,则磁盘空间将保持分配状态,直到swapoff完成。