Virtualbox 扩展vdi

连接:https://www.jeffgeerling.com/blogs/jeff-geerling/resizing-virtualbox-disk-image
by Perryg » 27. Jul 2012, 22:32
Resize a virtual HDD

VBoxManage showhdinfo mydisk.vdi
VBoxManage clonehd mydisk.vdi mydiskClone.vdi –variant Standard
VBoxManage modifyhd mydiskClone.vdi –resize 61440
VBoxManage showhdinfo mydiskClone.vdi

First resizing does not work if the guest has snapshots (prior to version 4.3.*) nor will it work on Fixed drives.
Secondly when doing anything that could prove as destructive as this should you make a mistake, backup the *.vdi file before you start.

Increasing the drive does not increase the primary partition so this is a two step process.

Step 1: Increase the size of the drive.
Note: if the path has spaces in it you will need to wrap the path in quotes.
Use the following command to increase the size of the drive:
Code: Select all Expand view
VBoxManage modifyhd –resize

Example: I have a 10GB drive that I want to be 20GB the command would be.
Code: Select all Expand view
VBoxManage modifyhd –resize 20480
可以将动态分配虚拟磁盘转换为固定磁盘:
sudo vboxmanage clonehd “Extend-Arch.vdi” “fixed-Arch.vdi” –variant Fixed

Step 2: Extend the primary partition to include the new drive space.
Download the Gparted live cd or what ever partition manager program you wish and mount it to the guests virtual CD and boot the guest.
From here you can expand the primary partition to use the new space.
Windows Vista and newer guests can use the Disk Management to expand the primary partition.

You can download the Gparted Live CD from HERE.

Note 1: The only step that VirtualBox is concerned with is step 1. After that you need to seek additional information on the partition manager you wish to use from the vendor of the partition manager.

Note 2: You can not shrink a guest drive with VirtualBox due to the inherent danger of loosing data or making the guest non-bootable.

Note 3: In 4.3.0 the devs fixed a bug which had previously made it impossible to resize a snapshot. Since then it is possible, but not recommended for non-experts.
Last edited by Perryg on 18. Aug 2015, 16:24, edited 3 times in total.
Perryg
Site Moderator

Posts: 33801
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Top
Re: How to resize a Virtual Drive

by mpack » 25. Aug 2013, 11:47
What if I used Fixed Disks, or VMDK?

As the advice above states, resizing of fixed VDIs or VHDs is not directly supported, nor is resizing of formats other than VHD/VDI. Nor is it easy to resize disks which are part of a snapshot chain.

However, all of these problems are easily addressed if you clone the disk to a supported format first, using :-
(fields in brackets are placeholders which should be replaced with actual filenames, the brackets are not literal)
Code: Select all Expand view
VBoxManage clonehd –format VDI –variant Standard

You can then resize the resulting dynamic VDI using “VBoxManage modifyhd” as described in the previous message.

If a snapshot chain is involved then should be the name of the latest snapshot VDI in the “Snapshots” subfolder. Do not make the rookie mistake of cloning the base VDI. In this case “clonehd” will create a merged clone and it’s important that you not incorporate this back into a VM which is still expecting a chain of difference disk images. Either build a new VM around the clone, or delete all the snapshot markers from the original VM, then replace the disk file. If the VM did not use difference images (no immutable drive, linked clone or snapshot) then you can use the Storage settings panel to remove the old disk and replace with the new one.
mpack
Site Moderator

Posts: 24422
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Top
Re: How to resize a Virtual Drive

by mpack » 28. Jun 2016, 12:57
What if my VM uses Snapshots?

If you are intent on keeping the snapshot structure then you are supposed to enlarge all members of the snapshot chain, which is a risky business. Or you can enlarge only the latest snapshot, but that is even more risky (think about future complications when snapshot elements are removed).

The best thing is to delete all the snapshots using the UI, before enlarging the current state. Be sure to make a backup of the VM before starting this.

You can also use the “clone VM, then enlarge” trick from the previous post. In particular see the paragraph on merging a snapshot chain into a single disk using VBoxManage clonehd. This would be an easy way to dispense with snapshots, making it a trivial matter to enlarge the disk.

Gparted 使用方法:【gparted-live-0.14.1-6-i486.iso可以用,最新版本gparted-livecd-0.3.4-11.iso会提示文件系统不支持】

8down vote

Free space must be adjacent to a partition to make increasing the size of that partition possible.
You can use gparted running from a Live CD to move that 268GB partition (mysteriously called “C”) to the front of the free space. Then you can increase the size of the extended partition.
If you get an error from gparted during the resize process (it boils doen to partitions cannot overlap) then you’ve hit a bug in the gparted version shipped with Ubuntu 12.10 (it is 0.12.1).

Download the latest version of Gparted Live
burn that to a CD
boot your Computer from that CD (you have to answer a few uncritical questions here)
the last question allows you to "autostart gparted", which is what you want
now select the drive you need and there the extended partition (easiest done in the table)
right click on that line and select "resize/move" to get the following 
now you can drag the left arrow as far as you want to increase the partition
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值