[转帖学习]Howto Shrink a Thin Provisioned Virtual Disk (VMDK)

Howto Shrink a Thin Provisioned Virtual Disk (VMDK)

Posted by fgrehl on November 24, 2014Leave a comment (18)Go to comments

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.

  1. Download SDelete
  2. 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.

  1. Identify free space with df
  2. 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

  1. Power off the Virtual Machine, or disconnect the virtual Disk you want to shrink
  2. Connect to the ESXi Host with SSH
  3. Navigate to the Virtual Machine Folder
  4. Verify disk usage with du
  5. Run vmkfstools -K [disk]
  6. Verify disk usage with du
[email protected]:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
7.9G vma_1-flat.vmdk

[email protected]:/vmfs/volumes/ds1/vma $ vmkfstools -K vma_1.vmdk
vmfsDisk: 1, rdmDisk: 0, blockSize: 1048576
Hole Punching: 25% done.

[email protected]:/vmfs/volumes/ds1/vma $ du -h vma_1-flat.vmdk
1.9G vma_1-flat.vmdk

原文地址:https://www.cnblogs.com/jinanxiaolaohu/p/9685798.html

时间: 2024-10-11 13:34:08

[转帖学习]Howto Shrink a Thin Provisioned Virtual Disk (VMDK)的相关文章

Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创)

Java Interface 是常量存放的最佳地点吗?(转帖学习,非原创) 由于java interface中声明的字段在编译时会自动加上static final的修饰符,即声明为常量.因而interface通常是存放常量的最佳地点.然而在java的实际应用时却会产生一些问题. 问题的起因有两个,第一,是我们所使用的常量并不是一成不变的,而是相对于变量不能赋值改变.例如我们在一个工程初期定义常量∏=3.14,而由于计算精度的提高我们可能会重新定义∏=3.14159,此时整个项目对此常量的引用都应

[转帖] 学习 Linux 大页的内存知识

一.在解释什么情况下需要开启大页和为啥需要开启大页前先了解下Linux下页的相关的知识:以下的内容是基于32位的系统,4K的内存页大小做出的计算1)目录表,用来存放页表的位置,共包含1024个目录entry,每个目录entry指向一个页表位置,每个目录entry,4b大小,目录表共4b*1024=4K大小2)页表,用来存放物理地址页的起始地址,每个页表entry也是4b大小,每个页表共1024个页表entry,因此一个页表的大小也是4K,共1024个页表,因此页表的最大大小是1024*4K=4M

【2016-10-13】【坚持学习】【Day4】【virtual 虚函数】

定义一个基类,有一个虚函数 定义三个子类,分别继承,重写,New,这个虚函数 abstract class Test { public virtual void Prinf() { Console.WriteLine("这是虚方法"); } } class SubClassA : Test { public override void Prinf() { Console.WriteLine("这是override的新方法"); } } class SubClassB

使用vmware-vdiskmanager.exe将多个vmdk文件转化成一个vmdk文件

在某些应用场合中需要将多个vmdk文件转化成一个vmdk文件. DOS命令终端执行可执行文件E:\Program Files\VMware Workstation>vmware-vdiskmanager.exe,其中E:\Program Files\VMware Workstation为VM的安装路径 vmware-vdiskmanager.exe的常用参数如下所示 E:\Program Files\VMware Workstation>vmware-vdiskmanager.exe VMwa

如何将多个vmdk文件合并为一个或者将一个vmdk文件拆分为多个

Vmware Station 自带的命令行工具"vmware-vdiskmanager"可以通过改变"磁盘类型Disk type"这一选项,将多个vmdk文件合并为一个或者将单个文件分为多个2G以内的文件.其帮助文档可以通过在DOS命令窗口输入E:\Program Files\VMware Workstation>vmware-vdiskmanager.exe来获取. <span style="font-family: Arial, Helve

考试题目

Q1. An administrator wants to provide users restricted access. The users should only be able to perform the followingtasks:- Create and consolidate virtual machine snapshots- Add/Remove virtual disks- Snapshot ManagementWhich default role in vCenter

day5:vcp考试

Q81. An administrator needs to recover disk space on a previously-used thin provisioned virtual disk. The volumeswhere the administrator needs to recover the disk blocks are on VAAI-compliant storage arrays.Which two actions should the administrator

[转帖]Ubuntu 18.04 server安装图形界面及realvnc远程桌面连接

Ubuntu 18.04 server安装图形界面及realvnc远程桌面连接 https://blog.csdn.net/networken/article/details/88938304 转帖 学习一下. 版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/networken/article/details/88938304 ubuntu server安装图形界面 sudo passwd root su root apt-get update apt

小白该如何学习Linux操作系统(2)

献给初学者:小白该如何学习Linux操作系统(2) 三.用虚拟机软件学习linux 3.1 什么是虚拟机软件虚拟机软件能够在一台电脑上模仿出来若干台PC电脑,每台PC能够运转独自的操作系统而互不搅扰,能够完成一台电脑"一起"运转几个操作系统,还能够将这几个操作系统连成一个网络. 图1:安装了3台虚拟机的windows系统 比如图1中,是在一台电脑上安装了Windows 2000 Server,再在Win2000 server上安装虚拟机软件VMWare,利用VMWare模拟出来3台PC