首页 > 其他 > 详细

Extended VM Disk In VirtualBox or VMware

时间:2014-04-07 08:37:42      阅读:657      评论:0      收藏:0      [点我收藏+]

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

vmdk:

bubuko.com,布布扣
vmware-vdiskmanager -x 16GB myDisk.vmdk
bubuko.com,布布扣

vdi:

bubuko.com,布布扣
VBoxManage modifyhd <absolute path to file> --resize <size in MB>
bubuko.com,布布扣

 

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.

bubuko.com,布布扣
fdisk /dev/sda
bubuko.com,布布扣

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

bubuko.com,布布扣
resize2fs /dev/sda1
bubuko.com,布布扣

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.

bubuko.com,布布扣
bubuko.com,布布扣
#.......
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, lets 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 <<EOF
p
d
$PART_NUM
n
p
$PART_NUM
$PART_START

p
w
EOF
  ASK_TO_REBOOT=1

  # 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: 2 3 4 5 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" >&2
    exit 3
    ;;
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" 20 60 2
  fi
}
#......
View Code
bubuko.com,布布扣

 

[via]

[via]

 

Extended VM Disk In VirtualBox or VMware,布布扣,bubuko.com

Extended VM Disk In VirtualBox or VMware

原文:http://www.cnblogs.com/eshizhan/p/3648896.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!