Home > Linux > Migrating ESX Thick disk to Thin disk (ESX 5.1 is always special)

Migrating ESX Thick disk to Thin disk (ESX 5.1 is always special)

So,  in previous article I cleanup Linux virtual machine , zeroed all empty space. Thick file is 42 GB, lets see how it big I can make it.

First of all, make sure you have enough free space on datastore. Migrating is 2 steps process.

  1. Convert .vmdk to temporary disk with 2gbsparse option. Lets see what I have
    /vmfs/volumes/4e66911a-a1a3ba60-b4c8-000e0ca032e4/RHEL6_master  ls -al
    drwxr-xr-x    1 root     root          1400 Mar 10 22:49 .
    drwxr-xr-t    1 root     root          2800 Mar 10 22:31 ..
    -rw-------    1 root     root     42949672960 Mar 10 22:49 RHEL6_master-flat.vmdk
    -rw-------    1 root     root          8684 Mar 10 22:49 RHEL6_master.nvram
    -rw-------    1 root     root           499 Mar 10 22:38 RHEL6_master.vmdk
    -rw-r--r--    1 root     root             0 Sep  6  2011 RHEL6_master.vmsd
    -rwxr-xr-x    1 root     root          3241 Mar 10 22:49 RHEL6_master.vmx
    -rw-r--r--    1 root     root          3432 Mar 10 22:29 RHEL6_master.vmxf
    -rw-r--r--    1 root     root        130408 Mar 10 21:46 vmware-1.log
    -rw-r--r--    1 root     root        123965 Mar 10 22:49 vmware.log

    so, filesystem is saying that disk is 42GB. You can convert disk with command from ESX.

    NOTE: as I mentioned, ESX 5.1 is always special 😉 you have to enable module to be able actually do it.

    esxcli system module load -m multiextent

    If you dont enable module, error will be very fast.

    Failed to clone disk: The system cannot find the file specified (25)

    Here is more info: http://www.virtuallyghetto.com/2012/09/2gbsparse-disk-format-no-longer-working.html

    so, needed command is vmkfstools (-i as convert, -d as destination format)

    vmkfstools -i RHEL6_master.vmdk -d 2gbsparse RHEL6_master-temp.vmdk

    This command will create temporary clone of your vmdk in 2GB sparse format, so after its done, your directory will contain bunch of files, like this:

    /vmfs/volumes/4e66911a-a1a3ba60-b4c8-000e0ca032e4/RHEL6_master # ls -al
    drwxr-xr-x    1 root     root          4480 Mar 10 23:03 .
    drwxr-xr-t    1 root     root          2800 Mar 10 22:31 ..
    -rw-------    1 root     root     42949672960 Mar 10 22:49 RHEL6_master-flat.vmdk
    -rw-------    1 root     root     1052770304 Mar 10 22:57 RHEL6_master-temp-s001.vmdk
    -rw-------    1 root     root     255393792 Mar 10 22:57 RHEL6_master-temp-s002.vmdk
    -rw-------    1 root     root     493748224 Mar 10 22:57 RHEL6_master-temp-s003.vmdk
    -rw-------    1 root     root     793247744 Mar 10 22:58 RHEL6_master-temp-s004.vmdk
    -rw-------    1 root     root     288423936 Mar 10 22:58 RHEL6_master-temp-s005.vmdk
    -rw-------    1 root     root     631177216 Mar 10 22:59 RHEL6_master-temp-s006.vmdk
    -rw-------    1 root     root      21626880 Mar 10 22:59 RHEL6_master-temp-s007.vmdk
    -rw-------    1 root     root     132513792 Mar 10 22:59 RHEL6_master-temp-s008.vmdk
    -rw-------    1 root     root     352583680 Mar 10 23:00 RHEL6_master-temp-s009.vmdk
    -rw-------    1 root     root     1202454528 Mar 10 23:00 RHEL6_master-temp-s010.vmdk
    -rw-------    1 root     root     1222508544 Mar 10 23:01 RHEL6_master-temp-s011.vmdk
    -rw-------    1 root     root     280363008 Mar 10 23:01 RHEL6_master-temp-s012.vmdk
    -rw-------    1 root     root     150929408 Mar 10 23:02 RHEL6_master-temp-s013.vmdk
    -rw-------    1 root     root     228327424 Mar 10 23:02 RHEL6_master-temp-s014.vmdk
    -rw-------    1 root     root     108593152 Mar 10 23:02 RHEL6_master-temp-s015.vmdk
    -rw-------    1 root     root     147521536 Mar 10 23:03 RHEL6_master-temp-s016.vmdk
    -rw-------    1 root     root     184221696 Mar 10 23:03 RHEL6_master-temp-s017.vmdk
    -rw-------    1 root     root       3997696 Mar 10 23:03 RHEL6_master-temp-s018.vmdk
    -rw-------    1 root     root      39518208 Mar 10 23:03 RHEL6_master-temp-s019.vmdk
    -rw-------    1 root     root      64421888 Mar 10 23:03 RHEL6_master-temp-s020.vmdk
    -rw-------    1 root     root         65536 Mar 10 22:56 RHEL6_master-temp-s021.vmdk
    -rw-------    1 root     root          1502 Mar 10 23:03 RHEL6_master-temp.vmdk
    -rw-------    1 root     root          8684 Mar 10 22:49 RHEL6_master.nvram
    -rw-------    1 root     root           499 Mar 10 22:38 RHEL6_master.vmdk
    -rw-r--r--    1 root     root             0 Sep  6  2011 RHEL6_master.vmsd
    -rwxr-xr-x    1 root     root          3241 Mar 10 22:49 RHEL6_master.vmx
    -rw-r--r--    1 root     root          3432 Mar 10 22:29 RHEL6_master.vmxf
    -rw-r--r--    1 root     root        130408 Mar 10 21:46 vmware-1.log
    -rw-r--r--    1 root     root        123965 Mar 10 22:49 vmware.log

    In this cloning of vmdk , all zeros in filesystem, (as in previous post) are removed and image is shrinked.

  2. Now, last step is to convert 2gbsparse temporary disk into Thin version of vmdk and we are almost done.
    vmkfstools -i  RHEL6_master-temp.vmdk -d thin RHEL6_master-thin.vmdk

    Notice -d paramter is changed, to set thin format of cloned disk. This operation should be faster 😉
    All -temp files can be safely deleted.

    /vmfs/volumes/4e66911a-a1a3ba60-b4c8-000e0ca032e4/RHEL6_master # ls -al
    drwxr-xr-x    1 root     root          1820 Mar 11 00:10 .
    drwxr-xr-t    1 root     root          2800 Mar 10 22:31 ..
    -rw-------    1 root     root     42949672960 Mar 10 22:49 RHEL6_master-flat.vmdk
    -rw-------    1 root     root     42949672960 Mar 11 00:10 RHEL6_master-thin-flat.vmdk
    -rw-------    1 root     root           553 Mar 10 23:40 RHEL6_master-thin.vmdk
    -rw-------    1 root     root          8684 Mar 11 00:10 RHEL6_master.nvram
    -rw-------    1 root     root           499 Mar 10 22:38 RHEL6_master.vmdk
    -rw-r--r--    1 root     root             0 Sep  6  2011 RHEL6_master.vmsd
    -rwxr-xr-x    1 root     root          3250 Mar 11 00:10 RHEL6_master.vmx
    -rw-r--r--    1 root     root          3432 Mar 10 23:32 RHEL6_master.vmxf
    -rw-r--r--    1 root     root        130408 Mar 10 21:46 vmware-1.log
    -rw-r--r--    1 root     root        123965 Mar 10 22:49 vmware-2.log
    -rw-r--r--    1 root     root        122649 Mar 11 00:10 vmware.log

    So, now I have RHEL6_master.vmdk which is Thick provisioned disk, and cloned RHEL6_master-thin.vmdk which is Thin provisioned disk. Size in ESX shell are same , because ESX is showing “full size” of vmdk. For seeing “real” size of disks aka data inside , there is another command.

    /vmfs/volumes/4e66911a-a1a3ba60-b4c8-000e0ca032e4/RHEL6_master # du -h *.vmdk
    40.0G   RHEL6_master-flat.vmdk
    8.7G    RHEL6_master-thin-flat.vmdk

    Thats it, now just login to vSphere client , replace virtual disk for your machine, with new one.

Now, you can after some time again shrink size, but as its Thin version of disk, you can do it by command

 vmkfstools --punchzero RHEL6_master-thin-flat.vmdk
Categories: Linux Tags: , , , ,
  1. Sergey
    December 10th, 2014 at 17:45 | #1

    Hi,
    I don’t get why we need to convert to 2gbsparse first?
    Why not convert to thin right away?

  2. admin
    January 21st, 2015 at 12:58 | #2

    it wont work, must be done in this order.

  1. No trackbacks yet.

%d bloggers like this: