Debian设置交换内存

归云
归云
发布于 2022-08-30 / 2226 阅读
0
0

Debian设置交换内存

  • 创建交换文件
fallocate -l 2G /swapfile
  • 设置权限
chmod 600 /swapfile
  • 在Linux创建swap
mkswap /swapfile
  • 激活交换分区
swapon /swapfile

永久设置交换内容

编辑这个文件vim /etc/fstab

# /etc/fstab: static file system information.
#
# 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/vda1 during installation
UUID=28507de7-6bf8-4229-b994-4169fdba432e /               ext4    errors=remount-ro 0       1
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0
/swapfile swap swap defaults 0 0

激活交换分区

swapon --show

检测

root@localhost:~# free -h
               total        used        free      shared  buff/cache   available
内存:      3.7Gi       2.9Gi       226Mi       116Mi       601Mi       482Mi
交换:      2.0Gi          0B       2.0Gi

交换内存已设置成功


评论