[关闭]
@tony-yin 2018-04-25T10:18:58.000000Z 字数 953 阅读 1551

ext4lazyinit

Filesystem


mount.sh:

  1. #! /bin/bash
  2. disks=$(lsblk | awk '{print $1}' | grep sd[a-w] -w)
  3. for disk in $disks
  4. do
  5. echo "===== disk $disk start time: $(date) ====="
  6. if [ ! -x "/test/$disk" ]; then
  7. mkdir "/test/$disk"
  8. fi
  9. mkfs -t ext4 -m 0 /dev/$disk"1"
  10. mount /dev/$disk"1" /test/$disk
  11. echo "===== disk $disk end time: $(date) ====="
  12. done

create_patition2.py:

  1. import sys
  2. from mcs3.command import do_cmd
  3. size = sys.argv[1]
  4. num = sys.argv[2]
  5. mount_info = do_cmd('mount')
  6. sys_disk_name = mount_info[5:8]
  7. def parted_disks(num, size, disk):
  8. for i in range(int(num)):
  9. do_cmd('sgdisk -n {}:0:+{} /dev/{}'.format(i+1, size, disk))
  10. do_cmd('sgdisk -N 2 /dev/{}'.format(disk))
  11. print 'disk {} partition {} done ...'.format(disk, i+1)
  12. if len(sys.argv) > 3:
  13. disks = sys.argv[3:]
  14. for disk in disks:
  15. if disk == sys_disk_name:
  16. print '{} is system disk, can\'t be parted!'.format(disk)
  17. else:
  18. parted_disks(num, size, disk)
  19. else:
  20. all_disks = do_cmd('lsblk').splitlines()
  21. for disk in all_disks:
  22. if (disk.startswith('sd')):
  23. disk_name = disk.split()[0]
  24. if disk_name != sys_disk_name:
  25. parted_disks(num, size, disk_name)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注