140
140
help='Allow to skip MD containers (fake raid leftovers) while '
141
141
'cleaning the rest of MDs',
144
'partition_udev_settle_attempts',
146
help='How many times udev settle will be called after partitioning'
149
'multipath_lvm_filter',
150
default=['r|/dev/mapper/.*-part.*|',
152
'r|/dev/disk/by-id/.*|'],
153
help='Extra filters for lvm.conf to force lvm work with partions '
154
'on multipath devices using /dev/mapper/<id>-part<n> links'
158
default='/etc/lvm/lvm.conf',
159
help='Path to LVM configuration file'
179
197
if not fs.keep_data and not found_images:
180
198
fu.make_fs(fs.type, fs.options, fs.label, fs.device)
201
def _make_partitions(parteds, wait_for_udev_settle=False):
202
for parted in parteds:
203
pu.make_label(parted.name, parted.label)
204
for prt in parted.partitions:
205
pu.make_partition(prt.device, prt.begin, prt.end, prt.type)
206
if wait_for_udev_settle:
207
utils.wait_for_udev_settle(
208
attempts=CONF.partition_udev_settle_attempts)
209
for flag in prt.flags:
210
pu.set_partition_flag(prt.device, prt.count, flag)
212
pu.set_gpt_type(prt.device, prt.count, prt.guid)
213
# If any partition to be created doesn't exist it's an error.
214
# Probably it's again 'device or resource busy' issue.
215
if not os.path.exists(prt.name):
216
raise errors.PartitionNotFoundError(
217
'Partition %s not found after creation' % prt.name)
182
219
def do_partitioning(self):
183
220
LOG.debug('--- Partitioning disks (do_partitioning) ---')
196
233
lu.vgremove_all()
197
234
lu.pvremove_all()
199
LOG.debug("Enabling udev's rules blacklisting")
200
utils.blacklist_udev_rules(udev_rules_dir=CONF.udev_rules_dir,
201
udev_rules_lib_dir=CONF.udev_rules_lib_dir,
202
udev_rename_substr=CONF.udev_rename_substr,
203
udev_empty_rule=CONF.udev_empty_rule)
205
236
for parted in self.driver.partition_scheme.parteds:
206
237
for prt in parted.partitions:
207
238
# We wipe out the beginning of every new partition
220
251
'seek=%s' % max(prt.end - 3, 0), 'count=5',
221
252
'of=%s' % prt.device, check_exit_code=[0, 1])
255
parteds_with_rules = []
223
256
for parted in self.driver.partition_scheme.parteds:
224
pu.make_label(parted.name, parted.label)
225
for prt in parted.partitions:
226
pu.make_partition(prt.device, prt.begin, prt.end, prt.type)
227
for flag in prt.flags:
228
pu.set_partition_flag(prt.device, prt.count, flag)
230
pu.set_gpt_type(prt.device, prt.count, prt.guid)
231
# If any partition to be created doesn't exist it's an error.
232
# Probably it's again 'device or resource busy' issue.
233
if not os.path.exists(prt.name):
234
raise errors.PartitionNotFoundError(
235
'Partition %s not found after creation' % prt.name)
237
LOG.debug("Disabling udev's rules blacklisting")
257
if hw.is_multipath_device(parted.name):
258
parteds_with_rules.append(parted)
260
parteds.append(parted)
262
utils.blacklist_udev_rules(udev_rules_dir=CONF.udev_rules_dir,
263
udev_rules_lib_dir=CONF.udev_rules_lib_dir,
264
udev_rename_substr=CONF.udev_rename_substr,
265
udev_empty_rule=CONF.udev_empty_rule)
267
self._make_partitions(parteds)
238
269
utils.unblacklist_udev_rules(
239
270
udev_rules_dir=CONF.udev_rules_dir,
240
271
udev_rename_substr=CONF.udev_rename_substr)
273
self._make_partitions(parteds_with_rules, wait_for_udev_settle=True)
242
275
# If one creates partitions with the same boundaries as last time,
243
276
# there might be md and lvm metadata on those partitions. To prevent
244
277
# failing of creating md and lvm devices we need to make sure
659
692
for fs in self.driver.partition_scheme.fss:
660
693
mount2uuid[fs.mount] = utils.execute(
661
'blkid', '-o', 'value', '-s', 'UUID', fs.device,
694
'blkid', '-c', '/dev/null', '-o', 'value',
695
'-s', 'UUID', fs.device,
662
696
check_exit_code=[0])[0].strip()
664
698
if '/' not in mount2uuid:
677
711
install_devices = [d.name for d in self.driver.partition_scheme.parteds
678
712
if d.install_bootloader]
680
grub.append_kernel_params('root=UUID=%s ' % mount2uuid['/'])
714
# Zigo: This failed in Debian... :/
715
# grub.append_kernel_params('root=UUID=%s ' % mount2uuid['/'])
682
717
kernel = grub.kernel_name or gu.guess_kernel(chroot=chroot,
683
718
regexp=grub.kernel_regexp)
851
886
bu.dump_runtime_uuid(bs_scheme.uuid,
852
887
os.path.join(chroot,
853
888
'etc/nailgun-agent/config.yaml'))
889
bu.append_lvm_devices_filter(chroot, CONF.multipath_lvm_filter,
854
891
bu.do_post_inst(chroot,
855
892
allow_unsigned_file=CONF.allow_unsigned_file,
856
893
force_ipv4_file=CONF.force_ipv4_file)