VirtualBox下扩容vdi文件
VirtualBox下扩容vdi文件
版本:VirtualBox 5.0.14
之前VirtualBox创建的虚拟机的vdi文件过小,无法满足新的实验需求,扩容vdi文件的方法如下:
比如我这里将RHEL6_Primary12cRAC2.vdi文件扩容到60000M大小,方法如下:
VBoxManage modifyhd E:\Vbox\Primary12cRAC2\RHEL6_Primary12cRAC2.vdi --resize 60000
实际执行过程:
c:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd E:\Vbox\Primary12cRAC2\RH
EL6_Primary12cRAC2.vdi --resize 60000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
至此虚拟机层面的操作就算完成了。
但是这个时候启动虚拟机会发现大小没有变化:
[root@jydb2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_linuxbase-lv_root 28G 2.0G 24G 8% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
实际上这是因为我这里的环境使用的lvm,而对应的根分区使用的是磁盘的一个分区,而扩容的vdi对应的是/dev/sda磁盘,下面继续来看详细情况:
[root@jydb2 ~]# fdisk -l /dev/sda
Disk /dev/sda: 62.9 GB, 62914560000 bytes
255 heads, 63 sectors/track, 7648 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00047a24
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 3917 30944256 8e Linux LVM
可以看到/dev/sda已经成功扩容,现在只需要把扩容的空间新建成一个分区:
[root@jydb2 ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sda: 62.9 GB, 62914560000 bytes
255 heads, 63 sectors/track, 7648 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00047a24
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 3917 30944256 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (3917-7648, default 3917):
Using default value 3917
Last cylinder, +cylinders or +size{K,M,G} (3917-7648, default 7648):
Using default value 7648
Command (m for help): p
Disk /dev/sda: 62.9 GB, 62914560000 bytes
255 heads, 63 sectors/track, 7648 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00047a24
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 3917 30944256 8e Linux LVM
/dev/sda3 3917 7648 29975280 83 Linux
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.
[root@jydb2 ~]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
新加的分区需要重启才能生效。
重启虚拟机之后就可以将新加的分区创建成pv加入到vg,最终扩容lv即可,可以分为4个步骤,具体如下:
1.创建pv
[root@jydb2 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@jydb2 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_linuxbase lvm2 a-- 29.51g 0
/dev/sda3 lvm2 a-- 28.59g 28.59g
2.扩容vg
[root@jydb2 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_linuxbase 1 2 0 wz--n- 29.51g 0
[root@jydb2 ~]# vgextend -h
vgextend: Add physical volumes to a volume group
vgextend
[-A|--autobackup y|n]
[--restoremissing]
[-d|--debug]
[-f|--force]
[-h|--help]
[-t|--test]
[-v|--verbose]
[--version]
[-y|--yes]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
[root@jydb2 ~]# vgextend vg_linuxbase /dev/sda3
Volume group "vg_linuxbase" successfully extended
[root@jydb2 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_linuxbase 2 2 0 wz--n- 58.09g 28.58g
3.扩容lv
[root@jydb2 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_root vg_linuxbase -wi-ao---- 27.54g
lv_swap vg_linuxbase -wi-ao---- 1.97g
[root@jydb2 ~]# vgdisplay
--- Volume group ---
VG Name vg_linuxbase
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 58.09 GiB
PE Size 4.00 MiB
Total PE 14871
Alloc PE / Size 7821 / 30.55 GiB
Free PE / Size 7050 / 27.54 GiB
VG UUID 41Wk3c-fuD0-SKcX-RqNQ-7uIP-e2xD-1mWaUd
[root@jydb2 ~]# lvresize -l +7050 /dev/mapper/vg_linuxbase-lv_root
Extending logical volume lv_root to 56.12 GiB
Logical volume lv_root successfully resized
[root@jydb2 ~]# vgdisplay
--- Volume group ---
VG Name vg_linuxbase
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 58.09 GiB
PE Size 4.00 MiB
Total PE 14871
Alloc PE / Size 14871 / 58.09 GiB
Free PE / Size 0 / 0
VG UUID 41Wk3c-fuD0-SKcX-RqNQ-7uIP-e2xD-1mWaUd
[root@jydb2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_linuxbase-lv_root 29G 2.0G 25G 8% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
4.resize2fs lv
[root@jydb2 ~]# resize2fs /dev/mapper/vg_linuxbase-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_linuxbase-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 4
Performing an on-line resize of /dev/mapper/vg_linuxbase-lv_root to 14711808 (4k) blocks.
The filesystem on /dev/mapper/vg_linuxbase-lv_root is now 14711808 blocks long.
[root@jydb2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_linuxbase-lv_root 56G 2.0G 51G 4% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
至此,已成功扩容了该虚拟机的系统根目录。
VirtualBox下扩容vdi文件的更多相关文章
- Mac环境下扩容 .vmdk 镜像容量
参考: Resizing a VirtualBox Disk Image (.vmdk) on a Mac Mac环境下扩容 .vmdk 镜像容量 在安装虚拟机时,原有的vmdk镜像容量只有20G,在 ...
- VirtualBox 复制vdi文件和修改vdi的uuid
1.复制vdi文件:VBoxManage clonehd 因为VirtualBox不允许注册重复的uuid,而每个vdi文件都有一个唯一的uuid.所以要想拷贝一份vdi文件再次在VBOX中注册,简单 ...
- VirtualBox 导入.vdi文件时报“uuid is exists”错误
解决办法: 1.要安装的.vdi文件所在目录:D:\developTools\vm\RedHatLinux1.vdi 2.找到VirtualBox的安装目录,这里是D:\Program Files\O ...
- 【转】VIRTUALBOX导入已有.VDI文件步骤
原文网址:http://blog.csdn.net/wanghai__/article/details/6703923 1.安装SUN VIRTUALBOX 2.新建,进入到“新建虚拟电话”对话框,下 ...
- 使用VirtualBox把IMG文件转换为VDI文件
使用VirtualBox把IMG文件转换为VDI文件 首先确保已安装VirtualBox. 需要使用的命令: 语法:$ VBoxManage convertdd input.img output.vd ...
- VirtualBox虚拟机怎么导入已经存在的vdi文件
VirtualBox虚拟机怎么导入已经存在的vdi文件 第一章 1.原因 早上一不小心将virtualBox 卸载了,(不知道怎么了, 里面得虚拟机全部都没有了,但是vdi文件还在) 2.解决办法 直 ...
- 【原创】VirtualBox 磁盘扩容教程
问题和环境说明 环境: 主机:Ubuntu 15.10 客户机:Windows 7 x64 VirtualBox:5.0.10 虚拟机磁盘类型:VDI(VirtualBox磁盘映像) 问题: 在虚拟机 ...
- VirtualBox修改现有VDI虚拟磁盘大小
之前创建的虚拟磁盘10G,现需要更大的空间,而又不想使用新增虚拟磁盘的方法. 通过查看资料发现VirtulBox提供的VBoxManage modifyhd命令可以解决,该命令的具体用法: VBoxM ...
- VirtualBox虚拟机扩容
1. 在VBox下增加储存 如图,未扩容前是40G 打开cmd命令行(win+r 输入cmd打开) 将目录切换到virtual的安装目录 cd C:\Program Files\Oracle\Vir ...
随机推荐
- [No0000E6]C# 判断与循环
判断语句 语句 描述 if 语句 一个 if 语句 由一个布尔表达式后跟一个或多个语句组成. if...else 语句 一个 if 语句 后可跟一个可选的 else 语句,else 语句在布尔表达式为 ...
- [No0000B6]C#中 ==与equals的区别
using System; internal class Person { public Person(string name) { Name = name; } public string Name ...
- 2012年蓝桥杯省赛A组c++第3题(喝断片的海盗)
/* 有一群海盗(不多于20人),在船上比拼酒量.过程如下:打开一瓶酒, 所有在场的人平分喝下,有几个人倒下了.再打开一瓶酒平分,又有倒下的, 再次重复...... 直到开了第4瓶酒,坐着的已经所剩无 ...
- lua--openresty--
lua-openresty---docker-- https://blog.csdn.net/boling_cavalry/article/details/79290944 lua-practice ...
- Instruments学习之Allocations
Allocations:检测一个进程(选择自己的app)内存分配和使用情况等 我们启动Allocations后得到一个初始界面 初始界面.png 简单说一下上图的3个地方 1:这里有两个部分了,因为官 ...
- [qemu] qemu旧的net参数已经不再可用了,新的这样用。
老的命令: /root/BUILD_qemu/bin/qemu-system-x86_64 -enable-kvm \ -m 2G \ -cpu Nehalem -smp cores=,threads ...
- [skill] ctags支持函数声明
一般情况下,使用ctags的时候,默认使用如下命令: ctags -R ./ 但是这种情况下,如果运行在include文件夹下的时候,好多函数是跳转不过去的,因为这种默认情况下,函数声明并不会被索引. ...
- XML文件处理
XML XML简介 XML被设计用来传输和存储数据. XML是可扩展标记语言. 解析XML的几种方式 DOM,DOM4j------先把XML文件读取到内存中,然后再解析 SAX----------边 ...
- Java基础知识之集合
Collection集合 特点:长度可变,只能存储引用类型,可以存储不同的类型的元素 list 特点:元素有序(存储和取出的顺序一致),元素可以重复.list除了可以用迭代器循环遍历之外,因为其是有序 ...
- Kubernetes应用管理
除了容器资源管理和调度,Kubernetes另外一个核心价值是提供了针对不同类型应用管理的API接口集合,这些API集合把针对不同类型应用的管理能力分别到Kubernetes平台中.以Web业务(Lo ...