阿里云服务器设置swap交换分区
Posted 杨雪之
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云服务器设置swap交换分区相关的知识,希望对你有一定的参考价值。
root@Ubuntu ~
# cd /var/ [22:26:23]
root@Ubuntu /var
# dd if=/dev/zero of=/var/blockd.swap bs=1M count=4096 [22:27:06]
4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 35.9325 s, 120 MB/s
root@Ubuntu /var
# mkswap swapfile [22:31:03]
mkswap: cannot open swapfile: No such file or directory
root@Ubuntu /var
# /sbin/mkswap swapfile [22:31:55]
mkswap: cannot open swapfile: No such file or directory
root@Ubuntu /var
# mkswap blockd.swap [22:32:13]
mkswap: blockd.swap: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
no label, UUID=3ee0b5e8-a807-4c60-aa67-f2626889ff74
root@Ubuntu /var
# swapon /var/blockd.swap [22:32:35]
swapon: /var/blockd.swap: insecure permissions 0644, 0600 suggested.
root@Ubuntu /var
# /sbin/swapon -s [22:33:27]
Filename Type Size Used Priority
/var/blockd.swap file 4194300 0 -2
root@Ubuntu /var
# vim /etc/fstab [22:33:57]
root@Ubuntu /var
# vim /etc/sysctl.conf
root@Ubuntu ~
# swapon -s [22:42:14]
Filename Type Size Used Priority
/var/blockd.swap file 4194300 0 -2
root@Ubuntu ~
# cat /proc/sys/vm/swappiness [22:44:56]
60
root@Ubuntu ~
# df -hl [22:45:08]
Filesystem Size Used Avail Use% Mounted on
udev 965M 0 965M 0% /dev
tmpfs 199M 660K 199M 1% /run
/dev/vda1 40G 9.4G 29G 25% /
tmpfs 994M 0 994M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 994M 0 994M 0% /sys/fs/cgroup
tmpfs 199M 0 199M 0% /run/user/0
以上是关于阿里云服务器设置swap交换分区的主要内容,如果未能解决你的问题,请参考以下文章