1)在linux下,首先,查看内存和swap大小:
[root@rhel6 usr]# free -m
Mem:
-/+ buffers/cache:
Swap:
2)创建swap文件:
[root@rhel6 usr]# mkdir swap
[root@rhel6 usr]# cd swap/
[root@rhel6 swap]# dd if=/dev/zero of=swapfile bs=402400
count=10000
记录了10000+0 的读入
记录了10000+0 的写出
4024000000字节(4.0 GB)已复制,224.925 秒,17.9 MB/秒
[root@rhel6 swap]# ls -al
总用量 3929700
drwxr-xr-x.
drwxr-xr-x. 15 root root
-rw-r--r--.
[root@rhel6 swap]# mkswap swapfile
mkswap: swapfile: warning: don't erase bootbits sectors
Setting up swapspace version 1, size = 3929680 KiB
no label, UUID=4e2ce2fe-3963-46ce-90cd-466495cd8ca8
3)激活swap文件:
[root@rhel6 swap]# swapon swapfile
[root@rhel6 swap]# free -m
Mem:
-/+ buffers/cache:
Swap:
4)若想要开机时自启动,需要修改文件/etc/fstab中的swap行:
[root@rhel6 swap]# vi /etc/fstab
UUID=8c6bea6a-3bba-4594-b5a8-fd4afd311476 swap
ts
/usr/swap/swapfile
ts
jesus love you! |
|