1. 程式人生 > >Swap故障一例

Swap故障一例

swap

錯誤:swapoff: /dev/dm-1: swapoff failed: Cannot allocate memory

解決方法:

[root@jrgc ~]# swapon -s
Filename                                Type                 Size         Used     Priority
/dev/dm-1                              partition            3145724       1524700    -1
[root@jrgc ~]# swapoff /dev/dm-1
swapoff: /dev/dm-1: swapoff failed: Cannot allocate memory
[root@jrgc home]# dd if=/dev/zero of=/home/swap bs=1024 count=512000
512000+0 records in
512000+0 records out
524288000 bytes (524 MB) copied, 1.2637 s, 415 MB/s
[root@jrgc home]# mkswap /home/swap
mkswap: /home/swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 511996 KiB
no label, UUID=155bb4be-29cb-4e95-9581-24e11be6188f
[root@jrgc home]# swapon /home/swap
[root@jrgc home]# free -m
                    total       used       free     shared    buffers     cached
Mem:                 3832       3550       282          0          4        166
-/+ buffers/cache:   3378       453
Swap:                3571       1495       2076
[root@jrgc home]# swapoff /dev/dm-1
[root@jrgc ~]# free -m
                    total       used       free     shared    buffers     cached
Mem:                 3832       3711        120          0          2         19
-/+ buffers/cache:   3689       143
Swap:                499        499          0
[root@jrgc home]# swapon /dev/dm-1
[root@jrgc home]# free -m
                    total       used       free     shared    buffers     cached
Mem:                3832       3717        114          0          1        25
-/+ buffers/cache:  3691       140
Swap:               3571       495         3076
[root@jrgc home]# swapoff /home/swap
[root@jrgc home]# free -m           
                    total       used       free     shared    buffers     cached
Mem:                3832       3725        106          0          0              15
-/+ buffers/cache:  3710       122
Swap:               3071       476         2595


Swap故障一例