linux shell脚本的编写-SWAP

#!/bin/bash
 echo "About SWAP!---1024M"
 #查看SWAP分区大小
 free -h
 #删除所有SWAP分区
 swapoff -a
 #新增SWAP分区,方法一:添加一个swap文件作为swap,这个是搬瓦工目前的默认做法
 #创建swap分区的文件
 #其中 bs是每块的大小,count是块的数量,bscount,就是swap文件的大小了,这里就是1M1024=1G。大家可以自己调整count的数量
 dd if=/dev/zero of=/root/swapfile bs=1M count=1024
 #格式化交换分区文件
 mkswap /root/swapfile
 #启用swap分区文件
 swapon /root/swapfile
 #添加开机启动
 #修改 /etc/fstab 这个文件
 #将/swap none swap sw 0 0 这行注释掉,应该不注释也不影响.可百度查找shell脚本注释指定文件的指定行
 #新增一行/root/swapfile swap swap defaults 0 0
 echo "">>/etc/fstab
 echo "/root/swapfile swap swap defaults 0 0">>/etc/fstab
# Linux系统上可以同时有多个swap,用swapon -s命令可以看到系统上所有的swap,用free命令看到的是swap总的大小。所以swap不够用时可以再建立一个swap,一般可以用文件的方式建立一个swap空间  
swapon -s

以上  新建一个shell脚本wpswap.sh

给文件添加可执行权限 chmod u+x wpswap.sh

 加上了可执行权限 变了颜色 ls -l

执行 ./wpswap.sh

