Skip to content

Shell script that automates reducing / resizing thin VMDK disks with XFS filesystem.

License

Notifications You must be signed in to change notification settings

igor-podpalchenko/vmware-vm-deflate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vmware-vm-deflate

Shell script that automates reducing unused free space (deflates) / resizing thin / thick VMDK disks with XFS filesystem.

Result of unused free space deflation

Script uses buffer disk (Attach VmWare disk with ext/xfs for XFS file dumps storage)

Disk structure (default layout for CentOS):

- VmWare VMDK file (disk configuration file)
	- VmWare VMDK flat disk file (binary data)
		- Disk Partition Table
			- Primary 1 boot partition - UEFI BootLoader 
			- Primary 2 LVM member -  LVM
				- VOLUME GROUP (VG) CENTOS (name is configured in script)
					- LOGICAL VOLUME (LV) SWAP
					- LOCICAL VOLUME (LV) ROOT (name is configured in script)
						- XFS VOLUME / - root filesystem

Script has following algorithm:

  1. ) Mount BUFFER and GUEST filesystems
  2. ) Create full filesystem dump using xfsdump for GUEST and store it on BUFFER (/mnt/buffer mounted disk)
  3. ) Repartition GUEST disk - delete existing LVM part.
  4. ) Script asks for new LVM partition parameters
  5. ) Restore XFS dump into new partition
  6. ) Calculate cut off extent for VMDK file https://virtualman.wordpress.com/2016/02/24/shrink-a-vmware-virtual-machine-disk-vmdk/
  7. ) Manually edit VMDK descriptor file
  8. ) Run "vmkfstools -i input.vmdk -d thin output.vmdk"
  9. ) Attach output.vmdk back to VM

Usage:

Attach new VM and install: Linux debian 3.16

Shutdown target VM and attach its VMDK to fixer VM (/dev/sdc).

Attach second buffer virtual disk (/dev/sdb) Attach

Install packages:

	sudo apt-get install parted xfsdump xfsprogs lvm2

Run:

	sudo ./vm-deflate.sh

EDIT script configuration BEFORE run. BACKUP your data before resizing. NO responsibility for data loss.

Uncomment those two lines

 set -x
 trap read debug

if you want step by step disk editing commands tracing.

About

Shell script that automates reducing / resizing thin VMDK disks with XFS filesystem.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages