python搭建文件系统_python运维实战--LVM创建和在线扩容

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值