无法创建 LVM,原因是:未找到(或被过滤忽略)

无法创建 LVM,原因是:未找到(或被过滤忽略)

我计划将 LVM 用于 KVM,但当我尝试创建 VG 时失败了,那么如何创建 VG 和 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

答案1

vgcreate只是避免了您意外破坏所有数据。在您完全了解发生了什么之前,请不要再次尝试此操作。

我建议您至少熟悉 LVM HOWTO 的这些部分:

请记住,该磁盘/dev/sda已在使用中,因此尝试在其上创建 LVM 卷将破坏当前存在的所有数据。您将需要另一个硬盘,或者至少另一个硬盘分区。

不幸的是,由于不知道您的设置,我无法提供更具体的建议。

也可以看看:

答案2

您需要在硬盘中有可用空间

例子

# 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

CREATE NEW PARTITION
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

然后在卷组内创建逻辑卷(用作 DomU 的虚拟磁盘)

示例(为您的 centos 虚拟机创建一个 50G 的容量组)

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

:) Alex Dávila

答案3

您不能将 sda 的全部用于 LVM,因为您已经在其中使用了多个分区用于非 LVM 用途。如果您有一个 3 TB 的驱动器,并且想要使用 sda1-3 未使用的剩余空间(我假设 sda2 是交换分区),那么您应该创建一个额外的分区(假设为 sda4),将其标记为类型 0x8e(Linux LVM),然后pvcreate /dev/sda4运行vgcreate virtual-machines /dev/sda4​​。

答案4

我遇到了同样的错误。但是,之后一次重启,问题已解决。但其他答复也可能存在此类情况。

相关内容