First, Clean VM all snapshot, and poweroff your VM.

vmdk:

vmware-vdiskmanager -x 16GB myDisk.vmdk

vdi:

VBoxManage modifyhd <absolute path to file> --resize <size in MB>

And now, go to guest OS to resize partition.

I have only one partition, and it's root partition. You can use LiveCD do this. However, You alse use fdisk and resize2fs, that support online mode.

fdisk /dev/sda

Delete old partition, and create new partition you want. Last, write to disk, reboot your VM. Then run:

resize2fs /dev/sda1

Now, you can check your partition size.

df -h

P.S.

I find Shell script on raspi-config. It's a script it is used for expand root filesystem on SD card.

#.......
do_expand_rootfs() {
if ! [ -h /dev/root ]; then
whiptail --msgbox "/dev/root does not exist or is not a symlink. Don't know how to expand"
return
fi ROOT_PART=$(readlink /dev/root)
PART_NUM=${ROOT_PART#mmcblk0p}
if [ "$PART_NUM" = "$ROOT_PART" ]; then
whiptail --msgbox "/dev/root is not an SD card. Don't know how to expand"
return
fi # NOTE: the NOOBS partition layout confuses parted. For now, let's only
# agree to work with a sufficiently simple partition layout
if [ "$PART_NUM" -ne ]; then
whiptail --msgbox "Your partition layout is not currently supported by this tool. You are probably using NOOBS, in which case your root filesystem is already expanded anyway."
return
fi LAST_PART_NUM=$(parted /dev/mmcblk0 -ms unit s p | tail -n | cut -f -d:) if [ "$LAST_PART_NUM" != "$PART_NUM" ]; then
whiptail --msgbox "/dev/root is not the last partition. Don't know how to expand"
return
fi # Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f -d:)
[ "$PART_START" ] || return
# Return value will likely be error for fdisk as it fails to reload the
# partition table because the root fs is mounted
fdisk /dev/mmcblk0 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START p
w
EOF
ASK_TO_REBOOT= # now set up an init.d script
cat <<\EOF > /etc/init.d/resize2fs_once &&
#!/bin/sh
### BEGIN INIT INFO
# Provides: resize2fs_once
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Resize the root filesystem to fill partition
# Description:
### END INIT INFO . /lib/lsb/init-functions case "$1" in
start)
log_daemon_msg "Starting resize2fs_once" &&
resize2fs /dev/root &&
rm /etc/init.d/resize2fs_once &&
update-rc.d resize2fs_once remove &&
log_end_msg $?
;;
*)
echo "Usage: $0 start" >&
exit
;;
esac
EOF
chmod +x /etc/init.d/resize2fs_once &&
update-rc.d resize2fs_once defaults &&
if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "Root partition has been resized.\nThe filesystem will be enlarged upon the next reboot"
fi
}
#......

[via]

[via]

