Sunday, November 13, 2022

 92274688=44G

92274688/2048=445056

44*1024*1024*1024 / 512

99i

Saturday, November 12, 2022

Reduce size

 Yes - you can cut a vmdk to a new desired size in place - without the need of a copy / migration.

Assuming that you already adjusted the descriptorsize to the new size we will use that value for the next calculations.
So lets take this example .... only showing the relevant line of the descriptorfile.
RW 4508876800 VMFS "name-flat.vmdk"
Enter this value into a calculator and check if the size in sectors is a multiple of 1MB.
4508876800 sectors / 2048 = 2201600 MB.
Using flat.vmdk - sizes that are not a multiple of 1MB is allowed but not ideal at all.
So rather adjust the new descriptor and pick a value that is a multiple of 1MB.
In this case the value of 2201600 is fine.
To use dd in "scissor-mode" you must inject at least one block of data at a given skip-value and MUST not use the "conv=notrunc" option.
The dd command needs the following parameters:
bs= blocksize (we will use 1Mb here which corresponds to bs=1M)
if= inputfile (we can use either /dev/zero or a specially created file I call "cut.bin" of exactly 1MB)
of= outputfile (here we assign the flat.vmdk we want to cut)

seek= this is the offset in the outputfile where we want to cut MINUS 1MB)
I used to inject empty blocks created from /dev/zero in the past but learned a safer approach during last years ....

So I nowadays use a "cut.bin" file that I create in one extra step for safety.
To create that file I extract the last MB of the future size.
Future size is 2201600 MB so I create the cut.bin with this command:
dd if=name-flat.vmdk of=cut.bin bs=1M count=1 skip=$((2201600 - 1))
So now we have everything we need.
The final command now is this one:
dd if=cut.bin of=name-flat.vmdk bs=1M count=1 seek=$((2201600 - 1)) conv=notrunc
Now this command re-injects our premade cut.bin of 1MB at exactly the same offset from where we extracted it in the first place.
This command will not yet cut the vmdk - instead it does actually nothing visible - it only reinjects and does not change the size of name-flat.vmdk
Last chance to doublecheck your value is NOW !!!! if you are sure run

dd if=cut.bin of=name-flat.vmdk bs=1M count=1 seek=$((2201600 - 1))

If you miscalculated your values or forget to set bs to 1MB you just probably destroyed your flat.vmdk.

If your values were ok - you just cut your flat.vmdk to the new desired size in place in just one second.

DISCLAIMER: this command is destructive - even I may not be able to help you if you messed this up.
DO NOT USE THIS IF YOU DO NOT UNDERSTAND THE INSTRUCTIONS !!!!

If you are unsure about the parameters post your vmdk descriptorfile and ls -lah from inside the VM-directory.
Ulli

ESXI doc

https://www.vionblog.com/migrate-virtualbox-vmware-esxi-6-5/

 Migrate VirtualBox to VMware ESXi 6.5

Using vmkfstools to clone the clone you will have 2 files Windows2008.vmdk (meta file that you can open and edit) and Windows2008-flat.vmdk (the actual data file)

To get the desired files use this commands:

cd /vmfs/volumes/volume01/yourmachine
vmkfstools -i Windows2008-tmp.vmdk  -d thin Windows2008.vmdk

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


you can also limit the number of old logs that are retained by editing the VM advanced setting "vmx.log.keepOld"

vmx.scoreboard.enabled = "FALSE"

See volvo.vmdk

To set this configuration utilize the vSphere interface as follows:


Select the VM then select Actions followed by Edit Settings.


Click on the VM Options tab then expand Advanced.


Click on EDIT CONFIGURATION.


Click on ADD CONFIGURATION PARAMS then input log.keepOld with a value of 10.


Click OK, then OK again.


To set the number of log files to be used to 10, run the following PowerCLI command:


# Add the setting to all VMs

Get-VM | New-AdvancedSetting -Name 'log.keepOld' -value '10'

Reclaiming disk space from thin provisioned VMDK files on ESXi (2136514) https://kb.vmware.com/s/article/2136514

Open an elevated command prompt.

Run this command

sdelete.exe -z drive_letter:

 Run this command:

vmkfstools -K disk_name.vmdk


------