LVM有关概念和操作
说明??:有关LVM详细概念,请各位大佬自行百度,谷歌。。这里不做重点介绍。
这个python脚本能做什么
创建LVM
指定具体磁盘进行分区,这里定义分区号1
刷新分区,不需要reboot系统
创建pv
创建vg
创建lv
格式化,ext4/xfs
创建挂载目录
将文件系统信息写到 /etc/fstab
使用 mount -a 自动挂载
在线扩容vg/lv
磁盘分区
刷新分区信息
创建pv
在线扩容vg
在线扩容lv
扩容后容量刷新
python 脚本信息
#!/usr/bin/env python
# coding=utf-8
__author__ = "wutengfei"
__email__ = "wutengfei@datagrand.com"
__status__ = "Production"
__version__ = "1.0"
from optparse import OptionParser
from subprocess import Popen, call, PIPE
from shlex import split
from commands import getstatusoutput
from os import mkdir
from os.path import basename , normpath
import time
parser = OptionParser()
parser.add_option(‘-d‘, ‘--drive‘, dest=‘drive‘, help=‘this is the name of the drive like sda, hdd etc..‘)
parser.add_option(‘-f‘, ‘--folder‘, dest=‘folder‘, help=‘this is the name of the directory like /data or /var/log‘)
parser.add_option(‘-t‘, ‘--fstype‘, dest=‘fstype‘, help=‘this is the type of filesystem you need like ext4 or xfs‘)
(opts,args) = parser.parse_args()
class FormatDriver(object):
"""
This is a class that does end to end create partition, deal with lvm, make filesyst