在linux下增加分区及查看swap分区

时间:2023-03-26 15:18:15 来源:爱钻网 编辑:tkgame 浏览:

Java代码 
1.查看系统Swap空间使用 
 
[root@jumper usr]# free 
             total       used       free     shared    buffers     cached 
Mem:        513980     493640      20340          0     143808     271780 
-/+ buffers/cache:      78052     435928 
Swap:      1052248      21256    1030992 
 
2.在空间合适处创建swap文件 
 
[root@jumper usr]# mkdir swap 
[root@jumper usr]# cd swap 
[root@jumper swap]# dd if=/dev/zero of=swapfile bs=1024 count=1000000  //增加1G 
10000+0 records in 
10000+0 records out 
[root@jumper swap]# ls -al 
total 10024 
drwxr-xr-x    2 root     root         4096  7月 28 14:58 . 
drwxr-xr-x   19 root     root         4096  7月 28 14:57 .. 
-rw-r--r--    1 root     root     10240000  7月 28 14:58 swapfile 
 
 
[root@jumper swap]# mkswap swapfile 
Setting up swapspace version 1, size = 9996 KiB 
 
 
3.激活swap文件 
[root@jumper swap]# swapon swapfile 
[root@jumper swap]# ls -l 
total 10016 
-rw-r--r--    1 root     root     10240000  7月 28 14:58 swapfile 
[root@jumper swap]# free 
             total       used       free     shared    buffers     cached 
Mem:        513980     505052       8928          0     143900     282288 
-/+ buffers/cache:      78864     435116 
Swap:      1062240      21256    1040984 
 
、若要想使开机时自启用,则需修改文件/etc/fstab中的swap行: 
  
/root/swap/swapfile swap swap defaults 0 0 

声明:优质手游攻略创作不易,来源:爱钻网。转载务必注明出处:http://www.aizuanapp.com/article/15680.html

① 扫二维码或添加微信号:sjyou_com 关注"爱钻网"

② 领取游戏礼包、手游攻略、新游推荐、游戏陪玩、原创测评

③ 赶紧扫一扫添加吧,Get手游技巧~

评论