Clone ESXi Installations on SD Cards or USB Flash Drives

If you have ESXi running on a flash media (USB flash drive or SD Card) you might want to create a ready-to-run backup of your host. This posts describes how you can create a backup of your ESXi hosts and create a media with an identical configuration where vicfg-backup is not a solution.

Clone a running ESXi Host with dd
You can copy the content of the SD card or USB flash drive to a datastore by using the dd command.

Identify the disk where ESXi is installed. USB devices are usually mpx.vmhba32:C0:T0:L0. Based on the partitions you can also tell that this is an ESXi (Parition ID 1 and 5-9).

[root@esx1:/] ls -l /dev/disks/
total 1332029424
-rw------- 1 root root 4026531840 Dec 17 19:53 mpx.vmhba32:C0:T0:L0
-rw------- 1 root root 4161536 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:1
-rw------- 1 root root 262127616 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:5
-rw------- 1 root root 262127616 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:6
-rw------- 1 root root 115326976 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:7
-rw------- 1 root root 299876352 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:8
-rw------- 1 root root 2684354560 Dec 17 19:53 mpx.vmhba32:C0:T0:L0:9
[...]

Write the entire disk to an image. I am using one of the datastores.

[root@esx1:/] dd if=/dev/disks/mpx.vmhba32:C0:T0:L0 of=/vmfs/volumes/ds1/images/esx1.img
7864320+0 records in
7864320+0 records out

If you have a large disk, you might want to compress the image. The size of an ESXi installation is about 700MB, all empty space will compress very nice.

[root@esx1:/] dd if=/dev/disks/mpx.vmhba32:C0:T0:L0 | gzip > /vmfs/volumes/ds1/images/esx1.img.gz

There is no noticeable creation time difference but the advantage of piping the command through gzip is a way smaller image.

[root@esx1:/] ls -lh /vmfs/volumes/ds1/images/
total 4625408
-rw-r--r--    1 root     root      676.8M Dec 17 18:01 esx.img.gz
-rw-r--r--    1 root     root        3.8G Dec 17 17:26 esx.img

Copy the image to a safe location.

Write the image to a SD Card or USB flash drive with dd (Linux Host)
If you want to use a Linux host to write the image back to a device you can simply use the dd command again. It is available on all Linux system.

Plug in your target media and identify the device (/dev/sdb in that case)

Write the image to /dev/sdb:

# dd if=esx1.img of=/dev/sdb

If you have previously used gzip to compress the image, use the following command:

# dd if=esx1.img.gz | gunzip | dd of=/dev/sdb

 

Write the image to a SD Card or USB flash drive with usbit (Windows Host)

  1. Download USB Image Tools
  2. Open USB Image Tool (Requires Administrator Privileges)
    usb-image-tool
  3. Select your Device and click Restore
    usb-image-tool-restore
  4. Locate and open the Image File
    esx1.img
  5. Wait until the process finishes. You do now have a 100% copy of your ESXi Host.
Leave a comment ?

