挂载磁盘脚本

  1. #!/usr/bin/python
  2. #coding=utf-8
  3. '''
  4. Created on Nov 4, 2015
  5. install basic system [c2]
  6. @author: Galbraith
  7. '''
  8. from subprocess import call
  9. from os.path import basename
  10. import os
  11. import sys
  12. import commands
  13. def scall(cmd_line):
  14. '''linux shell '''
  15. return call(cmd_line,shell=True)
  16. def findstrinfile(filename, lookup):
  17. '''file str differ check'''
  18. return lookup in open(filename,'rt').read()
  19. def file_check(file_sl):
  20. '''file differ check'''
  21. return os.path.isfile(file_sl)
  22. def dir_check(dir_sl):
  23. '''dir differ check'''
  24. return os.path.exists(dir_sl)
  25. def srun(comm):
  26. '''system command'''
  27. return os.system(comm)
  28. def mount_disk():
  29. '''mount new disk'''
  30. srun('mkdir /data')
  31. srun('mkfs -t ext4 /dev/vdb')
  32. srun('mount /dev/vdb /data')
  33. srun('echo "/dev/vdb /data ext4 defaults 0 0" >> /etc/fstab')
  34. def cat_mount():
  35. mount = commands.getoutput('mount -v')
  36. lines = mount.split('\n')
  37. points = map(lambda line: line.split()[2], lines)
  38. srun('df -h')
  39. print points
  40. def handle():
  41. mount_disk()
  42. cat_mount()
  43. if __name__ == '__main__':
  44. handle()
posted @   技术颜良  阅读(291)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
点击右上角即可分享
微信分享提示