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

vgimport: Allow '--force' to import VGs with missing PVs.

When there are missing PVs in a volume group, most operations that alter
the LVM metadata are disallowed.  It turns out that 'vgimport' is one of
those disallowed operations.  This is bad because it creates a circular
dependency.  'vgimport' will complain that the VG is inconsistent and that
'vgreduce --removemissing' must be run.  However, 'vgreduce' cannot be run
because it has not been imported.  Therefore, 'vgimport' must be one of
the operations allowed to change the metadata when PVs are missing.  The
'--force' option is the way to make 'vgimport' happen in spite of the
missing PVs.
This commit is contained in:
Jonathan Brassow 2013-02-20 16:28:26 -06:00
parent 303e86adc8
commit 3ab46449f4
3 changed files with 23 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
vgimport '--force' now allows users to import VGs with missing PVs.
Fix PV alignment to incorporate alignment offset if the PV has zero MDAs.
Allow remove/replace of RAID sub-LVs that are composed of error targets.
Make 'vgreduce --removemissing' able to handle RAID LVs with missing PVs.

View File

@ -20,6 +20,11 @@ See \fBlvm\fP(8) for common options.
.TP
.BR \-a ", " \-\-all
Import all exported Volume Groups.
.TP
.BR \-\-force
Import exported Volume Groups even if there are missing Physical Volumes.
This option should only be used if the missing devices are known to have
failed and they cannot be restored.
.SH SEE ALSO
.BR lvm (8),
.BR pvscan (8),

View File

@ -68,6 +68,23 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
if (arg_count(cmd, force_ARG)) {
/*
* The volume group cannot be repaired unless it is first
* imported. If we don't allow the user a way to import the
* VG while it is 'partial', then we will have created a
* circular dependency.
*
* The reason we don't just simply set 'handles_missing_pvs'
* by default is that we want to guard against the case
* where the user simply forgot to move one or more disks in
* the VG before running 'vgimport'.
*/
log_print("'--force' supplied. Volume groups with missing PVs"
" will be imported.");
cmd->handles_missing_pvs = 1;
}
return process_each_vg(cmd, argc, argv,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
NULL,