Skip to content

Instantly share code, notes, and snippets.

@chenchun
Last active July 13, 2020 08:17
Show Gist options
  • Save chenchun/a15e878618f1146a0e29 to your computer and use it in GitHub Desktop.
Save chenchun/a15e878618f1146a0e29 to your computer and use it in GitHub Desktop.
Add another disk for your vagrant box, dd

http://vladimir-ivanov.net/how-to-compact-virtualboxs-vdmk-file-size/

  1. Fill the free space with zeros VirtualBox only knows that the space is really free if it’s been set to zero, and standard deletion won’t do this. Login into the virtual machine and run the following command:
cat /dev/zero > zero.fill; sync; sleep 1; sync; rm -f zero.fill
  1. compact vmdk
cd ~/VirtualBox\ VMs/kubernetes_master_1477538740395_78361/
VBoxManage clonehd fedora-23-x86_64-disk1.vmdk fedora-23-x86_64-disk1.vdi --format vdi
VBoxManage modifyhd fedora-23-x86_64-disk1.vdi --compact

虚拟介质管理 => remove fedora-23-x86_64-disk1.vmdk
VBoxManage clonehd fedora-23-x86_64-disk1.vdi fedora-23-x86_64-disk1.vmdk --format vmdk
虚拟介质管理 => remove fedora-23-x86_64-disk1.vdi
虚拟机设置=>添加虚拟硬盘=>add fedora-23-x86_64-disk1.vmdk
//first use virtual box GUI to add another
//virtual disk and then use fdisk to create
//a primary disk partion
fdisk -l
fdisk /dev/sdb/
mkfs.ext4 /dev/sdb1
mount -t ext4 /dev/sdb1 /home/chenchun
# oflag=direct,sync
dd if=/dev/zero of=tmpfile bs=4k count=1024 oflag=direct,sync
管理vmdk vni虚拟盘,virtualbox菜单栏=>管理=>虚拟介质管理
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment