VMware Cloud Community
vipclubber
Enthusiast
Enthusiast
Jump to solution

Decrease Drive Size

Can you please assist with step by step instructions to decrease vmfs VM HD drive using shell.

Thank you

1 Solution

Accepted Solutions
depping
Leadership
Leadership
Jump to solution

just to be clear: It is NOT supported to decrease the size of your disk! You can only do this by using VMware Converter. Which basically means you are creating a new VM and copying block by block in to a new disk.

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

8 Replies
a_p_
Leadership
Leadership
Jump to solution

Are you specifically asking for cutting off the .vmdk file from the ESXi shell?

From a technical point of view (reduce the guest OS partitions to have all free disk space at the end of the disk, change the .vmdk header file, use e.g. dd to cut off unused space, ..), this may work, but the supported way to reduce a virtual disk's size is to use e.g. VMware's free Converter.

André

Reply
0 Kudos
vipclubber
Enthusiast
Enthusiast
Jump to solution

I am asking for the reverse of what x tools does when used to increase size using the shell

Reply
0 Kudos
a_p_
Leadership
Leadership
Jump to solution

With "x tool" I assume you mean "vmkfstools -X <newsize>"!?

Anyway, no matter which tool you are using to increase a virtual disk size, reducing unfortunately requires more work than just a command, as mentioned in my previous post.


André

vipclubber
Enthusiast
Enthusiast
Jump to solution

Right. Is there article with steps you can recommend or point me to?

Thanks in advance.

Reply
0 Kudos
sjesse
Leadership
Leadership
Jump to solution

This is easily search able, vcenter converter is the only option like was mentioned, so just look up how to shrink disk with vcenter converter.

Reply
0 Kudos
NathanosBlightc
Commander
Commander
Jump to solution

To find-out how to use vmkfstools for changing VMDK size:

Growing, thinning, and shrinking virtual disks for VMware ESX and ESXi (1002019)

Please mark my comment as the Correct Answer if this solution resolved your problem
Reply
0 Kudos
depping
Leadership
Leadership
Jump to solution

just to be clear: It is NOT supported to decrease the size of your disk! You can only do this by using VMware Converter. Which basically means you are creating a new VM and copying block by block in to a new disk.

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

continuum
Immortal
Immortal
Jump to solution

Your question has not been answered at all.

You also did not receive any good hints that would help to find the real answer.
Let me do that now ....

First of all - there exists a way to reduce the size of a vmdk

( that is in case we talk about regular normal vmdks stored on VMFS - no vSAN or other fancy variants)

Second: Duncans answer  is very good. It is safe and lame - but if you want to prevent that your customers destroy VMs that have done nothing wrong then it is the only one possible.

If my job was to decide wether something makes it into the offical documentation - I would probably also not even mention this.

Similar case: I do not expect that the manual for a hunting rifle features a section on how to use this rifle for suicide.

Doing so would really be contraproductive if you want to establish a longterm healthy relationship with your customers.

Problem: adding zeros after the partitioned area is a harmless action.If something goes wrong you end with a vmdk thats is larger than necessary but the risk to do any harm is really really low.

To do the opposite you pick a pair of scissors - that is not failsafe at all - if you cut at the wrong location you DESTROY YOUR DATA in a second.

... never needed a such large disclaimer before ....

So if you really want to cut your flat.vmdk - use dd like I do it.

Get your numbers straight: - one error - and the DATA is TOAST

You have to know this answers :

MBR or GPT ?

Does the partitiontable describe <OLD-SIZE-IN-MB>  or was it already expanded for <NEW-SIZE-MB>?

Do you have the OLD-SIZE-IN-SECTORS ?

Then create your pair-of-scissors by extracting the last MB of the old size and save it as scissors.bin

Inspect your scissor.bin with hexedit - really ? - sure you got the right one ??

If you think you got all the questions answered - triple checked your numbers and still believe that this is your only option.

Then reinject scissors.bin at the very same spot you extracted it from and do NOT use conv=notrunc

So to sum it up:

vmkfstools -X

expands a vmdk

dd if=scissor.bin of=name-flat.vmdk bs=1M seek=X count=1

cuts a vmdk.

Thats it.
If you can not address all the problems that come up in this last red paragraph by using skills you practise already yourself then run away NOW.

If you cant fix the vmdk-descriptorfile without needing google first then do not try this - run away now.

If you do not know how to read / edit the partitiontable of a flat.vmdk with Linux-commandline tools ... are you really sure you need to do this ???...

Recommended to study first: read my article on how-to-use-dd-to-work-with-vmdks-stored-on-vmfs on vm-sickbay.

If you ask for support - dont call after you messed up !
But feel free to call via me skype so that I can check your numbers before you mess up.

Last warning: never enter dd seek values that you copied from some instructions in the net.

Ulli


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos