VMware Cloud Community
gkman
Enthusiast
Enthusiast
Jump to solution

How to cause a corruption on vmdk? (for testing)

Hi,

I am testing this new system (freeNAS if anyone is interested)

and I want to test how it handles failed and/or corrupted disks.

can anyone please instruct me on how I can simulate (or actually corrupt- it is a testing environment so no worries) such a thing?

thanks in advance

1 Solution

Accepted Solutions
continuum
Immortal
Immortal
Jump to solution

That first example is quite boring. This VMDK will not boot - and if it just contains data it will not show any partitions.
The next example assumes a NTFS - one partition data disk. Here the damage is more interesting and less predictable.

### create a backup to be able to revert the corruption

dd if=name-flat.vmdk bs=1M count=10 of=first-MB-of-name-flat-vmdk.bin skip=4

### overwrite first mb with zeroes

dd if=/dev/zero bs=1M count=10 seek=4  of=name-flat.vmdk conv=notrunc

### revert changes

dd if=first-MB-of-name-flat-vmdk.bin of=name-flat.vmdk bs=1M seek=4 count=10 conv=notrunc
In this case the filetable is ok, the NTFS-bootsector is still ok but probably the MFT is corrupt so in real life this VMDK would probably need a massive chkdsk repair.
I hope the examples show how inject zeroes into a flat.vmdk.
For more real life corruption use this approach and inject zeroes to several locations and enjoy yourself.


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

View solution in original post

5 Replies
rajen450m
Hot Shot
Hot Shot
Jump to solution

Hi,

I don't think you can deliberately corrupt the vmdk, maybe possible to recreate logic volumes if it is a Linux vm.

In order to test the system, it is good to use iometer or HDDSCAN tools.

Regards,

Raj M Please mark helpful or correct if my answer resolved your issue. Visit www.hypervmwarecloud.com for my blog posts, step-by-step procedures etc.,
0 Kudos
gkman
Enthusiast
Enthusiast
Jump to solution

thanks for the reply,

I specifically want to corrupt the disk to test how the system handles failed disks (from alert and rebuild perspective)
IO measurements is less of an issue at this time

0 Kudos
continuum
Immortal
Immortal
Jump to solution

Here is a very easy AND revertable way to corrupt a VMDK in ESXi.
connect via putty to the esxi and change directory to VM directory
Assume you want to "corrupt" name.vmdk ....
### create a backup to be able to revert the corruption
dd if=name-flat.vmdk bs=1M count=1 of=first-MB-of-name-flat-vmdk.bin
### overwrite first mb with zeroes
dd if=/dev/zero bs=1M count=1 of=name-flat.vmdk conv=notrunc
### revert changes
dd if=first-MB-of-name-flat-vmdk.bin of=name-flat.vmdk bs=1M seek=0 count=1 conv=notrunc
To the VM this will look like the partitiontable has been lost


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

continuum
Immortal
Immortal
Jump to solution

That first example is quite boring. This VMDK will not boot - and if it just contains data it will not show any partitions.
The next example assumes a NTFS - one partition data disk. Here the damage is more interesting and less predictable.

### create a backup to be able to revert the corruption

dd if=name-flat.vmdk bs=1M count=10 of=first-MB-of-name-flat-vmdk.bin skip=4

### overwrite first mb with zeroes

dd if=/dev/zero bs=1M count=10 seek=4  of=name-flat.vmdk conv=notrunc

### revert changes

dd if=first-MB-of-name-flat-vmdk.bin of=name-flat.vmdk bs=1M seek=4 count=10 conv=notrunc
In this case the filetable is ok, the NTFS-bootsector is still ok but probably the MFT is corrupt so in real life this VMDK would probably need a massive chkdsk repair.
I hope the examples show how inject zeroes into a flat.vmdk.
For more real life corruption use this approach and inject zeroes to several locations and enjoy yourself.


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

gkman
Enthusiast
Enthusiast
Jump to solution

thank you very much.

very helpful!

0 Kudos