I was recently building out a new ESXi box and bought a Seagate Barracuda 1.5Tb SATA 2 drive to use as the datastore as well as to backup some data from a laptop who’s hard drive was acting up. The hard drive was/is making all sorts of bad sounds, so I wanted to get the data backed up as quickly as possible. As soon as I got the drive home, I started backing up my data, rather than checking how vSphere handles disks with data already on them. When I was sure I had a clean backup, I moved to the ESXi 4.0 host to add the Barracuda, minus the 400 gig backup partition.
To my dismay, when I went to add the datastore through vSphere I was informed that the entire disk would be used and my backup partition would be overwritten. After a quick run through the vSphere interface to make sure I hadn’t missed an option somewhere to allow me to add only the unused space, I moved to the ESXi 4.0 maintenance console to try and create the datastore by hand.
Below are the steps I ended up using to create the vmfs3 partition without losing my backup partition:
- Log into the ESXi 4.0 maintenance console as root
- Open the new disk with fdisk
- Create a new primary partition that uses the remaining space on the disk.
- Set the partition type to VMFS (hex: fb)
- Use vmkfstools to create the VMFS3 file system (vmkfstools -C vmfs3 /dev/disks/[yourdevice]:[parition number])*
- Exit the ESXi 4.0 maintenance console
- Under the vSphere client, again as root, select the “Configuration” tab, then select “storage” and click “refresh” in the upper right-hand corner
Your new datastore has now been added while protecting your backup partition and it’s data. Through the “Configuration” tab you can also rename this datastore to something more friendly than the UUID ESXi assigns it by default.
* the device name and partition number under ESXi is dynamic, so you’ll need to replace this with whatever is valid for your system. Generally, the partition number is following the device name and a colon (:). The partition number should correspond the the partition number you created with fdisk, not your backup partition.