esxi-storage

Sometimes it’s necessary to hot-add a new hard drive to a VM (temporary backup disk, etc…).  In this case we will be using Ubuntu 12.04 LTS as the VM client and VMWare ESXi vSphere 5.0.0.

First we need to install the scsi-tools package from the default repositories.   These commands must be executed as root/sudo.

$ apt-get install scsi-tools

Now we need to examine the current set of disks and partitions.  Do not clear the output of this as you will reference it soon to compare what is listed now and what will be listed after a hot-add.

$ cat /proc/partitions

It’s now time to add in our VMWare VMDK virtual hard drive.  Log in to your VMWare vSphere console and open settings on your VM.  Add in a new hard drive and go back into your Ubuntu system.

Run the rescan-scsi-bus.sh script and let’s get an up-to-date listing of disks and partitions.

$ /sbin/rescan-scsi-bus.sh

Re-output the list of disks and partitions and compare what is there now to what was listed in our first execution of the command.

$ cat /proc/partitions

We will assume the new device found is /dev/sdb and the partition found is 1.  Replace these with whatever was changed from the last time we looked at /proc/partitions.

$ fdisk /dev/sdb
$ mkfs -t ext3 /dev/sdb1

Now let’s get the partitions’ UUID:

$ partprobe
$ blkid /dev/sdb1

This should output something similar to /dev/sdb1: UUID=”b4ff9bb6-cedf-4ccd-a25f-74dc788ba3e1″ SEC_TYPE=”ext2″ TYPE=”ext3″.  Copy the UUID string and save it for the next set of commands.

We need to add our new disk partition to fstab.  If you’re uncomfortable using fstab refer to the documentation around it (man fstab) before modifying fstab.  We will also need to create a new mount point.

$ mkdir -p /mnt/vmdk1
$ vi /etc/fstab

Within fstab add an entry that looks like this:

# /mnt/vmdk1 (mynewdisk.vmdk)UUID=b4ff9bb6-cedf-4ccd-a25f-74dc788ba3e1 /mnt/vmdk1   ext3    nouser    0       0

Basically that entry tells fstab/mount to mount the disk partition with the UUID specified in /mnt/vmdk1 and the filesystem type is EXT3.  The nouser flag lets the system know that normal user accounts cannot access the mounted partition and only superusers can do this.

Mount the new disk and you should be golden.

$ mount /mnt/vmdk1

Pin It on Pinterest

Share This