Manpage of 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.
Why doesn't the following pvcreate
command fail to mark a disk as PV then?
$ sudo parted -l
Model: ATA TOSHIBA MQ01ABF0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
2 538MB 500GB 500GB ext4
$ sudo lvmdiskscan
/dev/sda1 [ 512.00 MiB]
/dev/sda2 [ <465.26 GiB]
0 disks
2 partitions
0 LVM physical volume whole disks
0 LVM physical volumes
$ sudo pvcreate /dev/sda
Device /dev/sda excluded by a filter.
roaima wrote in https://unix.stackexchange.com/a/502428/674:
You're trying to use the entire /dev/sda for a PV. But you've got (at least) two partitions on that disk (sda1 and sda2), so LVM is rightly refusing to honour your request.
Does it mean that we can make a disk a PV by pvcreate
, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate
, if and only if the disk has more than one partitions?
Thanks.
/dev/sda1
and/dev/sda2
with gparted or any other partitioning program, then your disk is without partitions. – Freddy Feb 24 '19 at 16:52