红联Linux门户
Linux帮助

使用dd添加swap大小

发布时间:2014-07-14 16:17:13来源:红联作者:velcbo
当前swap是5951M,创建一个512M的空文件

[root@linux ~]# free -m
total used free shared buffers cached
Mem: 3947 793 3154 0 15 367
-/+ buffers/cache: 410 3537
Swap: 5951 651 5300
[root@linux ~]#
[root@linux ~]# dd if=/dev/zero of=/swap_mount bs=1024 count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 1.49614 seconds, 359 MB/s
[root@linux ~]#
[root@linux ~]# ls -h /swap_mount
/swap_mount
[root@linux ~]# ls -hl /swap_mount
-rw-r--r-- 1 root root 512M Jan 24 14:43 /swap_mount

把swap_mount挂载到swap上

[root@linux ~]# mkswap /swap_mount
Setting up swapspace version 1, size = 536866 kB
[root@linux ~]# swapon /swap_mount
[root@linux ~]#
[root@linux ~]# free -m
total used free shared buffers cached
Mem: 3947 1317 2630 0 16 885
-/+ buffers/cache: 415 3532
Swap: 6463 651 5812
[root@linux ~]#

添加到开机自动挂载

[root@linux ~]# echo "/swap_mount swap swap defaults 0 0" >> /etc/fstab
[root@linux ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/swap_mount swap swap defaults 0 0

作者:staricqxyz
文章评论

共有 0 条评论