无法创建 LVM 由于:未找到(或被过滤忽略)

Zim*_*m3r 5 linux lvm centos6

我打算将 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
Run Code Online (Sandbox Code Playgroud)

小智 9

您需要在高清中有可用空间

例子

# 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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

创建物理卷

# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
Run Code Online (Sandbox Code Playgroud)

显示物理卷

# 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
Run Code Online (Sandbox Code Playgroud)

创建一个卷组

# vgcreate virtual-machines /dev/sda3
Volume group "virtual-machines" successfully created
Run Code Online (Sandbox Code Playgroud)

显示卷组

# 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
Run Code Online (Sandbox Code Playgroud)

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

示例(为你的centos虚拟机创建一个50G的vaolume组)

lvcreate -nfedora64-1 -L50G /dev/virtual-machines
Logical volume "fedora64-1" created
Run Code Online (Sandbox Code Playgroud)

:) 亚历克斯·达维拉


Mic*_*ton 8

vgcreate刚刚使您免于意外破坏所有数据。在您完全了解正在发生的事情之前,请勿再次尝试。

我建议您至少熟悉 LVM HOWTO 的以下部分:

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

不幸的是,在不了解您的设置的情况下,我无法提供更具体的建议。

也可以看看: