mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
pvcreate wipes first 4 sectors unless given --zero n.
This commit is contained in:
parent
0d19475588
commit
2245e1c41f
@ -1,12 +1,11 @@
|
||||
Version 2.00.33 -
|
||||
====================================
|
||||
|
||||
pvcreate wipes first 4 sectors unless given --zero n.
|
||||
gulm clvmd now uses new ccsd key names.
|
||||
gulm clvmd now doesn't ignore the first node in cluster.conf
|
||||
Improve clvmd failure message if it's already running.
|
||||
Allow user to kill clvmd during initialisation.
|
||||
|
||||
|
||||
Version 2.00.32 - 22nd December 2004
|
||||
====================================
|
||||
Drop static/dl restriction for now.
|
||||
|
@ -16,6 +16,7 @@ pvcreate \- initialize a disk or partition for use by LVM
|
||||
.RB [ \-\-restorefile file ]
|
||||
.RB [ \-\-setphysicalvolumesize size ]
|
||||
.RB [ \-\-version ]
|
||||
.RB [ \-Z | \-\-zero y/n ]
|
||||
.IR PhysicalVolume " [" PhysicalVolume ...]
|
||||
.SH DESCRIPTION
|
||||
.B pvcreate
|
||||
@ -59,6 +60,13 @@ onto a replacement device - see \fBvgcfgrestore\fP(8).
|
||||
.TP
|
||||
.BR \-y ", " \-\-yes
|
||||
Answer yes to all questions.
|
||||
.TP
|
||||
.BR \-Z ", " \-\-zero " y/n"
|
||||
Whether or not the first 4 sectors (2048 bytes) of the device should be
|
||||
wiped.
|
||||
If this option is not given, the
|
||||
default is to wipe these sectors unless either or both of the --restorefile
|
||||
or --uuid options were specified.
|
||||
.SH NEW METADATA OPTIONS
|
||||
LVM2 introduces a new format for storing metadata on disk.
|
||||
This new format is more efficient and resilient than the format the
|
||||
|
@ -367,12 +367,13 @@ xx(pvcreate,
|
||||
"\t[-u|--uuid uuid] " "\n"
|
||||
"\t[-v|--verbose] " "\n"
|
||||
"\t[-y|--yes]" "\n"
|
||||
"\t[-Z|--zero {y|n}]\n"
|
||||
"\t[--version] " "\n"
|
||||
"\tPhysicalVolume [PhysicalVolume...]\n",
|
||||
|
||||
force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG, metadatacopies_ARG,
|
||||
metadatasize_ARG, physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG,
|
||||
yes_ARG)
|
||||
yes_ARG, zero_ARG)
|
||||
|
||||
xx(pvdata,
|
||||
"Display the on-disk metadata for physical volume(s)",
|
||||
|
@ -15,6 +15,10 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
struct pvcreate_params {
|
||||
int zero;
|
||||
};
|
||||
|
||||
const char _really_init[] =
|
||||
"Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
|
||||
|
||||
@ -107,6 +111,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
|
||||
static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
void *handle)
|
||||
{
|
||||
struct pvcreate_params *pp = (struct pvcreate_params *) handle;
|
||||
struct physical_volume *pv, *existing_pv;
|
||||
struct id id, *idp = NULL;
|
||||
const char *uuid = NULL;
|
||||
@ -207,6 +212,17 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pp->zero) {
|
||||
log_verbose("Zeroing start of device %s", pv_name);
|
||||
if (!dev_open_quiet(dev)) {
|
||||
log_error("%s not opened: device not zeroed", pv_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
dev_zero(dev, UINT64_C(0), (size_t) 2048);
|
||||
dev_close(dev);
|
||||
}
|
||||
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
if (!(pv_write(cmd, pv, &mdas, arg_int64_value(cmd, labelsector_ARG,
|
||||
@ -229,6 +245,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int i, r;
|
||||
int ret = ECMD_PROCESSED;
|
||||
struct pvcreate_params pp;
|
||||
|
||||
if (!argc) {
|
||||
log_error("Please enter a physical volume path");
|
||||
@ -269,8 +286,15 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, zero_ARG))
|
||||
pp.zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
|
||||
else if (arg_count(cmd, restorefile_ARG) || arg_count(cmd, uuidstr_ARG))
|
||||
pp.zero = 0;
|
||||
else
|
||||
pp.zero = 1;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
r = pvcreate_single(cmd, argv[i], NULL);
|
||||
r = pvcreate_single(cmd, argv[i], &pp);
|
||||
if (r > ret)
|
||||
ret = r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user