为虚拟机硬盘扩容(Oracle VM VirtualBox)的方法啊

E:\VirtualBox>VBoxManage list hdds    首先获取要扩容的虚拟机的 UUID

UUID:           a6018b56-dda9-4e92-b2d7-666622cc7fc3

Parent UUID:    base

State:          locked write

Type:           normal (base)

Location:       E:\ls\ls1.vdi

Storage format: VDI

Capacity:       20480 MBytes

 

E:\VirtualBox>VBoxManage modifyhda6018b56-dda9-4e92-b2d7-666622cc7fc3  --resize 25600     (由20480 扩容到 25600)

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

 

刚开始结果:

[root@ls ~]# df -h

Filesystem           Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      16G   15G  283M  99% /

/dev/sda1             99M   23M   71M  25% /boot

tmpfs                1.1G     0  1.1G   0% /dev/shm



[root@ls ~]# fdisk -l

 

Disk /dev/sda: 26.8 GB, 26843545600 bytes

255 heads, 63 sectors/track, 3263 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

 

   DeviceBoot     Start        End      Blocks   Id  System

/dev/sda1  *          1         13      104391   83  Linux

/dev/sda2             14        2610   20860402+  8e  Linux LVM

 

这个时候只是容量从20G扩充到25G,但还不能使用

将空余磁盘创建为 sda3

 

# fdisk /dev/sda  (依次输入 n p 3 t 3 8e w )

  n{new partition}

  p{primary partition}

  3{partition number}

 

  t{change partition id}

  3 {partitionnumber}

  8e{Linux LVM partition}

  w

 

[root@ls ~]# reboot

查看一下:

[root@ls ~]# fdisk -l /dev/sda

 

Disk /dev/sda: 26.8 GB, 26843545600 bytes

255 heads, 63 sectors/track, 3263 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

 

   DeviceBoot     Start        End      Blocks   Id  System

/dev/sda1  *          1         13      104391   83  Linux

/dev/sda2             14        2610   20860402+  8e  Linux LVM

/dev/sda3           2611        3263    5245222+  8e  Linux LVM

 

调整 LVM 大小先看看当前 Volume Group:

 [root@ls~]# vgdisplay

  ---Volume group ---

  VGName               VolGroup00

 System ID            

 Format                lvm2

 Metadata Areas        2

 Metadata Sequence No  5

  VGAccess             read/write

  VGStatus             resizable

  MAXLV                0

  CurLV                2

 Open LV               2

  MaxPV                0

  CurPV                2

  ActPV                2

  VGSize              19.88 GB

  PESize               32.00 MB

 Total PE              796

 Alloc PE / Size       796 / 24.88GB

 Free  PE / Size       0 / 0  

  VGUUID               pjf0p4-myx5-QbxW-XK3X-rUFT-jSBS-4uub4T

名称为 VolGroup00,可调整大小(resizable),当前大小为19.88 GB。

活动的 LVM 卷有,

[root@ls ~]# lvscan 

ACTIVE     '/dev/VolGroup00/LogVol00 '[15.91GB] inherit 

ACTIVE           '/dev/VolGroup00/LogVol01' [3.97 GB] inherit

先将分配过来的新磁盘空间创建为一个新的物理卷,

[root@ls ~]# pvcreate /dev/sda3 

Physical volume "/dev/sda3"successfully created

然后使用新的物理卷来扩展 LVM 的 VolGroup00

vgextend VolGroup00 /dev/sda3

[root@ls ~]# vgextend VolGroup00 /dev/sda3
  Volume group "VolGroup00" successfully extended
然后扩展 LVM 的逻辑卷 VolGroup00/LogVol00
[root@ls ~]# lvextend /dev/VolGroup00/LogVol00 /dev/sda3
  Extending logical volume LogVol00 to 20.91 GB
  Logical volume LogVol00 successfully resized
最后,调整逻辑卷文件系统的大小,
[root@ls ~]# resize2fs  /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizingrequired
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 5480448 (4k)blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 5480448 blocks long.

完成。看看效果:
[root@ls ~]# lvscan
  ACTIVE           '/dev/VolGroup00/LogVol00' [20.91 GB] inherit
  ACTIVE           '/dev/VolGroup00/LogVol01' [3.97 GB] inheri

 

另外,几个有用的 LVM 指令(lvm2):

  • lvmdiskscan
  • vgdisplay
  • pvdisplay
  • lvdispay
  • vgcreate
  • pvcreate
  • lvscan
  • pvscan
  • vgscan

最后结果:
[root@ls ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      21G   15G  4.9G  75% /
/dev/sda1             99M   23M   71M  25% /boot
tmpfs                1.1G     0  1.1G   0% /dev/shm
 

 







 




 

你可能感兴趣的:(LINUX)