ubuntu lv swap扩展

swap在lv  /dev/ubuntu-vg/swap_1上

1.关闭交换分区swapoff,要保证剩余内存>=swap的used,自我感觉swap会释放到内存中.否则会报错swapoff failed: Cannot allocate memory

[root@testdb ~]# swapoff /dev/ubuntu-vg/swap_1   
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      14682       1398          0         83      13680
-/+ buffers/cache:        919      15162
Swap:            0          0          0
 
 
2.扩展 /dev/ubuntu-vg/swap_1,增加5G
 [root@testdb ~]# lvextend -L +5G /dev/ubuntu-vg/swap_1
  Logical volume swap_1successfully resized
 
 
3.将/dev/ubuntu-vg/swap_1 设置为swap分区
 [root@testdb ~]# mkswap /dev/ubuntu-vg/swap_1
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 17072124 KiB
no label, UUID=f5fa0e85-da9e-440c-8f1c-e3ab978c9d6b
 
4.启动swap分区
[root@testdb ~]# swapon /dev/ubuntu-vg/swap_1
[root@testdb ~]# free -m

total used free shared buffers cached
Mem: 5.8G 2.3G 3.5G 15M 40M 287M
-/+ buffers/cache: 2.0G 3.9G
Swap: 6.0G 0B 6.0G

 

 

posted @ 2017-05-31 15:18  wangxingg  阅读(429)  评论(0编辑  收藏  举报