歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 使用dd添加swap大小

使用dd添加swap大小

日期:2017/2/28 14:53:08   编辑:Linux教程

當前swap是5951M,創建一個512M的空文件

[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 3947 793 3154 0 15 367
-/+ buffers/cache: 410 3537
Swap: 5951 651 5300
[[email protected] ~]#
[[email protected] ~]# 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
[[email protected] ~]#
[[email protected] ~]# ls -h /swap_mount
/swap_mount
[[email protected] ~]# ls -hl /swap_mount
-rw-r--r-- 1 root root 512M Jan 24 14:43 /swap_mount

把swap_mount掛載到swap上

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

添加到開機自動掛載

[[email protected] ~]# echo "/swap_mount swap swap defaults 0 0" >> /etc/fstab
[[email protected] ~]# 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

Copyright © Linux教程網 All Rights Reserved