《linux shell脚本的编写-SWAP》有44条留言

  1. I wanted to send you the very little remark to finally thank you the moment again over the remarkable tactics you have shared on this page. This has been simply surprisingly open-handed with you to offer unhampered what most of us would’ve offered for sale for an ebook to get some dough for themselves, mostly now that you might have tried it in case you desired. These secrets as well served to be the good way to fully grasp that other people online have the identical interest much like my personal own to learn more regarding this matter. I am sure there are numerous more pleasant periods in the future for many who read your site.

    回复
  2. I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it’s easy to see why. A lot of people hear all about the compelling form you convey advantageous guidance by means of the blog and attract contribution from other individuals about this area and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a brilliant job.

    回复
  3. I needed to draft you one little bit of observation so as to say thank you once again for those great methods you’ve documented here. It is quite pretty generous of people like you to deliver freely exactly what a number of people could possibly have made available as an e book to end up making some cash for themselves, mostly now that you might have tried it in case you desired. These secrets as well served to be a good way to fully grasp that other people online have the identical fervor much like my personal own to know the truth more regarding this matter. I am sure there are numerous more pleasant periods in the future for many who read your site.

    回复
  4. I’m commenting to let you be aware of of the beneficial discovery my child developed browsing the blog. She came to find a lot of details, including how it is like to have a great coaching character to get certain people completely thoroughly grasp various very confusing topics. You undoubtedly surpassed visitors’ expected results. Thanks for showing those warm and friendly, trustworthy, revealing not to mention unique tips on your topic to Tanya.

    回复
  5. My wife and i were very satisfied when Peter managed to round up his survey while using the precious recommendations he received when using the weblog. It is now and again perplexing to simply possibly be offering tips which usually the others might have been trying to sell. We really see we now have you to thank for this. These illustrations you made, the straightforward website navigation, the relationships your site make it possible to promote – it is mostly terrific, and it is making our son in addition to us recognize that this theme is satisfying, which is certainly unbelievably vital. Thanks for the whole thing!

    回复
  6. I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it’s easy to see why. A lot of people hear all about the compelling form you convey advantageous guidance by means of the blog and attract contribution from other individuals about this area and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a brilliant job.

    回复
  7. I simply wanted to thank you so much once more. I am not sure the things that I would’ve made to happen without the type of solutions revealed by you over that situation. It truly was an absolute hard matter in my opinion, however , seeing the very specialised strategy you resolved that made me to leap over gladness. I am just happy for this information and then pray you realize what a great job you happen to be providing teaching people today thru your web site. More than likely you have never got to know any of us.

    回复
  8. I’m also commenting to make you understand what a wonderful experience our princess went through visiting yuor web blog. She realized too many things, with the inclusion of what it is like to possess an incredible teaching style to make the rest without problems understand various very confusing topics. You undoubtedly surpassed visitors’ expected results. Thanks for supplying those warm and helpful, trustworthy, revealing not to mention unique tips on your topic to Tanya.

    回复
  9. I am glad for writing to make you know what a magnificent encounter my friend’s girl gained studying your web site. She learned plenty of pieces, which include what it’s like to possess an awesome helping nature to let other folks very easily know just exactly several multifaceted subject matter. You truly exceeded people’s expectations. Thank you for presenting these powerful, safe, explanatory and in addition fun tips about this topic to Julie.

    回复
  10. Thanks for your whole work on this website. My niece takes pleasure in working on research and it is simple to grasp why. We all notice all relating to the powerful ways you render vital tips and tricks via your website and therefore welcome response from website visitors on this topic while our own simple princess is without question understanding so much. Take pleasure in the rest of the year. Your performing a very good job.

    回复
  11. I’m commenting to let you be aware of of the beneficial discovery my child encountered browsing the blog. She came to understand a lot of details, including how it is like to have a great coaching character to get certain people completely comprehend a variety of complex issues. You actually did more than her desires. I appreciate you for coming up with such essential, dependable, edifying and cool guidance on that topic to Ethel.

    回复
  12. I am only writing to make you understand what a really good experience my wife’s princess obtained viewing your webblog. She noticed some things, which included what it is like to possess an ideal teaching spirit to make others without difficulty learn about specific tortuous things. You undoubtedly surpassed readers’ expected results. Thanks for rendering those productive, trusted, informative as well as unique tips on your topic to Mary.

    回复
  13. I am glad for writing to make you know what a magnificent encounter my friend’s girl gained studying your web site. She learned several pieces, which include what it’s like to possess an awesome helping nature to let other folks very easily know just exactly several multifaceted subject matter. You truly exceeded people’s expectations. Thank you for presenting these powerful, safe, explanatory and in addition fun tips about this topic to Kate.

    回复
  14. I enjoy you because of all of your effort on this blog. Ellie enjoys conducting internet research and it’s easy to see why. All of us hear all about the compelling manner you create efficient ideas by means of the blog and as well cause contribution from other ones about this article and my child is being taught a great deal. Enjoy the remaining portion of the new year. You’re the one carrying out a fantastic job.

    回复
  15. Thanks for the tips about credit repair on this blog. Things i would advice people would be to give up the actual mentality that they’ll buy right now and pay out later. As a society all of us tend to do that for many things. This includes holidays, furniture, as well as items we would like. However, you have to separate your own wants from all the needs. When you are working to improve your credit rating score you have to make some sacrifices. For example you are able to shop online to save money or you can turn to second hand shops instead of costly department stores with regard to clothing.

    回复
  16. Hello there! I simply want to offer you a big thumbs up for your excellent information you have right here on this post. I will be returning to your site for more soon. Bettine Jackie Fawne

    回复
  17. After looking at a number of the blog articles on your web page, I honestly appreciate your technique of blogging. I book-marked it to my bookmark webpage list and will be checking back soon. Please check out my website too and tell me what you think. Ella Clifford Hetti

    回复
  18. Having read this I thought it was very informative. I appreciate you spending some time and energy to put this information together. I once again find myself spending way too much time both reading and posting comments. But so what, it was still worthwhile! Lark Wendall Randolf

    回复
  19. Simply desire to say your article is as surprising. The clearness in your post is just excellent and i can assume you are an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work. Pavla Sansone Packston

    回复
  20. Thank you for another great post. Where else may just anybody get that kind of information in such an ideal method of writing? I have a presentation next week, and I am at the search for such information.| Sallie Mikkel Serrell

    回复
  21. Sure, but I think it is of no use informing him about this. If he is human after all, he could never ever possible go through all the cartoons facepalming on him. Jori Jarib Floeter

    回复
  22. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Ella Clifford Hetti

    回复
  23. Hiya, I am really glad I have found this info. Today bloggers publish only about gossip and net stuff and this is really frustrating. A good site with exciting content, this is what I need. Thanks for making this site, and I will be visiting again. Do you do newsletters by email? Laurie Lalo Reginald

    回复
  24. Nice post. I learn something new and challenging on blogs I stumbleupon on a daily basis. It will always be helpful to read articles from other authors and practice a little something from other websites. Darci Parker Chafee

    回复
  25. Hello there. I found your website by means of Google while looking for a similar topic, your website got here up. It seems good. I have bookmarked it in my google bookmarks to visit then. Caresa Reuben Emilee

    回复
  26. After checking out a handful of the articles on your site, I seriously appreciate your way of writing a blog. I saved as a favorite it to my bookmark site list and will be checking back soon. Take a look at my website too and let me know your opinion. Tandy Boyce Roderic

    回复

留下评论