Creating a new virtual disk for an existing Linux virtual machine
book
Article ID: 316591
calendar_today
Updated On:
Products
VMware vSphere ESXi
Issue/Introduction
This article provides steps to create a new virtual disk for an existing Linux virtual machine.
Environment
VMware vSphere ESXi
Resolution
Note: This article assumes some degree of familiarity with Linux system administration skills
For a full description of the utilities mentioned in this article, see the Linux documentation.
Note: The preceding link was correct as of May 19, 2015. If you find the link is broken, please provide feedback and a VMware employee will update the link.
To create a new virtual disk for an existing Linux virtual machine:
Log in as root on the Linux virtual machine.
Run this command and make note of the sdx entries
ls /dev/sd*
Log in to the vCenter Server using the vSphere Client.
In the vSphere Client inventory, right-click the virtual machine and select Edit Settings.
Click the Hardware tab and click Add.
Select Hard Disk and click Next.
Complete the wizard.
Reboot the Linux virtual machine.
Log in using the root credentials.
Running the command ls /dev/sd* will now return a new entry.
Create one partition on new disk, example to sdx: fdisk /dev/sdx Command (m for help): p Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-22400, default 1): <RETURN> Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-22800, default 22800): 22400
Command (m for help): w The partition table has been altered !
Create an ext3 file system on the new disk partition created on step 11.
mkfs -t ext3 /dev/sdx1
Caution: Ensure the right device is selected as there is no undo.
Run the fdisk command to verify the existence of the newly created disk partition:
fdisk -l
Run this command to create a mount point for the new disk partition:
mkdir /New_Directory_Name
Run this command to display the current content of /etc/fstab:
cat /etc/fstab
Using a text editor, edit fstab and add this line to add the disk partition to /etc/fstab so that it is available across reboots:
/dev/sdx1 /New_Directory_Name ext3 defaults 1 3
Note: Use a Linux text editor such as vi.
Restart the Linux virtual machine and the new disk partition is now available.