-1

https://www.thegeekdiary.com/lvm-error-cant-open-devsdx-exclusively-mounted-filesystem/ says

LVM will only create a pv label on a device if it is not currently in use. There are some of the other various causes for this issue, which include’s:

  • The device for pvcreate has a mounted filesystem.

  • The device for pvcreate has a partition, but you are running pvcreate on the whole disk.

For the first case, it recommends a solution:

If it is being used by a mount point which is currently mounted, umount it first.

If the device is a partition with an un-mounted filesystem, will pvcreate still refuse to create a PV out of the partition by default? (I can't test it out, because it is dangerous to test.)

I think that pvcreate should always refuse to create a PV out of a partition by default, if the partition contains a filesystem, regardless of whether the filesystem is mounted or not, to avoid data loss.

Thanks.

  • So…Why don't you just test it on a loop device? Or more general, test everything in a VM… – 炸鱼薯条德里克 Feb 26 at 10:02
1

LVM will not refuse PV creation when on partition where is filesystem and partition is unmounted. At the end the responsibility for commands is yours. LVM (or any other program in Linux/UNIX) will refuse operation when this operation can interfere with the running OS. And as filesystem is not mounted it is not part of running OS

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.