2013-09-18 00:46:58 +02:00
|
|
|
from common.tools import log_check_call
|
|
|
|
from base import BasePartition
|
|
|
|
|
|
|
|
|
|
|
|
class GPTPartition(BasePartition):
|
|
|
|
|
2013-09-22 21:20:09 +02:00
|
|
|
def __init__(self, size, filesystem, name, previous):
|
2013-09-18 00:46:58 +02:00
|
|
|
self.name = name
|
2013-09-22 21:20:09 +02:00
|
|
|
super(GPTPartition, self).__init__(size, filesystem, previous)
|
2013-09-18 00:46:58 +02:00
|
|
|
|
2013-09-22 21:20:09 +02:00
|
|
|
def _before_create(self, e):
|
2013-09-18 00:46:58 +02:00
|
|
|
start = self.get_start()
|
2014-01-18 23:10:16 +01:00
|
|
|
create_command = ('mkpart primary {start}MiB {end}MiB'
|
|
|
|
.format(start=str(start),
|
2013-09-18 00:46:58 +02:00
|
|
|
end=str(start + self.size)))
|
|
|
|
log_check_call(['/sbin/parted', '--script', '--align', 'none', e.volume.device_path,
|
2014-01-18 23:10:16 +01:00
|
|
|
'--', create_command])
|
|
|
|
|
|
|
|
# partition name only works for gpt, for msdos that becomes the part-type (primary, extended, logical)
|
|
|
|
name_command = ('name {idx} {name}'
|
|
|
|
.format(idx=self.get_index(),
|
|
|
|
name=self.name))
|
|
|
|
log_check_call(['/sbin/parted', '--script', '--align', 'none', e.volume.device_path,
|
|
|
|
'--', name_command])
|