1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvcreate: overwrite partition header with -f

$ pvcreate /dev/sdc
  Cannot use /dev/sdc: device is partitioned
$ pvcreate -f /dev/sdc
  Physical volume "/dev/sdc" successfully created.
This commit is contained in:
David Teigland 2021-09-08 16:30:11 -05:00
parent 89595a3665
commit d3d5ec7469
3 changed files with 14 additions and 0 deletions

View File

@ -197,6 +197,7 @@ struct cmd_context {
unsigned check_devs_used:1; /* check devs used by LVs */
unsigned print_device_id_not_found:1; /* print devices file entries not found */
unsigned ignore_device_name_mismatch:1; /* skip updating devices file names */
unsigned filter_partitioned_skip; /* don't use filter-partitioned */
/*
* Devices and filtering.

View File

@ -27,6 +27,9 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
if (cmd->filter_nodata_only)
return 1;
if (cmd->filter_partitioned_skip)
return 1;
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev);

View File

@ -5336,6 +5336,10 @@ int pvcreate_each_device(struct cmd_context *cmd,
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
/* pvcreate -f overwrites partitions */
if (pp->force && !pp->is_remove)
cmd->filter_partitioned_skip = 1;
log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
label_scan_devs(cmd, cmd->filter, &scan_devs);
@ -5350,6 +5354,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
}
}
cmd->filter_deviceid_skip = 0;
cmd->filter_partitioned_skip = 0;
/*
* Can the command continue if some specified devices were not found?
@ -5562,6 +5567,9 @@ do_command:
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
if (pp->force && !pp->is_remove)
cmd->filter_partitioned_skip = 1;
log_debug("Rescanning and filtering device args with exclusive open");
if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl");
@ -5575,7 +5583,9 @@ do_command:
dm_list_add(&pp->arg_fail, &pd->list);
}
}
cmd->filter_deviceid_skip = 0;
cmd->filter_partitioned_skip = 0;
if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
log_debug("No devices to process.");