Cloning the ESXi boot volume

20150703 - VMwareSince ESXi was introduced it has been possible to install it to a USB key. Initially it was always a hack… I remember getting a 3.5 image and using dd in a very unsupported way to write an image. It was only when ESXi 4.0 came along were USB keys officially supported as a boot volume.

I remember thinking this would save us a lot of money.  We no longer needed two 146GB disks and an expensive RAID card to host the boot volume and service console, as we could use cheap and cheerful USB keys.

Unfortunately, cheap doesn’t always equate to cheerful, as not all USB keys are made equally.

Recently at the company I work we discovered a number of hosts where the USB keys that had been provisioned were substandard, and had a low mean time between failure (MTBF). This resulted in the familiar error of losing the device backing the boot filesystem. While ESXi will continue to run (the image is copied into memory during boot), it does mean the system is highly unlikely to boot next time.

We decided to replace the USB keys, meaning a full reinstallation of ESXi was necessary. We raised a Request for Change and scheduled a maintenance window with the client.  Unfortunately due to the critical nature of the hosts, the window wasn’t as large as we hoped. I had to find a way to reprovision ESXi on a number of hosts in the time allocated.

I decided that cloning was the solution.

I downloaded the GParted Live ISO to my workstation and connected to the first server’s remote management card (iDrac/IMM/iLO).  I disabled HA host monitoring on the cluster, evacuated the first host, placed it into maintenance mode and then shut it down. I then replaced the internal USB key with the new model, and inserted the old one into a random port on the front.  Finally I disconnected the fibre cables (this is really important – if you accidentally erase or resignature a SAN LUN you’re going to have a really bad day).

Fortunately the server still recognised the old key, despite ESXi previously reporting it as lost.

I then booted into the GParted Live image:20151120 - 1After choosing the default image, I received the console screen. Here I just selected the default again.20151120 - 2Next I was asked to choose my language:

20151120 - 3

I chose 02 and moved on. I then typed 0 to start X and run GParted:

When the GUI loaded, I ran GParted to see what disks were available. It saw two, one empty and one with partitions:

20151120 - 4

20151120 - 5

As you can see, /dev/sda is the new USB key.

From here I ran the Terminal application,  and then cloned the partition table using:

sudo sgdisk --replicate=/dev/sda /dev/sdb

The important thing to note here is the syntax, which should be:

sgdisk –replicate=/dev/target /dev/source

If you get that wrong, you will wipe your existing disk!

This created an empty partition table on the new USB key, but with no data on it:

20151120 - 6

Now all that was left was to copy the data.

Back in GParted I refreshed the devices. I then selected each partition in turn on the original USB key, right-clicked to copy it, and then pasted it into the same place on the new key.

Some of the partitions couldn’t be copied, but this didn’t prove to be an issue. In the above example, partitions /dev/sdb7, /dev/sdb9 and /dev/sdb3 were the ones.

Finally I clicked Apply to commit. I then powered off the host, removed the original USB key, reconnected the fibre and powered it back on.  ESXi started without issue, now on a completely new boot volume.

20151120 - 7

Using GParted like this is a great way to visualise the partition table of an ESXi boot volume. Check it out!

13 thoughts on “Cloning the ESXi boot volume

  1. Great article.
    Is there any reason you wouldn’t be able to use CloneZilla to perform the same task ?
    (Apart from the fact Gparted allows you to see definitely which disks are used/empty.)

    Like

  2. Thanks dude! Your guide is the only one that actually managed to work for me. My previous attempts with Acronis and Clonezilla both failed to boot once the cloning completed. By the way – it appears that the partitions that you wrote could not be copied appears to be VMware Diagnostic partitions (sdb7 and sdb9). On my ESXi 6.5 there was no third partition (the 670 MB partition).

    Like

  3. Dude!! You saved my life mate!!! I have to do this on Monday at our colocation/data center and after researching and trying this thing for over 7 hours, dd and clonzilla were both a fiasco. This worked like a charm!!!

    Thanks man, I was stressing out for days!!

    Liked by 1 person

  4. I had the same problem with my ESXi 6.0 boot disk. I used Clonezilla. The clone process ran but the clone disk didn’t boot. Attempts to boot the clone gave the error “boot device not found”.
    The root cause of the failure is Clonezilla did not create a working GPT partition on the clone. Examination of both disks with gparted showed that both disks had GPT partitions.

    Solution #1. Clone the disk with Clonezilla. Then run sudo sgdisk from gparted as described above. This clones the GTP partition. The clone will now boot.

    Solution #2. Buy an offline clone device like the WEme USB 3.0 to SATA Dual-Bay External Hard Drive Docking Station With Offline Clone/ Duplicator Function from Amazon.
    https://www.amazon.com/gp/product/B00PTUQE4M/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1
    For $35 it avoids a lot of grief.

    Research. There may be expert mode options in Clonezilla that will force a good GPT copy. I have not investigated this.

    Research: A detailed analysis of the GPT partition on the clone (prior to running sudo sgdisk) would be a good contribution to the Sum of Human Knowledge. I would suggest this to anyone looking for a Master’s Degree Project in Computer Science.

    Liked by 1 person

  5. You are the Man!
    Desperately needed to clone my esxi usb boot drive and tried all the solutions before finding yours. Xserve running v6.0U2 and created a vm running gparted live to clone the USB drive. Worked like a charm.
    Many thanks for posting this solution
    LJS

    Like

  6. Pingback: How to Clone VMware ESXi USB boot volume 6.5 – Yoder Network

  7. I too tried all others but they all failed. This tutorial did work. I also had one partition that could not be copied but like the author, it didn’t seem to matter.

    Like

  8. any good ideas on how to shrink the 3rd partition (the datastore vmfs) in the process?
    I installed ESXI on 500gb SSD and now would like to move to ESXI USB boot.

    Like

  9. image2usb that was ver 1.6 and work just fine. After over a day of trying.. and doing the gpart stuff just rip clean main main disk. But overall, a fresh install do the best, but image2usb is rock solid to copy over a new disk and then try an update or so…

    Like

  10. Works with a 6.7u3 installation! Only after an abrupt power outage that I realized how important it is to have a backup clone of your usb boot stick! My usb sustained damage, so the DD method and usb cloning software couldn’t successfully copy. The DD or cloning software method, when works – copies partition 7 and 9, this will require the same size target. This method works great if you need to go from a 32g or 16g stick down to an 8g stick; it doesn’t copy the diagnostic partitions — which you can’t copy anyway. Thank you sooooooo much for this howTO !!!

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.