ThisCalculator

Everyday

How to Add Storage to a VMware Virtual Machine

Updated · Standard formula, shown below

How to Add Storage to a VMware Virtual Machine

This guide walks you through adding usable storage to a VMware virtual machine, covering disk creation, attachment, and formatting. You’ll learn how to expand a virtual disk, add a new one, and make the space visible to the guest operating system. You’ll need administrative access to both the VMware management interface (vSphere Client, VMware Workstation, or Fusion) and the guest OS.

What You’ll Need

  • VMware software: vSphere (ESXi/vCenter), Workstation, or Fusion
  • Administrative credentials for the host (or vCenter) and the guest OS
  • Knowledge of the guest OS (Windows or Linux) for partitioning/formatting
  • Enough free space on the datastore to accommodate the new or expanded disk

Step-by-Step

Add or Expand the Virtual Disk

  1. Power off the VM (or ensure it is supported for hot-add). In vSphere, right-click the VM and select Power → Shut Down Guest OS. For Workstation/Fusion, shut down the guest normally.
  2. Open VM settings:
    • vSphere: Right-click the VM → Edit Settings.
    • Workstation: Select the VM tab → Edit virtual machine settings.
    • Fusion: Go to Virtual Machine menu → Settings.
  3. To expand an existing disk: Find the hard disk (e.g., SCSI 0:0), change the size (GB) to a larger value, and click Save. The disk size increases but the partition inside still needs to be extended.
  4. To add a new disk: Click Add (or Add Hard Disk), choose Hard Disk, select the disk type (Thick or Thin), and set the size. Leave the SCSI controller default. Click Finish and then Save.

Make the Storage Usable in the Guest OS

  1. Power on the VM and log in to the operating system.
  2. For Windows (new disk):
    • Open Disk Management (right-click Start → Disk Management).
    • Right-click the new disk (shown as “Unallocated�) → Initialize Disk (choose GPT for modern systems, MBR for older compatibility).
    • Right-click the unallocated space → New Simple Volume and follow the wizard: assign a drive letter, choose file system (NTFS), and set a volume label.
  3. For Windows (expanded disk): In Disk Management, right-click the partition on the enlarged disk → Extend Volume. Follow the wizard to add the unallocated space to the existing partition.
  4. For Linux (new disk):
    • Identify the new disk with lsblk or fdisk -l (e.g., /dev/sdb).
    • Create a partition: sudo fdisk /dev/sdb → n for new, accept defaults, then w to write.
    • Format: sudo mkfs.ext4 /dev/sdb1 (or use xfs).
    • Mount: sudo mkdir /mnt/newdata and sudo mount /dev/sdb1 /mnt/newdata.
    • To persist, add an entry to /etc/fstab using the UUID (get it with blkid).
  5. For Linux (expanded disk): If the partition was expanded, use sudo growpart /dev/sda 1 (or parted) to resize the partition, then sudo resize2fs /dev/sda1 (or xfs_growfs for XFS) to extend the filesystem.

Common Mistakes

  • Not checking datastore space: Expanding a disk or creating a new one requires free space on the datastore. If insufficient, the operation fails or the VM becomes unavailable.
  • Ignoring the guest OS partition size: Enlarging the virtual disk alone does not make the space visible. You must extend the partition and filesystem inside the OS.
  • Using the wrong disk type: Thick disks allocate all space upfront; thin disks grow as used. Choose based on performance vs. storage efficiency.
  • Forgetting to initialize a new disk in Windows: A new disk appears as “Unknown� until initialized, and you can’t create a volume without it.
  • Mounting Linux disks without fstab: The mount disappears after a reboot unless you add it to /etc/fstab.
  • Extending the wrong partition: In Windows, ensure you extend the correct volume (e.g., C:) and not a recovery partition.

Tips

  • Use hot-add for production VMs: In vSphere, you can add a new disk without powering off if the guest OS and SCSI controller support hot-add (Windows Server 2008+ and most Linux distros). This minimizes downtime.
  • Snapshot before changes: Take a snapshot before modifying disks to allow easy rollback if something goes wrong.
  • Use thin provisioning for dev/test: It saves space, but be aware of overcommitment risks in production.
  • Align partitions: Modern OSes handle alignment automatically, but for older Linux systems, use parted with optimal alignment.
  • Monitor disk performance: Adding storage doesn’t improve I/O if the underlying datastore is slow. Consider separate datastores for high-I/O VMs.

Troubleshooting

  • Disk not showing in guest: If the new disk isn’t visible, check the SCSI controller type (LSI Logic vs. PVSCSI) and ensure the guest has the correct drivers. In vSphere, you may need to change the controller type or install VMware Tools.
  • “Extend Volume� is greyed out in Windows: This happens when the unallocated space is not immediately after the volume. You can’t extend across another partition; you may need third-party tools or to add a new disk instead.
  • Linux shows the disk but not the partition: After expanding the virtual disk, the partition table still shows the old size. Run partprobe or reboot to rescan.
  • Datastore full after expansion: If the expansion fails midway, the VM may be left in an inconsistent state. Check the datastore and free space before retrying.
  • VM fails to boot after disk changes: This is rare but can happen if the boot disk was corrupted. Restore from snapshot or backup.
  • Performance is poor after adding disk: Ensure the disk is on a fast datastore and not thin-provisioned with high watermark. Check storage I/O metrics.

Frequently Asked Questions

Can I add storage while the VM is running?

Yes, in vSphere you can hot-add a new disk to a running VM if the guest OS and controller support it. Expanding an existing disk also works, but the OS may need a rescan to see the new size.

What is the difference between thick and thin provisioning?

Thick provisioning allocates all disk space upfront, improving performance but using more storage. Thin provisioning allocates space as used, saving storage but potentially causing performance issues if overcommitted.

How do I extend the root filesystem on Linux without rebooting?

Use growpart and resize2fs (or xfs_growfs) on the root partition. These tools can resize the partition and filesystem online for most filesystems.

Why does my new disk show as “Unknown� in Windows Disk Management?

You need to initialize the disk first. Right-click on the disk and select “Initialize Disk�, then choose GPT or MBR.

Can I shrink a virtual disk?

Yes, but it’s more complex. You must shrink the filesystem inside the OS, then use tools like vmkfstools (ESXi) or the VMware management UI to reduce the virtual disk size. It’s not recommended for production due to data loss risk.

What is VMware Tools and why is it important for disks?

VMware Tools includes drivers and services that improve disk performance and enable features like hot-add. Always install the latest version after adding a disk if it wasn’t already installed.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.