mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
pvck: repair headers and metadata
To write a new/repaired pv_header and label_header: pvck --repairtype pv_header --file <file> <device> This uses the metadata input file to find the PV UUID, device size, and data offset. To write new/repaired metadata text and mda_header: pvck --repairtype metadata --file <file> <device> This requires a good pv_header which points to one or two metadata areas. Any metadata areas referenced by the pv_header are updated with the specified metadata and a new mda_header. "--settings mda_num=1|2" can be used to select one mda to repair. To combine all header and metadata repairs: pvck --repair --file <file> <device> It's best to use a raw metadata file as input, that was extracted from another PV in the same VG (or from another metadata area on the same PV.) pvck will also accept a metadata backup file, but that will produce metadata that is not identical to other metadata copies on other PVs and other areas. So, when using a backup file, consider using it to update metadata on all PVs/areas. To get a raw metadata file to use for the repair, see pvck --dump metadata|metadata_search. List all instances of metadata from the metadata area: pvck --dump metadata_search <device> Save one instance of metadata at the given offset to the specified file (this file can be used for repair): pvck --dump metadata_search --file <file> --settings "metadata_offset=<off>" <device>
This commit is contained in:
parent
2e0f273008
commit
3145a85583
@ -1,8 +1,83 @@
|
|||||||
pvck checks LVM metadata on PVs.
|
pvck checks and repairs LVM metadata on PVs.
|
||||||
|
|
||||||
Use the --dump option to extract metadata from PVs for debugging.
|
.SS Dump
|
||||||
With dump, set --pvmetadatacopies 2 to extract metadata from a
|
|
||||||
second metadata area at the end of the device. Use the --file
|
.B headers
|
||||||
option to save the raw metadata to a specified file. (The raw
|
.br
|
||||||
metadata is not usable with vgcfgbackup and vgcfgrestore.)
|
Print header values and warn if any values are incorrect. Checks the
|
||||||
|
label_header, pv_header, mda_header(s), and metadata text.
|
||||||
|
|
||||||
|
.B metadata
|
||||||
|
.br
|
||||||
|
Print or save the current metadata text, using headers to locate the
|
||||||
|
metadata. If headers are damaged, the metadata may not be found. Use
|
||||||
|
--settings "mda_num=2" to look in mda2 (the second mda at the end of the
|
||||||
|
device (if used). The metadata text is printed to stdout. With --file,
|
||||||
|
the metadata text is saved to a file.
|
||||||
|
|
||||||
|
.B metadata_all
|
||||||
|
.br
|
||||||
|
List or save all versions of metadata found in the metadata area, using
|
||||||
|
headers to locate the metadata. If headers are damaged, the metadata may
|
||||||
|
not be found. Use --settings "mda_num=2" as above. All metadata versions
|
||||||
|
are listed (add -v to include descriptions and dates in the listing.)
|
||||||
|
With -file, all versions are written to a file.
|
||||||
|
|
||||||
|
.B metadata_search
|
||||||
|
.br
|
||||||
|
Search for all versions of metadata in the common locations. This does
|
||||||
|
not use headers, so it can find metadata even when headers are damaged.
|
||||||
|
Use --settings "mda_num=2" as above. All metadata versions are listed
|
||||||
|
(add -v to include descriptions and dates in the listing.) With --file,
|
||||||
|
all versions are written to a file. To save one copy of metadata, use
|
||||||
|
--settings "metadata_offset=<offset>", where the offset is taken from the
|
||||||
|
dump listing.
|
||||||
|
|
||||||
|
.B metadata_area
|
||||||
|
.br
|
||||||
|
Save the entire text metadata area to a file without processing.
|
||||||
|
|
||||||
|
.SS Repair
|
||||||
|
|
||||||
|
.B --repair
|
||||||
|
.br
|
||||||
|
Repair headers and metadata on a PV. This uses a metadata input file that
|
||||||
|
was extracted by --dump, or a backup file (from /etc/lvm/backup). When
|
||||||
|
possible, use metadata saved by --dump from another PV in the same VG (or
|
||||||
|
from a second metadata area on the PV).
|
||||||
|
|
||||||
|
There are cases where the PV UUID needs to be specified for the PV being
|
||||||
|
repaired. It is specified using --settings "pv_uuid=<UUID>". In
|
||||||
|
particular, if the device name for the PV being repaired does not match
|
||||||
|
the previous device name of the PV, then LVM may not be able to determine
|
||||||
|
the correct PV UUID. When headers are damaged on more than one PV in a
|
||||||
|
VG, it is important for the user to determine the correct PV UUID and
|
||||||
|
specify it in --settings. Otherwise, the wrong PV UUID could be used if
|
||||||
|
device names have been swapped since the metadata was last written.
|
||||||
|
|
||||||
|
If a PV had no metadata areas and the pv_header is damaged, then the
|
||||||
|
repair will not know to create no metadata areas during repair. It will
|
||||||
|
by default repair metadata in mda1. To repair with no metadata areas, use
|
||||||
|
--settings "mda_offset=0 mda_size=0".
|
||||||
|
|
||||||
|
There are cases where repair should be run on all PVs in the VG (using the
|
||||||
|
same metadata file): if all PVs in the VG are damaged, if using an old
|
||||||
|
metadata version, or if a backup file is used instead of raw metadata.
|
||||||
|
|
||||||
|
Using --repair is equivalent to running --repairtype pv_header followed by
|
||||||
|
--repairtype metadata.
|
||||||
|
|
||||||
|
.B --repairtype pv_header
|
||||||
|
.br
|
||||||
|
Repairs the header sector, containing the pv_header and label_header.
|
||||||
|
|
||||||
|
.B --repairtype metadata
|
||||||
|
.br
|
||||||
|
Repairs the mda_header and metadata text. It requires the headers to be
|
||||||
|
correct (having been undamaged or already repaired).
|
||||||
|
|
||||||
|
.B --repairtype label_header
|
||||||
|
.br
|
||||||
|
Repairs label_header fields, leaving the pv_header (in the same sector)
|
||||||
|
unchanged. (repairtype pv_header should usually be used instead.)
|
||||||
|
|
||||||
|
452
test/shell/pvck-repair.sh
Normal file
452
test/shell/pvck-repair.sh
Normal file
@ -0,0 +1,452 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (C) 2008-2013,2018 Red Hat, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
# of the GNU General Public License v.2.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
. lib/inittest
|
||||||
|
|
||||||
|
aux prepare_devs 2
|
||||||
|
get_devs
|
||||||
|
|
||||||
|
# One PV, one mda, pv_header zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, mda_header zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, pv_header and mda_header zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, metadata zeroed, use backup
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2 seek=9
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, mda_header and metadata zeroed, use backup
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, pv_header, mda_header and metadata zeroed, use backup
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, pv_header zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, mda_header1 zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=1 "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=1 "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, pv_header and mda_header1 zeroed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, metadata1 zeroed, use mda2
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2 seek=9
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, mda_header1 and metadata1 zeroed, use mda2
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, pv_header, mda_header1 and metadata1 zeroed, use mda2
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings "mda_num=2 seqno=1" -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, pv_header, both mda_header, and both metadata zeroed, use backup
|
||||||
|
# only writes mda1 since there's no evidence that mda2 existed
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=67584
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, two mdas, pv_header, both mda_header, and both metadata zeroed, use backup
|
||||||
|
# writes mda1 and also mda2 because of the mda2 settings passed to repair
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
vgcreate --pvmetadatacopies 2 $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=67584
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata "$dev1" || true
|
||||||
|
pvck --dump metadata --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --dump metadata_search "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings mda_num=2 "$dev1" || true
|
||||||
|
pvck --repair --settings "mda2_offset=34603008 mda2_size=1048576" -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, pv_header and mda_header zeroed on each
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --repair -y -f meta "$dev2"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, metadata zeroed on each, use backup
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2 seek=9
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2 seek=9
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev2"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, pv_header, mda_header and metadata zeroed on each, use backup
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev2"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, pv_header and mda_header zeroed on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata -f meta "$dev2"
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, metadata zeroed on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2 seek=9
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata -f meta "$dev2"
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, pv_header, mda_header and metadata zeroed on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata -f meta "$dev2"
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda on first, no mda on second, zero header on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
pvcreate "$dev1"
|
||||||
|
pvcreate --pvmetadatacopies 0 "$dev2"
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda on first, no mda on second, zero headers on both
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
pvcreate "$dev1"
|
||||||
|
pvcreate --pvmetadatacopies 0 "$dev2"
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
pvck --repair -y --settings "mda_offset=0 mda_size=0" -f meta "$dev2"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda on first, no mda on second, zero all on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
pvcreate "$dev1"
|
||||||
|
pvcreate --pvmetadatacopies 0 "$dev2"
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
vgcfgbackup
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=3 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --repair -y -f etc/backup/$vg "$dev1"
|
||||||
|
pvck --repair -y --settings "mda_offset=0 mda_size=0" -f etc/backup/$vg "$dev2"
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, two mda on each, pv_header and mda_header1 zeroed on both
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
pvcreate --pvmetadatacopies 2 "$dev1"
|
||||||
|
pvcreate --pvmetadatacopies 2 "$dev2"
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
pvck --dump metadata_search --settings "mda_num=2 seqno=1" -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
rm meta
|
||||||
|
pvck --dump metadata_search --settings "mda_num=2 seqno=1" -f meta "$dev2" || true
|
||||||
|
pvck --repair -y -f meta "$dev2"
|
||||||
|
rm meta
|
||||||
|
pvck --dump headers "$dev1"
|
||||||
|
pvck --dump headers "$dev2"
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# Two PV, one mda each, pv_header and mda_header zeroed on each,
|
||||||
|
# non-standard data_offset/mda_size on first
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
pvcreate --metadatasize 2048k --dataalignment 128k "$dev1"
|
||||||
|
pvcreate "$dev2"
|
||||||
|
vgcreate $vg "$dev1" "$dev2"
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=1 seek=8
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=2
|
||||||
|
dd if=/dev/zero of="$dev2" bs=512 count=1 seek=8
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
pvck --repair -y -f meta "$dev1"
|
||||||
|
rm meta
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev2" || true
|
||||||
|
pvck --repair -y -f meta "$dev2"
|
||||||
|
rm meta
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump headers "$dev2" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
||||||
|
# One PV, one mda, pv_header zeroed, unmatching dev name requires specified uuid
|
||||||
|
rm meta || true
|
||||||
|
dd if=/dev/zero of="$dev1" || true
|
||||||
|
dd if=/dev/zero of="$dev2" || true
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
UUID1=`pvck --dump headers "$dev1" | grep pv_header.pv_uuid | awk '{print $2}'`
|
||||||
|
echo $UUID1
|
||||||
|
dd if=/dev/zero of="$dev1" bs=512 count=2
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
pvck --dump metadata_search --settings seqno=1 -f meta "$dev1" || true
|
||||||
|
sed 's/\/dev\/mapper\/LVMTEST/\/dev\/mapper\/BADTEST/' meta > meta.bad
|
||||||
|
grep device meta
|
||||||
|
grep device meta.bad
|
||||||
|
not pvck --repair -y -f meta.bad "$dev1"
|
||||||
|
pvck --repair -y -f meta.bad --settings pv_uuid=$UUID1 "$dev1"
|
||||||
|
pvck --dump headers "$dev1" || true
|
||||||
|
vgs $vg
|
||||||
|
lvcreate -l1 -an $vg
|
||||||
|
|
22
tools/args.h
22
tools/args.h
@ -214,11 +214,13 @@ arg(driverloaded_ARG, '\0', "driverloaded", bool_VAL, 0, 0,
|
|||||||
"For testing and debugging.\n")
|
"For testing and debugging.\n")
|
||||||
|
|
||||||
arg(dump_ARG, '\0', "dump", string_VAL, 0, 0,
|
arg(dump_ARG, '\0', "dump", string_VAL, 0, 0,
|
||||||
"Dump metadata from a PV. Option values include \\fBmetadata\\fP\n"
|
"Dump headers and metadata from a PV for debugging and repair.\n"
|
||||||
"to print or save the current text metadata, \\fBmetadata_area\\fP\n"
|
"Option values include: \\fBheaders\\fP to print and check LVM headers,\n"
|
||||||
"to save the entire text metadata area to a file, \\fBmetadata_all\\fP\n"
|
"\\fBmetadata\\fP to print or save the current text metadata,\n"
|
||||||
"to save the current and any previous complete versions of metadata\n"
|
"\\fBmetadata_all\\fP to list or save all versions of metadata,\n"
|
||||||
"to a file, and \\fBheaders\\fP to print and check LVM headers.\n")
|
"\\fBmetadata_search\\fP to list or save all versions of metadata,\n"
|
||||||
|
"searching standard locations in case of damaged headers,\n"
|
||||||
|
"\\fBmetadata_area\\fP to save an entire text metadata area to a file.\n")
|
||||||
|
|
||||||
arg(errorwhenfull_ARG, '\0', "errorwhenfull", bool_VAL, 0, 0,
|
arg(errorwhenfull_ARG, '\0', "errorwhenfull", bool_VAL, 0, 0,
|
||||||
"Specifies thin pool behavior when data space is exhausted.\n"
|
"Specifies thin pool behavior when data space is exhausted.\n"
|
||||||
@ -544,9 +546,15 @@ arg(rebuild_ARG, '\0', "rebuild", pv_VAL, ARG_GROUPABLE, 0,
|
|||||||
"See \\fBlvmraid\\fP(7) for more information.\n")
|
"See \\fBlvmraid\\fP(7) for more information.\n")
|
||||||
|
|
||||||
arg(repair_ARG, '\0', "repair", 0, 0, 0,
|
arg(repair_ARG, '\0', "repair", 0, 0, 0,
|
||||||
|
"#lvconvert\n"
|
||||||
"Replace failed PVs in a raid or mirror LV, or run a repair\n"
|
"Replace failed PVs in a raid or mirror LV, or run a repair\n"
|
||||||
"utility on a thin pool. See \\fBlvmraid\\fP(7) and \\fBlvmthin\\fP(7)\n"
|
"utility on a thin pool. See \\fBlvmraid\\fP(7) and \\fBlvmthin\\fP(7)\n"
|
||||||
"for more information.\n")
|
"for more information.\n"
|
||||||
|
"#pvck\n"
|
||||||
|
"Repair headers and metadata on a PV.\n")
|
||||||
|
|
||||||
|
arg(repairtype_ARG, '\0', "repairtype", repairtype_VAL, 0, 0,
|
||||||
|
"Repair headers and metadata on a PV. See command description.\n")
|
||||||
|
|
||||||
arg(replace_ARG, '\0', "replace", pv_VAL, ARG_GROUPABLE, 0,
|
arg(replace_ARG, '\0', "replace", pv_VAL, ARG_GROUPABLE, 0,
|
||||||
"Replace a specific PV in a raid LV with another PV.\n"
|
"Replace a specific PV in a raid LV with another PV.\n"
|
||||||
@ -1001,6 +1009,8 @@ arg(exported_ARG, 'e', "exported", 0, 0, 0,
|
|||||||
arg(physicalextent_ARG, 'E', "physicalextent", 0, 0, 0, NULL)
|
arg(physicalextent_ARG, 'E', "physicalextent", 0, 0, 0, NULL)
|
||||||
|
|
||||||
arg(file_ARG, 'f', "file", string_VAL, 0, 0,
|
arg(file_ARG, 'f', "file", string_VAL, 0, 0,
|
||||||
|
"#pvck\n"
|
||||||
|
"Metadata file to read or write.\n"
|
||||||
"#lvmconfig\n"
|
"#lvmconfig\n"
|
||||||
"#dumpconfig\n"
|
"#dumpconfig\n"
|
||||||
"#config\n"
|
"#config\n"
|
||||||
|
@ -1437,9 +1437,20 @@ ID: pvck_general
|
|||||||
DESC: Check for metadata on a device
|
DESC: Check for metadata on a device
|
||||||
|
|
||||||
pvck --dump String PV
|
pvck --dump String PV
|
||||||
OO: --settings String, --file String, --pvmetadatacopies MetadataCopiesPV, --labelsector Number
|
OO: --settings String, --file String,
|
||||||
|
--pvmetadatacopies MetadataCopiesPV, --labelsector Number
|
||||||
ID: pvck_dump
|
ID: pvck_dump
|
||||||
DESC: Print metadata from a device
|
DESC: Check and print LVM headers and metadata on a device
|
||||||
|
|
||||||
|
pvck --repairtype RepairType PV
|
||||||
|
OO: --settings String, --file String, --labelsector Number
|
||||||
|
ID: pvck_repair_type
|
||||||
|
DESC: Repair LVM headers or metadata on a device
|
||||||
|
|
||||||
|
pvck --repair --file String PV
|
||||||
|
OO: --settings String, --labelsector Number
|
||||||
|
ID: pvck_repair
|
||||||
|
DESC: Repair LVM headers and metadata on a device
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ static inline int syncaction_arg(struct cmd_context *cmd __attribute__((unused))
|
|||||||
static inline int reportformat_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
static inline int reportformat_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
||||||
static inline int configreport_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
static inline int configreport_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
||||||
static inline int configtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
static inline int configtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
||||||
|
static inline int repairtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
|
||||||
|
|
||||||
/* needed to include commands.h when building man page generator */
|
/* needed to include commands.h when building man page generator */
|
||||||
#define CACHE_VGMETADATA 0x00000001
|
#define CACHE_VGMETADATA 0x00000001
|
||||||
|
@ -1077,6 +1077,15 @@ int configtype_arg(struct cmd_context *cmd, struct arg_values *av)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int repairtype_arg(struct cmd_context *cmd, struct arg_values *av)
|
||||||
|
{
|
||||||
|
if (!strcmp(av->value, "pv_header") ||
|
||||||
|
!strcmp(av->value, "metadata") ||
|
||||||
|
!strcmp(av->value, "label_header"))
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: there's been a confusing mixup among:
|
* FIXME: there's been a confusing mixup among:
|
||||||
* resizeable, resizable, allocatable, allocation.
|
* resizeable, resizable, allocatable, allocation.
|
||||||
|
1457
tools/pvck.c
1457
tools/pvck.c
File diff suppressed because it is too large
Load Diff
@ -184,6 +184,7 @@ int syncaction_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_v
|
|||||||
int reportformat_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
int reportformat_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
||||||
int configreport_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
int configreport_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
||||||
int configtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
int configtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
||||||
|
int repairtype_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
|
||||||
|
|
||||||
/* we use the enums to access the switches */
|
/* we use the enums to access the switches */
|
||||||
unsigned arg_count(const struct cmd_context *cmd, int a);
|
unsigned arg_count(const struct cmd_context *cmd, int a);
|
||||||
|
@ -141,6 +141,7 @@ val(syncaction_VAL, syncaction_arg, "SyncAction", "check|repair")
|
|||||||
val(reportformat_VAL, reportformat_arg, "ReportFmt", "basic|json")
|
val(reportformat_VAL, reportformat_arg, "ReportFmt", "basic|json")
|
||||||
val(configreport_VAL, configreport_arg, "ConfigReport", "log|vg|lv|pv|pvseg|seg")
|
val(configreport_VAL, configreport_arg, "ConfigReport", "log|vg|lv|pv|pvseg|seg")
|
||||||
val(configtype_VAL, configtype_arg, "ConfigType", "current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata")
|
val(configtype_VAL, configtype_arg, "ConfigType", "current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata")
|
||||||
|
val(repairtype_VAL, repairtype_arg, "RepairType", "pv_header|metadata|label_header")
|
||||||
|
|
||||||
/* this should always be last */
|
/* this should always be last */
|
||||||
val(VAL_COUNT, NULL, NULL, NULL)
|
val(VAL_COUNT, NULL, NULL, NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user