LoginSignup
0
0

More than 5 years have passed since last update.

parted

Last updated at Posted at 2013-07-09
create_parted_partitions.py
#!/usr/bin/python

_TARGET_DISK       = '/dev/sdb'
_PARTITION_NUM     = 4

#--- parted _TARGET_DISK -s 'unit s print'

_DISK_SECTOR       = 17511219456
_OFFSET_START      = 2048
_OFFSET_END        = 34
_AVAILABLE_SECTOR  = _DISK_SECTOR - _OFFSET_START - _OFFSET_END
_PARTITION_SECTOR  = _AVAILABLE_SECTOR / _PARTITION_NUM / 2048 * 2048
_PARTED_COMMAND    = "parted %s -s 'unit s mkpart primary ext4 %12ds %12ds'"

for i in xrange(_PARTITION_NUM):
    if i == 0 : sector_start = _OFFSET_START
    else      : sector_start = sector_end + 1
    sector_end = sector_start + _PARTITION_SECTOR - 1
    print _PARTED_COMMAND % (_TARGET_DISK, sector_start, sector_end)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0