请忽略我这个弱智写的py3的创建文件系统不会写日后看情况改
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请忽略我这个弱智写的py3的创建文件系统不会写日后看情况改相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env pythoncoding=utf-8
print(‘echo "- - -" > /sys/class/scsi_host/host0/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host1/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host2/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host3/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host4/scan‘)
print(‘echo "- - -" > /sys/class/scsi_host/host5/scan‘)
f = open(‘a.txt‘,‘r+‘)
l = []
for i in f.readlines():
l.append(i.split())
f.close()
#print(l)
l1 =[]
for i in l:
l1.append(i[1])
l2 = [‘sdc‘,‘sdd‘,‘sde‘,‘sdf‘,‘sdg‘,‘sdh‘]
def func(n):
s = ‘ ‘
for i in range(n):
s = s + ‘/dev/‘+ l2[0] + ‘ ‘
l2.remove(l2[0])
return s
#print(l1)
#for i in l1:
#a = ‘pvcreate --dataalignment +1M ‘ + i[1]
#print(a)
for i in l:
sd = func(int(i[2]))
print(‘vgcreate ‘ + ‘ ‘ + i[0] + ‘ -s 32M ‘ + sd)
c = ‘lvcreate -L ‘ + i[5] + ‘G ‘ + ‘ -n ‘ + i[4] + ‘ ‘ + ‘-i‘ + ‘ ‘+ i[2] + ‘ ‘ + "-I 64" + ‘ ‘+ i[0]
print(c)
d = ‘mkfs.‘ + i[6] + ‘ ‘ + ‘/dev/‘ + i[0] + ‘/‘ + i[4]
print(d)
e = ‘mkdir -p‘ + ‘ ‘ + i[7] + i[9]
print(e)
print(‘echo ‘ + ‘/dev/‘ + i[0] + ‘/‘ + i[4] + ‘ ‘ + i[7] + ‘ ‘ + ‘ ‘ + i[6] + ‘ defaults 0 0 ‘ + ‘>>/etc/fstab‘)
f = ‘chmod 755 -R ‘ + i[9]
print(f)
g = ‘chown -R‘ + ‘ ‘ + i[8] + ‘ ‘ +i[9]
print(g)
print(‘mount -a‘)
a.txt
vgname pvcreate lvsize pesize lvname
vgdata /dev/sdb 2 32 lvdata 1 ext4 /data root:root /data
vgdata1 /dev/sdc 2 32 lvdata1 2 ext4 /data1 root:root /data1
vgdata2 /dev/sdd 1 32 lvdata2 3 ext4 /data2 root:root /data2
以上是关于请忽略我这个弱智写的py3的创建文件系统不会写日后看情况改的主要内容,如果未能解决你的问题,请参考以下文章