@tony-yin
2018-04-25T10:18:58.000000Z
字数 953
阅读 1551
Filesystem
mount.sh
:
#! /bin/bash
disks=$(lsblk | awk '{print $1}' | grep sd[a-w] -w)
for disk in $disks
do
echo "===== disk $disk start time: $(date) ====="
if [ ! -x "/test/$disk" ]; then
mkdir "/test/$disk"
fi
mkfs -t ext4 -m 0 /dev/$disk"1"
mount /dev/$disk"1" /test/$disk
echo "===== disk $disk end time: $(date) ====="
done
create_patition2.py
:
import sys
from mcs3.command import do_cmd
size = sys.argv[1]
num = sys.argv[2]
mount_info = do_cmd('mount')
sys_disk_name = mount_info[5:8]
def parted_disks(num, size, disk):
for i in range(int(num)):
do_cmd('sgdisk -n {}:0:+{} /dev/{}'.format(i+1, size, disk))
do_cmd('sgdisk -N 2 /dev/{}'.format(disk))
print 'disk {} partition {} done ...'.format(disk, i+1)
if len(sys.argv) > 3:
disks = sys.argv[3:]
for disk in disks:
if disk == sys_disk_name:
print '{} is system disk, can\'t be parted!'.format(disk)
else:
parted_disks(num, size, disk)
else:
all_disks = do_cmd('lsblk').splitlines()
for disk in all_disks:
if (disk.startswith('sd')):
disk_name = disk.split()[0]
if disk_name != sys_disk_name:
parted_disks(num, size, disk_name)