禁用交换内存,如何再次启用?

禁用交换内存,如何再次启用?

我跑了sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab sudo swapoff -a

这导致没有使用交换内存,从 2 GB 降至 2 GB。(我有 24 GB 的 RAM)。

/etc/fstab

#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=0446af6d-0bd1-4811-91e7-7663019eecad /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=343C-7C17  /boot/efi       vfat    umask=0077      0       1
# /swapfile                                 none            swap    sw              0       0    

答案1

在 /etc/fstab 中注释掉与交换相关的行:

sed -i '/ swap / s/^#\(.*\)$/\1/g' /etc/fstab

然后再次启用交换:

swapon -a -v

选项 -v 告诉您更多信息,操作是否成功

相关内容