Extended VM Disk In VirtualBox or VMware (虚拟机磁盘扩容)的更多相关文章

  1. Hyper-V与VirtualBox或VMware虚拟机软件冲突的解决方法(VirtualBox只能创建32位虚拟机)

    Hyper-V与VirtualBox或VMware虚拟机软件冲突的解决方法 Hyper-V是微软的虚拟化软件,功能类似VirtualBox.VMware,可以用来创建虚拟机. 虚拟化软件都是基于CPU ...

  2. 如何将Virtualbox和VMware虚拟机相互转换[译文211] - 转

    迁移到其他的虚拟机程序可行会吓倒一批人.如果你已经按照自己的喜好设置好了虚拟机,那么就不需要再从头安装——你可以迁移现有的虚拟机. VirtualBox 和 VMware 使用不同的虚拟机格式,不过他 ...

  3. Workstation和Virtualbox的虚拟机磁盘扩容方式.

    1. 虚拟机磁盘管理, 更改磁盘格式是一个场景 还有一个场景是 硬盘空间不够了 需要扩充. 方法主要有两个. 如果是workstation的的虚拟机. 并且没有快照 可以直接GUI操作 如下图: 虚拟 ...

  4. 关于VMware虚拟机磁盘收缩的几种方法

    VMware虚拟机在使用过程中,随着软件和数据的增多,虚拟磁盘占用的硬盘空间会逐渐增大,但删除数据后,却不会自动减小占用的物理硬盘空间 而是继续占用相应大小.如果需要解决上面的问题,就需要收缩wmwa ...

  5. VMware exsi虚拟机磁盘扩容

    创建Linux时分配磁盘空间随着使用的增加,使用率逐渐升高,需要对/root进行扩容,此时需要在添加或者扩展一下磁盘. 查看Linux版本信息 [root@localhost ~]# cat /etc ...

  6. VMware虚拟机磁盘收缩的几种方法

    原文地址:http://www.cnblogs.com/5201351/p/4290401.html 根据下面转载的内容,我在VMware 12.0.0 build-2985596的ubuntu上做试 ...

  7. [CentOS7]Windows下VirtualBox虚拟机磁盘扩容

    目录 虚拟系统磁盘文件扩充 修改分区 LVM更新 扩容文件系统 参考资料 虚拟系统磁盘文件扩充 命令操作 命令行运行VBoxManage,modifyhd扩容需要文件格式为.vdi,如为.vmdk,需 ...

  8. Vmware Linux虚拟机磁盘扩容方法

    我的LINUX版本是ubuntu12.04 32bit.今天在下载android源代码的时候发现自己最初给这个虚拟机分配的磁盘空间不足了(只有20G).所以就需要给磁盘扩容.网上大致搜索了一下,主要有 ...

  9. 最简单的Linux虚拟机磁盘扩容方法

    思路:1.虚拟机增加磁盘容量: 2.将增加的磁盘容量增加到系统分区中: 准备阶段: 下载Gparted软件:https://sourceforge.net/projects/gparted/files ...

随机推荐

  1. Chrome 主页被篡改

    尝试恢复设置.重装chrome.改注册表均无果.最后意外发现解决方法无比简单:删掉桌面上的chrome图标,打开安装文件夹找到chrome.exe,随便改成什么名字.exe,比如baiduwcnm,重 ...

  2. Gearman的使用

    对于分布式网络环境或者有大量任务的应用,我们需要将任务在不同的服务器之间进行分布,这个时候正好是Gearman发挥实力的时候.虽然我们也可以使用MQ队列再加一些自己实现的调度算法来将任务进行分发,但是 ...

  3. [maven] settings 文件 本地maven仓库

    <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Soft ...

  4. ErrorProvider控件使用

    在Windows应用程序开发中,我们可以通过处理输入控件(如TextBox控件)的Validating事件,对用户的输入进行有效性验证,当用户输入不正确时,可以使用错误提示控件ErrorProvide ...

  5. Qt QTcpSocket 对连接服务器中断的不同情况进行判定

    简述 对于一个C/S结构的程序,客户端有些时候需要实时得知与服务器的连接状态.而对于客户端与服务器断开连接的因素很多,现在就目前遇到的情况进行一下总结. 分为下面六种不同情况 客户端网线断开 客户端网 ...

  6. hibernate向mysql数据库插入中文显示??

  7. Java如何监视线程的状态?

    在Java编程中,如何监视线程的状态? 以下示例演示如何通过扩展Thread类并使用currentThread.getName()方法来监视线程的状态. package com.yiibai; cla ...

  8. mysql -- 远程访问mysql的解决方案

    1.改表法 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "u ...

  9. WAS启动报错Service failed to start. startServer return code = -1

    http://www-01.ibm.com/support/docview.wss?uid=swg21368020 Problem(Abstract) Attempts to start IBM We ...

  10. Linux可视化服务器管理工具webmin

    webmin是一个可视化的linux服务器管理工具,可以帮助我们实现很多功能. Webmin官网: http://www.webmin.com/ 下载地址:http://prdownloads.sou ...