为虚拟机硬盘扩容(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,但還不能使用
將空余磁盤創(chuàng)建為 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
先將分配過來的新磁盤空間創(chuàng)建為一個新的物理卷,
[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
最后,調整邏輯卷文件系統(tǒng)的大小,
[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):
lvmdiskscanvgdisplaypvdisplaylvdispayvgcreatepvcreatelvscanpvscanvgscan最后結果:
[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
總結
以上是生活随笔為你收集整理的为虚拟机硬盘扩容(Oracle VM VirtualBox)的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中职计算机基础微课,浅谈中职计算机应用基
- 下一篇: 1、Elasticsearch简介与安装