VirtualBox增大硬盘容量(guest为Linux)

如果virtualbox中的guest系统出现磁盘空间不足的情况,最方便的方法就是将已有硬盘变大。网上能找到不少guest为windows时的扩大硬盘容量的方法,但在guest为linux时又略有不同。其实方法不止一种,下面以virtualbox自带的调整工具为例进行说明。
 
 
 
第一步:
 
如guest系统的vdi为debian_work.vdi,原大小为10G,现在想要扩大到20G,则到virtualbox安装路径下运行:
 
vboxmanage modifyhd debian_work.vdi --resize 20000
 
注:
 
1. 只有当vdi创建时选的动态扩展才有效。
 
2. 参数resize后以M为单位,只能比原来的空间大。
 
3. 实际当中vdi可能会需要加路径。
 
这是官方文档上的一段说明:
 
"The --resize option allows you to expand the capacity of an existing image; this increases thelogical size of a virtual disk without affecting the physical size much.[32] This currently works only for the VDI and VHD formats, and only for the dynamically expanding variants. For example, if you originally created a 10G disk which is now full, you can use the --resize command to add more space to the virtual disk without having to create a new image and copy all data from within a virtual machine."
 
 
 
第二步:
 
如果第一步成功了的话会在virtualbox的管理界面里看到该vdi文件的虚拟大小为20G,但实际大小为10G不到。到guest系统(Linux)中执行
 
# fdisk -l
 
会发现/dev/sda中有一块空间是没有分配的,执行
 
# fdisk /dev/sda
 
进行分配,根据说明依次输入
 
n(新建), p(主分区), x(数字,代表/dev/sdax),起末位置一般默认即可,最后w保存退出。
 
 
 
第三步:
 
重启后看到新建分区(如/dev/sda3),然后将之挂载到某一目录(如/workspace)。先运行
 
#blkid
 
得到新建分区/dev/sda3的UUID,然后编辑/etc/fstab,加上
 
UUID=xxxxxx    /workspace   ext3   errors =remount-ro  0   1
 
当中实际的参数请根据需要填写。以后重启完了就可以通过/workspace访问新扩大的磁盘了。
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值