-3

man pvcreate says

pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be used in a VG. A PV can be a disk partition, whole disk, meta device, or loopback file.

For DOS disk partitions, the partition id should be set to 0x8e using fdisk(8), cfdisk(8), or a equivalent. For GUID Partition Table (GPT), the id is E6D6D379-F507-44C2-A23C- 238F2A3DF928. For whole disk devices only the partition table must be erased, which will effectively destroy all data on that disk. This can be done by zeroing the first sector with:

dd if=/dev/zero of=PhysicalVolume bs=512 count=1

If I use pvcreate to mark a disk as a PV, does it mean that pvcreate will destroy all the data on a disk?

If I use pvcreate to mark a partition which contains a filesystem as a PV as a PV, will it destroy all the data in the filesystem? If yes, does it mean that I can't move a filesystem from a partition to a LV, by pvcreate the partition as a PV (and then lvcreate a LV)?

Thanks.

  • 1
    What do you mean by "mark the disk as a PV"? Formatting an existing device as a PV will effectively lose said data in the same way that reformating a filesystem with a new filesystem will lose previous files. – Torin Feb 24 at 16:05
  • What do you mean? Marking a device as a PV is not reformating a filesystem with a new filesystem. – Tim Feb 24 at 16:24
  • Both involve removing the structure of a volume and replacing it with a new structure. You don't make a physical volume by "marking" it as such in the same way you don't make a filesystem by "marking" it - it needs formatting – Torin Feb 24 at 16:29
  • 1
    pvcreate writes a header block. This may effectively make the data structures (eg the filesystem superblock) unreadable, but the underlying data may be recoverable by a data recovery tool, or by dd. From a typical end-user perspective, doing pvcreate on a block device may render the existing filesystem unreadable. – Stephen Harris Feb 24 at 16:35
1

Does it say that pvcreate will destroy all the data on a disk,

No, I read all the quotes in your question, and it does not say this.

Never pvcreate, not mkfs, will securely delete a partition. They do not write to much of the partition. They only write what they need to, the rest is ignored.

When the OS reads this partition, it will see what type it is, and only follow links to initialised data, the rest with old stuff will be ignored. However if you choose to read it in a different way (forensic analysis), then you can see much of what was there before).

However

While we can not trust them to remove data, we also cannot trust them not to write over data. They write what they need to, this could over-right important data.

Is there a way to convert from one file-system/PV to another?

I don't know. It depends what you are converting to what.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.