26 Comments.

  1. Thanks for the info! Just setup our lab to boot ESXi from internal USB drives. Problem then was how to ensure it was backed up. This solves that problem.

    Question though: Is there a way to get the status while it's running? Typically on 'ix OS's one can use CTRL-T or kill -usr1 pid to get the status. Neither of these work on ESXi.

    • I usually just watch the size of the target file with "ls -lh". Does not work if you copy the file back to the SD card of course.

      • Pretty much what I resorted to fgrehl. I added it to a watch statement. Problem with that is it doesn't end when the copy stops so you have to watch for a minute to see it hasn't changed size. Oh well, better than nothing I guess.

  2. Hi, thanks for this guide! I can't get it work when i replaced the original 4gb sd-card with a new 16gb sd-card. I get the error: Not a VMware boot bank. Tried another tool, but then it boots an old version of VMWare. The host is upgrade from 5.1 to 5.5.

  3. Nice guide, I have tried it out using two identical USB sticks and it works great.
    Only when I "Clone" a micro SD card and restore (windows methode or with Rufus) the image on 8Gb USB or 32GB USB stick. The process goes wrong and the Hyperviser will pop a boot warning: "BANK5: invalid configuration. (return) BANK6: not a VMware boot bank (return) No hypervisor found.
    Someone got a idea what is going wrong? Maybe the problem is related to the different type of storage? (SD vs USB)

    • This problem is usually caused by a wrong partition table.
      Make sure to clear all partitions from the target SD card.

      Can you do a "partedUtil get [device]" from both sd cards and compare the result? Should be identical..

      • Hey fgrehl,

        The idea was to clone an micro-sd card to an USB device (because i haven't got a second micro sd card 8Gb)(I will order one to night, then I will test a sd to sd clone)

        If I look to the partition from the SD card en de USB (clone from SD) Partition table seems the same size.

        I tried another thing; I have put the micro SD card in a micro sd to usb adapter (passive) and put is in a USB slot. Then tried to boot the ESXi Server and it wouldn't boot. Same message as in my previous post.
        So i think it's related to the different type of storage device. Maybe de ESXi installation config is different for SD vs USB devices.

        • Hey fgrehl,
          I've got exactly the same problem as E reported. I tried to clone a 16GB sd card containing ESXi 5.5 U3 once on Linux using DD and two times once on Windows using USB Image Tool / Rufus and once with dd on ESXi command line.
          When trying to boot from the destination sd card I got: "BANK5: invalid configuration. (return) BANK6: not a VMware boot bank (return) No hypervisor found"
          Cleaning the partitions on target sd card with parted on linux or diskpart on Windows before writing doesn't help.

          Probably it is a problem of the partition table but so far I did not find a way to fix that. I cannot compare the output of "partedUtil get [device]" because the destination sd card does not boot the esxi.

          When comparing the size of the sectors with parted I can see that the start and end sectors of all 6 partitions on source and destination sd card are the same. Never the less the destination sd card has some more sectors although both are thought to contain 16GB. Source has got 30894079 and destination has got 31422463 sectors. But IMHO that should cause the problem.

          If anyone could post a reason / solution for that problem it would be great.

  4. Hey fgrehl,

    I can confirm the problems which E has, mine are the same. I tried to clone a 16GB sd card running ESXi 5.5. The first time I used dd on linux to create an image, the second time I used the USB Image Tool on Windows 7. But the destination sd card does not boot: "BANK5: invalid configuration. (return) BANK6: not a VMware boot bank (return) No hypervisor found."

    I think the problem is located to the partition table (as you already said) but I didn't find a solution so far. Looking at the physics of the two sd cards I can see, that both 16GB sd cards have a different number of sectors. The source has got 30894080 while the destination is slightly bigger with 31422464. fdisk shows that the (six) partitions start and end at the same sectors. Never the less after cloning fdisk complaints that the destination sd card has got a wrong GPT size (it is too small because it is set to the size of the source). Fixing the size doesn't help. Using diskpart in Windows to clear the GPT before writing doesn't help either.

    There are other threads which seems to have the same problems e.g. http://www.vladan.fr/tool-use-cloning-esxi-usb-stick/

    Unfortunately I cannot use partedUtil get [device] on the destination device as it doesn't boot...

    • I've never cloned usb-flash to sd cards or vice versa. Only same types. Device size shouldn't be a problem as long as the target is bigger (I've done that couple of times without issues).
      Let's see if i can reproduce this issue. I don't have a server with SD card to verify at the moment, i will try with an adapter.

      • I can confirm the issue. Cloned an ESXi from SD card to usb flash drive, does not work. I'll try to fix it.

        BANK5: invalid configuration
        BANK6: not a VMware boot bank
        No hypervisor found.

    • Okay, here is the problem. USB Image Tool screws up the partition numbering. Not sure why this happens now because it worked when I created this article.

      Original device:
      partedUtil get /dev/disks/mpx.vmhba32\:C0\:T0\:L0
      247 255 63 3970048
      1 64 8191 0 128
      5 8224 520191 0 0
      6 520224 1032191 0 0
      7 1032224 1257471 0 0
      8 1257504 1843199 0 0

      Cloned Device
      partedUtil get /dev/disks/mpx.vmhba36:C0:T0:L0
      1897 255 63 30489408
      1 64 8191 0 128
      2 8224 520191 0 0
      3 520224 1032191 0 0
      4 1032224 1257471 0 0
      5 1257504 1843199 0 0

      Cloning the device with DD does not have this problem. (Use a Live Linux CD)

  5. fgrehl thank you for the extra support,

    I have tried the DD option using a linux OS (ubuntu) and I have successfully cloned a 8GB Micro-SD card to an 8GB USB 2.0 stick. (also tested 32GB USB 3.0 stick)

    (My experience with de DD command is that it works faster if you don't use compressed (gz) images. Maybe this is because I'm running ubuntu in a VM)

    So if you need to clone USB --> USB, the image tool works. If you need to clone SD, use the DD option!

  6. Hi, I'm Alex, author of USB Image Tool. I got notice of this thread by a post on my websites forum, where somebody reported this issue.

    Intentionally USB Image Tool doesn't modify the GPT numbering. In fact it doesn't care for GPT or MBR and tries to backup/restore the whole device (in device mode).

    I want to figure out, what is going wrong in this procedure. Could you possibly try to recreate the issue with older versions of USB Image Tool? They are still available for download at http://www.alexpage.de/usb-image-tool/download/.

    This could help me to narrow down the problems origin. Restore routines haven't changed that much since 1.70, which was the current version December 2014.

    I guess I will have to create a sample SD card with GPT an above partition numbering. Any hints on how to do this effectivly without an ESX server at hand? GParted Live CD possibly?

    • Hi Alex and thanks for your support.
      I've tried to figure out which version I used for the post. I've found the copy in my local documentation, it was 1.70.

      I've cloned SD -> USB flash with Version 1.70 and it produced the same issue.
      I've also cloned an SD to another SD with version 1.70: Same Issue.

      Here are 2 screenshots from GParted from both, source and target:
      https://www.dropbox.com/s/qn06h8xsx6xbvh9/esxi-correct-partitions.png?dl=0
      https://www.dropbox.com/s/yutiu4afm0xzbzg/esxi-wrong-partitions.png?dl=0

      Not sure how you tool handles "Devices Mode", compared to "dd" in Linux. I would assume both are just copying the entire device blockwise, ignoring any type of partition types or partitions iself.
      But maybe the problem is related to Windows not recognising the partition numbering correctly? When I use diskpart in Windows to list partitions, the output is quite odd (Both, source and Target):

      https://www.dropbox.com/s/w9gqi4ze49qneiz/esxi-windows-partitions.png?dl=0

      Any ideas? Anything we can do to help you to narrow down the issue?

      • Maybe, if you have a Windows 7 available. Looks like you originally did the tutorial with Windows 7. I had some other issues with Win8/10 behaving differently. Maybe you switched to Win10 like me. Thanks for your offer to help.

        • I'm still on Windows7 on my desktop. But I also have an Windows10 Notebook. The "strange numbering" shown in diskpart happens on both, Win7 and Win10.

        • Hello Alex,
          I'm still at Win7 with my laptop and used the latest version (1.72) of your tool. During the troubleshooting process I have tried cloning with a compressed and uncompressed image. Both made with de dd command. Both give the same issue.

          To be clear, the USB to USB process works. The SD cloning to USB did not work. I have not tested SD to SD.

          I will tried the Win7 + Tool version V1.70, and report the results.

          • The cloning SD --> USB using Image Tool V1.7 (on windows 7) gives the same result. I'm not 100% sure if it is the same issue.

          • Hello Alex,

            I just tested to restore sd-card image from ESXi 5.5 (created with dd) with USB Tool version V1.65 on Win7 to a new sd-card and had the same issue with the wrong partition table.
            I guess (as fgrehl already said) that the problem is somewhat Windows specific as other tools have the same problem. I also tested
            'Rufus 2.8' https://rufus.akeo.ie/
            'Win32 Disk Imager 0.9.5' https://sourceforge.net/projects/win32diskimager/
            and had also that problem with the partitions.
            Using dd in a Linux VM (VirtualBox) within Windows 7 host works as expected and results in a correct partition table.

  7. John O'Shaughnessy

    Interesting. I've had the same issue with version 1.72 of USB Image Tool on Windows 10. My last time using Alex's tool was about 18 months ago (with whatever was current at the time) on Windows 7, and it worked fine. Like mentioned above, the partition numbering was incorrect on the restored USB key.

    I used dd from MacOS, and it copied correctly.

  8. Pete Robinson

    I too have exactly the same issue using version 1.72 of USB Image Tool on Windows 10 - the partitions on the destination card differed from those on the source card.

    I got around this by using GDisk (GPT FDisk) on a GParted live CD to manually renumber the partitions.

  9. seems to me that the difference in writing the image it is using LBA mode within vmware, while writing it back to usb from windows is falls back to CHS mode.
    Don't know how to overcome this but maybe Alex has a solution for this?

  10. I have the same problem what "fgrehl" describes. The partitions are not as on the original USB stick sdx1, sdx5, sdx6, sdx7, sdx8 and sdx9, but are simply numbered from sdx1 to sdx6. This also explains the VMware Start message with BANK5 and BANK6. A cloning with dd in a Suse VM does not work by the way. I have then solved it with a gparted-live-cd (debian), there I could also immediately check the partitions.

  11. I use dd if=/dev/sdb of=/dev/sdc
    this Clone usb stick on dev sdb to sdc.

  12. And clean all Partitions on the Destination Usb Stick befor use dd copy

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>