我打算使用LVM作为KVM,当我尝试创buildVG时,它失败了,那么如何创build我的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
vgcreate
只是保存你意外销毁你的所有数据。 直到你完全明白发生了什么事情之前,不要再试这个。
我build议您至less熟悉一下LVM HOWTO的这些部分:
请记住/dev/sda
已经在使用,所以尝试在其上创buildLVM卷将会破坏当前所有的数据。 您将需要另一个硬盘驱动器,或至less另一个硬盘驱动器分区。
不幸的是,不知道你的设置,我不可能给出更具体的build议。
也可以看看:
你需要有你的高清自由空间
例
# 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
创build物理卷
# 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
创build一个卷组
# 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
然后创build您的逻辑音量(用作DomU的虚拟磁盘)在音量组内
示例(为您的centos虚拟机创build一个50G的vololume组)
lvcreate -nfedora64-1 -L50G /dev/virtual-machines Logical volume "fedora64-1" created
:)亚历克斯Dávila
您不能将所有的sda用于LVM,因为您已经在其上使用了多个分区来进行非LVM使用。 如果你有一个3 TB的驱动器,并且你想使用sda1-3没有使用的剩余空间(我假设sda2是交换),那么你应该创build一个额外的分区(sda4,比方说),标记为types0x8e(Linux LVM),然后运行pvcreate /dev/sda4
和vgcreate virtual-machines /dev/sda4
。