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. java 缩放算法 双线性插值,双三次插值

    双线性插值的效果对于放大的图像而言较领域插值来得平滑,但是却使得图像变得模糊而且仍然会有一部分锯齿现象. 双三次插值更好比双线性插值更好.   图像缩放之双三次插值法 数字图像处理之双线性插值

  2. MFC中的句柄

    1.引出句柄 CDC问题:1.CDC dc;dc.LineTo(point);无法运行 2.CDC *dc=GetDC();dc->LineTo(point);就可以运行了 MFC中有大量的句柄 ...

  3. Claims-Based Authentication and Authorization

    Introduction You can download the Visual Studio solutions for this article at this location. With al ...

  4. (笔记)Linux Socket通信:bind: Address already in use

    在网络通信时使用Bind绑定IP地址跟端口号时,有时Ctrl+C强制结束进程之后,再次运行程序Bind错误,原因如下: 虽然用Ctrl+C强制结束了进程,但错误依然存在,用netstat -an |g ...

  5. Maven 构建配置文件

    什么是构建配置文件? 生成配置文件是一组可以用来设置或覆盖 Maven 构建配置值的默认值.使用生成配置文件,你可以针对不同的环境,如:生产V/S开发环境自定义构建. 配置文件中指定 pom.xml ...

  6. Lua------------------unity关于lua的使用

    关于Lua在Unity 中的使用   对于手机游戏,如果可以在线更新以实现bug修复.新功能添加等等,其好处自不必多说. 通过C#的反射机制,也可以实现某种程度上的脚本级更新,具体可以参考 http: ...

  7. Winform控件学习笔记【第二天】——常用控件

    背景:期末考试刚过就感冒了,嗓子火辣辣的,好难受.但是一想起要学习总结就打起精神来了,Winform控件网上也没有多少使用教程,大部分都是自己在网上零零散散的学的,大部分用的熟了,不总结会很容易忘得. ...

  8. C#连接SQL数据库代码

    感觉很有必要总结一下 一:C# 连接SQL数据库  Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername; ...

  9. tf.variable_scope

    转载:https://blog.csdn.net/gaoyueace/article/details/79079068 例如: #在名字为ae的命名空间内创建变量 with tf.variable_s ...

  10. 关于Struts2的文件上传

    要实现Struts2框架的文件上传,需要用到2个jar包 commons-fileupload-1.2.2.jar commons-io-2.0.1.jar 由于文件解析Struts2内部已经帮我们做 ...