[转帖学习]Howto Shrink a Thin Provisioned Virtual Disk (VMDK)
Howto Shrink a Thin Provisioned Virtual Disk (VMDK)
Thin provisioned disks are a great feature to save capacity as you virtual machines filesystem will never use the full capacity. I do not know a single system where you do not have at least 10GB of free space for OS disks. I am not considering databases, applications or fileservers which will grow constantly. Having thin provisioned disk is usually no longer a performance problem so it is a valid design choice even in production.
A common issue with thin disks is that the size will grow when required, but never shrink. When you require the capacity only once you might want to get it back from the virtual machine. This post describes how to reclaim unused space from the virtual machine.
Virtual Machine Preparation (Windows)
Windows does not automatically zero deleted blocks. Microsoft provides a tool that can zero blocks after while deleting a file or zero out the entire free space. This is required to reclaim space back from the virtual disk.
- Download SDelete
- run sdelete.exe -z [Drive]

Wait a couple of minutes until the process is finished. Please note that you virtual disk file (VMDK) will grow to the full size during the process.
Virtual Machine Preparation (Linux)
Linux does not zero deleted blocks too. There are various tools available to create zeroed blocks. The best known tool is dd which should be available on all systems.
- Identify free space with df
- Fill the free space with dd
vma:/mnt/data # df -h vma:/mnt/data # dd bs=1M count=8192 if=/dev/zero of=zero
This will zero 8GB of the available 8.2GB (1MB Blocksize * 8192 = 8GB). Please note that you virtual disk file (VMDK) will grow to the full size during the process.
Shrink VMDK File
- Power off the Virtual Machine, or disconnect the virtual Disk you want to shrink
- Connect to the ESXi Host with SSH
- Navigate to the Virtual Machine Folder
- Verify disk usage with du
- Run vmkfstools -K [disk]
- Verify disk usage with du
root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk 7.9G vma_1-flat.vmdk root@esx3:/vmfs/volumes/ds1/vma $ vmkfstools -K vma_1.vmdk vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576 Hole Punching: 25% done. root@esx3:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk 1.9G vma_1-flat.vmdk
[转帖学习]Howto Shrink a Thin Provisioned Virtual Disk (VMDK)的更多相关文章
- Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创)
Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创) 由于java interface中声明的字段在编译时会自动加上static final的修饰符,即声明为常量.因而inter ...
- [转帖]学习关于TTL
自己简单试了一下在家里与在公司里面服务器的连接: C:\Users\Administrator>tracert oms.inspur.com 通过最多 个跃点跟踪 到 oms.inspur.co ...
- [转帖]学习一下centos7 新地方
总结的挺好 copy一下 慢慢学习: http://blog.itpub.net/312079/viewspace-2214440/ Centos7 单用户模式 centos7里不再有0-6启动级别 ...
- [转帖学习]Oracle的 SYS_CONTEXT 函数简介
Oracle的 SYS_CONTEXT 函数简介 https://blog.csdn.net/IndexMan/article/details/48606369 1.什么是SYS_CONTEXT? S ...
- [转帖] 学习 Linux 大页的内存知识
一.在解释什么情况下需要开启大页和为啥需要开启大页前先了解下Linux下页的相关的知识:以下的内容是基于32位的系统,4K的内存页大小做出的计算1)目录表,用来存放页表的位置,共包含1024个目录en ...
- [转帖] 学习一下 apache bench 的总结简介 ( LAMP的没用过..)
PS:网站性能压力测试是性能调优过程中必不可少的一环.只有让服务器处在高压情况下才能真正体现出各种设置所暴露的问题.Apache中有个自带的,名为ab的程序,可以对Apache或其它类型的服务器进行网 ...
- 算法学习 howto
入门: The Most Important Algorithms http://www.risc.jku.at/people/ckoutsch/stuff/e_algorithms.html Alg ...
- 【2016-10-13】【坚持学习】【Day4】【virtual 虚函数】
定义一个基类,有一个虚函数 定义三个子类,分别继承,重写,New,这个虚函数 abstract class Test { public virtual void Prinf() { Console ...
- VMware虚拟机磁盘文件vmdk单文件转多文件相互转换
设置环境变量 set PATH=%PATH%;D:\Program Files (x86)\VMware\VMware Workstation echo %PATH% C:\Users\Admi ...
随机推荐
- [ATL/WTL]_[初级]_[选择目录对话框]
场景 1.起因是创建标准选择目录对话框时使用了 SHCreateItemFromParsingName 函数, 这个函数支持vista以上系统. 之后再winxp上运行就报错: 无法定位程序输入点 S ...
- 基于Vue的弹框实例
看到博客的人,请养成写博客的习惯,不会不会,就怕曾经会过,现在想不起来了,一起加油.................... 让学习真的成为一种习惯,同时要注意身体 <!DOCTYPE html ...
- java四舍五入
package com.clzhang.sample; import java.math.BigDecimal; import java.math.RoundingMode; import java. ...
- java.util.Arrays.asList 的小问题
JDK 1.4对java.util.Arrays.asList的定义,函数参数是Object[].所以,在1.4中asList()并不支持基本类型的数组作参数. JDK 1.5中,java.util. ...
- Object C学习笔记1-基本数据类型说明
Objective-C数据类型可以分为:基本数据类型.对象类型和id类型.基本数据类型有:int.float.double和char类型.对象类型就是类或协议所声明的指针类型,例如:NSAutorel ...
- 使用web api开发微信公众号,调用图灵机器人接口(一)
此文将分两篇讲解,主要分为以下几步 签名校验; 首次提交验证申请; 接收消息; 被动响应消息(返回XML); 映射图灵消息及微信消息; 其实图灵机器人搭载微信公众号很简单,只需要把图灵的地址配到公众后 ...
- Linux入门基础(二):Linux磁盘及文件管理系统
磁盘管理 fdisk分区工具 只支持MBR分区 fdisk命令只有root用户能用 fdisk -l 列出所有安装磁盘及分区信息 fdisk /dev/sda (操作磁盘,按m可列出帮助界面,常用的操 ...
- dubbo 多人开发时(即开发环境),版本号不要一致
导致问题:如果版本号相同,会调到别人的服务 不需要修改配置文件.直接改idea配置即可. Configurations ====> 添加parameters ===> dubbo.cons ...
- 用adb来修改android嵌入式设备的system只读目录下的东西
转的一篇: 以修改hosts文件为例: 由于某些原因,可能需要指定域名对应的IP地址.Android是基于Linux的系统,与Linux类似,通过hosts文件来设置. 在Android下,/etc是 ...
- Linux命令的那些事(一)
回顾一下前文,三大主流操作系统 windows做的最好(更准确最早做图形化界面是windows)其实是图形化界面占有90%的市场份额(PC(个人电脑)机的市场)但是现在发展图形界面做的较好其实Unix ...