to start a partition on an x KBytes
boundary.
+ --no-table: This option is specific to wic. Space will be
+ reserved for the partition and it will be
+ populated but it will not be added to the
+ partition table. It may be useful for
+ bootloaders.
+
* bootloader
This command allows the user to specify various bootloader
self.kernel_dir = kernel_dir
self.native_sysroot = native_sysroot
+ def __get_part_num(self, num, parts):
+ """calculate the real partition number, accounting for partitions not
+ in the partition table and logical partitions
+ """
+ realnum = 0
+ for n, p in enumerate(parts, 1):
+ if not p.no_table:
+ realnum += 1
+ if n == num:
+ if p.no_table:
+ return 0
+ if self._ptable_format == 'msdos' and realnum > 3:
+ # account for logical partition numbering, ex. sda5..
+ return realnum + 1
+ return realnum
+
def __write_fstab(self, image_rootfs):
"""overriden to generate fstab (temporarily) in rootfs. This is called
from _create, make sure it doesn't get called from
def _update_fstab(self, fstab_lines, parts):
"""Assume partition order same as in wks"""
for num, p in enumerate(parts, 1):
- if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot":
+ pnum = self.__get_part_num(num, parts)
+ if not p.mountpoint or p.mountpoint == "/" or p.mountpoint == "/boot" or pnum == 0:
continue
part = ''
if p.disk.startswith('mmcblk'):
part = 'p'
- pnum = num
- if self._ptable_format == 'msdos' and pnum > 3:
- # account for logical partition numbering, ex. sda5..
- pnum += 1
-
device_name = "/dev/" + p.disk + part + str(pnum)
opts = "defaults"
fsopts = p.fsopts,
boot = p.active,
align = p.align,
+ no_table = p.no_table,
part_type = p.part_type)
self.__image.layout_partitions(self._ptable_format)
if p.disk.startswith('mmcblk'):
part = 'p'
- if self._ptable_format == 'msdos' and num > 3:
- rootdev = "/dev/%s%s%-d" % (p.disk, part, num + 1)
- else:
- rootdev = "/dev/%s%s%-d" % (p.disk, part, num)
+ pnum = self.__get_part_num(num, parts)
+ rootdev = "/dev/%s%s%-d" % (p.disk, part, pnum)
root_part_uuid = p.part_type
return (rootdev, root_part_uuid)
self.source = kwargs.get("source", None)
self.sourceparams = kwargs.get("sourceparams", None)
self.rootfs = kwargs.get("rootfs-dir", None)
+ self.no_table = kwargs.get("no-table", False)
self.source_file = ""
self.size = 0
retval += " --sourceparams=%s" % self.sourceparams
if self.rootfs:
retval += " --rootfs-dir=%s" % self.rootfs
+ if self.no_table:
+ retval += " --no-table"
return retval
# use specified rootfs path to fill the partition
op.add_option("--rootfs-dir", type="string", action="store",
dest="rootfs", default=None)
+ # wether to add the partition in the partition table
+ op.add_option("--no-table", dest="no_table", action="store_true",
+ default=False)
return op
self.disks[disk_name] = \
{ 'disk': None, # Disk object
'numpart': 0, # Number of allocate partitions
+ 'realpart': 0, # Number of partitions in the partition table
'partitions': [], # Indexes to self.partitions
'offset': 0, # Offset of next partition (in sectors)
# Minimum required disk size to fit all partitions (in bytes)
self.__add_disk(part['disk_name'])
def add_partition(self, size, disk_name, mountpoint, source_file = None, fstype = None,
- label=None, fsopts = None, boot = False, align = None,
+ label=None, fsopts = None, boot = False, align = None, no_table=False,
part_type = None):
""" Add the next partition. Prtitions have to be added in the
first-to-last order. """
'num': None, # Partition number
'boot': boot, # Bootable flag
'align': align, # Partition alignment
+ 'no_table' : no_table, # Partition does not appear in partition table
'part_type' : part_type } # Partition type
self.__add_partition(part)
# Get the disk where the partition is located
d = self.disks[p['disk_name']]
d['numpart'] += 1
+ if not p['no_table']:
+ d['realpart'] += 1
d['ptable_format'] = ptable_format
if d['numpart'] == 1:
# Skip one sector required for the partitioning scheme overhead
d['offset'] += overhead
- elif d['numpart'] > 3:
+ if d['realpart'] > 3:
# Reserve a sector for EBR for every logical partition
# before alignment is performed.
if ptable_format == "msdos":
d['offset'] += p['size']
p['type'] = 'primary'
- p['num'] = d['numpart']
+ if not p['no_table']:
+ p['num'] = d['realpart']
+ else:
+ p['num'] = 0
if d['ptable_format'] == "msdos":
- if d['numpart'] > 3:
+ if d['realpart'] > 3:
p['type'] = 'logical'
- p['num'] = d['numpart'] + 1
+ p['num'] = d['realpart'] + 1
d['partitions'].append(n)
msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d "
msger.debug("Creating partitions")
for p in self.partitions:
+ if p['num'] == 0:
+ continue
+
d = self.disks[p['disk_name']]
if d['ptable_format'] == "msdos" and p['num'] == 5:
# Create an extended partition (note: extended