I'm planning to use LVM for KVM, and when I try to create a VG it fails, so how can I create my VG and LV ?


[root@server ~]# vgcreate virtual-machines /dev/sda
  Device /dev/sda not found (or ignored by filtering).
  Unable to add physical volume '/dev/sda' to volume group 'virtual-machines'.
[root@server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             2.0T  929G  976G  49% /
tmpfs                 3.9G  124K  3.9G   1% /dev/shm
/dev/sda1             194M   57M  128M  31% /boot
[root@server ~]# pvscan
  No matching physical volumes found

vgcreate just saved you from accidentally destroying all your data. Don't try this again until you fully understand what's going on.

I recommend you familiarize yourself with at least these parts of the LVM HOWTO:

Remember that /dev/sda is already in use, so attempting to create LVM volumes on it will destroy any data currently there. You will need another hard drive, or at least another hard drive partition.

Unfortunately, without knowing your setup, it's impossible for me to give more specific advice.

See also:

|improve this answer|||||
  • Really Thanks, I mentioned my setup in Question. it's a 3TB hard drive. 200 MB /boot and remained space is mounted as / – Zim3r Sep 16 '12 at 10:18
  • James, you didn't provide any details about the partitioning of the drive. – Paul Gear Sep 17 '12 at 3:19
  • Reading "Common Tasks: Initializing disks or disk partitions" was helpful for me since I wanted to wipe the disks and start over. For some reason when I deployed a new VM and attached it to my old ISCSI the sda and sdb drives were mangled? – Breedly Jul 8 '17 at 20:42

You need to have free space in your HD


# fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3dd7

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     4196351     2097152   83  Linux
/dev/sda2         4196352   172148735    83976192   8e  Linux LVM

Command (m for help): n
Partition type:
p   primary (2 primary, 0 extended, 2 free)
e   extended
Select (default p): p
Partition number (1-4, default 3):
Using default value 3
First sector (172148736-1953525167, default 172148736):
Using default value 172148736
Last sector, +sectors or +size{K,M,G} (172148736-1953525167, default 1953525167):
Using default value 1953525167
Partition 3 of type Linux and of size 849.4 GiB is set


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

# partprobe


# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created


# pvdisplay
--- Physical volume ---
PV Name               /dev/sda2
VG Name               fedora_fed18
PV Size               80.09 GiB / not usable 4.00 MiB
Allocatable           yes
PE Size               4.00 MiB
Total PE              20501
Free PE               1
Allocated PE          20500
PV UUID               1BWm7E-M3Z8-WFJQ-vLRI-eUqa-MfPm-6x2mef

"/dev/sda3" is a new physical volume of "849.43 GiB"
--- NEW Physical volume ---
PV Name               /dev/sda3
VG Name              
PV Size               849.43 GiB
Allocatable           NO
PE Size               0  
Total PE              0
Free PE               0
Allocated PE          0
PV UUID               xo8Xrp-MpKE-MVE1-fkJr-Hebe-NSwo-4w502f


# vgcreate virtual-machines /dev/sda3
Volume group "virtual-machines" successfully created


# vgdisplay
--- Volume group ---
VG Name               virtual-machines
System ID            
Format                lvm2
Metadata Areas        1
Metadata Sequence No  1
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                0
Open LV               0
Max PV                0
Cur PV                1
Act PV                1
VG Size               849.42 GiB
PE Size               4.00 MiB
Total PE              217452
Alloc PE / Size       0 / 0  
Free  PE / Size       217452 / 849.42 GiB
VG UUID               M69gwe-S5e9-1ZXM-zlxg-L3yc-pR0P-mhW6Vi

--- Volume group ---
VG Name               fedora_fed18
System ID            
Format                lvm2
Metadata Areas        1
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               80.08 GiB
PE Size               4.00 MiB
Total PE              20501
Alloc PE / Size       20500 / 80.08 GiB
Free  PE / Size       1 / 4.00 MiB
VG UUID               r0LXYG-BQdo-WN7w-GcPa-uKxE-68mC-li3HFm


EXAMPLE (create a vaolume group of 50G for your centos virual machine)

lvcreate -nfedora64-1 -L50G /dev/virtual-machines
Logical volume "fedora64-1" created

:) Alex Dávila

|improve this answer|||||
  • 1
    How does this work if you're creating a primary partition and then a physical partition on that new primary partition? Mine fails every time with Device /dev/sda3 not found (or ignored by filtering). – Brandon Mar 21 '16 at 18:42
  • the partprobe step was what fixed it for me - I'd just shutdown my vmware VM, extended the disk, booted up and added the partition with 'fdisk'. That's usually enough, but for whatever reason the partition isn't known by the OS, even though fdisk shows it until you do the partprobe (or reboot). – Ralph Bolton Nov 8 '17 at 11:35

You can't use all of sda for LVM since you're already using several partitions on it for non-LVM uses. If you have a 3 TB drive, and you want to use the remaining space not used by sda1-3 (i'm assuming sda2 is swap), then you should create an extra partition (sda4, let's say), flag it as type 0x8e (Linux LVM), then run pvcreate /dev/sda4 and vgcreate virtual-machines /dev/sda4.

|improve this answer|||||

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.