I was trying to shrink a vmdk (VMWare disk image) file to be as small as possible, and found two recommendations. The first is to cat /dev/zero into the fs then delete it, and run VMWare tools' shrink. This works okay. The second is to copy everything into a new vmdk. I went the second route. I did not use dd because I actaully want to use as few blocks as possible, instead of having a block-by-clok copy. Any unlinked files will still have blocks that aren't zeroed out. Secondly the centos image was mostly lvm, except for the boot partition, and my target was going to be 4gb instead of 8gb.

I did use dd for the first 40mb to get the boot blocks and partition copied. I then used parted to create an identical primary boot, and smaller primary lvm. Then I used pvcreate on that device sdb2, vgcreate, and lvcreate to create a root and swap. I used mkfs.ext3fs on the root partition and then rsync -av / /2root excluding /proc /sys /2root /dev. So far everything went fine.

My problem is that:

  1. The result is 2.7 GB while the source was 2.1 GB. This is weird to me.
  2. The second vgroup is called VolGroup01, while the original was called VolGroup00.

How can I rename the VolGroup01 to VolGroup00 and swap it out after all this?


To rename the vg you use vgrename. Normally you should avoid having duplicate volume group names, as it will break many of the tools, but you can always rename based on UID for the vg.

vgrename vg02 my_volume_group

The reason for the larger result is probably that you have hard-linked files that became duplicated when you did the rsync.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.