First, Clean VM all snapshot, and poweroff your VM.
vmdk:
vmware-vdiskmanager -x 16GB myDisk.vmdk
vdi:
VBoxManage modifyhd --resize
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" 20 60 2
return 0
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" 20 60 2
return 0
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 2 ]; 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." 20 60 2
return 0
fi
LAST_PART_NUM=$(parted /dev/mmcblk0 -ms unit s p | tail -n 1 | cut -f 1 -d:)
if [ "$LAST_PART_NUM" != "$PART_NUM" ]; then
whiptail --msgbox "/dev/root is not the last partition. Don't know how to expand" 20 60 2
return 0
fi
# Get the starting offset of the root partition
PART_START=$(parted /dev/mmcblk0 -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d:)
[ "$PART_START" ] || return 1
# 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