Creating a new virtual disk for an existing Linux virtual machine
search cancel

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:
  1. Log in as root on the Linux virtual machine.
  2. Run this command and make note of the sdx entries

    ls /dev/sd*
     
  3. Log in to the vCenter Server using the vSphere Client.
  4. In the vSphere Client inventory, right-click the virtual machine and select Edit Settings.
  5. Click the Hardware tab and click Add.
  6. Select Hard Disk and click Next.
  7. Complete the wizard.
  8. Reboot the Linux virtual machine.
  9. Log in using the root credentials.
  10. Running the command ls /dev/sd* will now return a new entry.
  11.  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 !                                                                                                                                                                                                                                     
  12. 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.
     
  13. Run the fdisk command to verify the existence of the newly created disk partition:

    fdisk -l
     
  14. Run this command to create a mount point for the new disk partition:

    mkdir /New_Directory_Name
     
  15. Run this command to display the current content of /etc/fstab:

    cat /etc/fstab
     
  16. 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.
     
  17. Restart the Linux virtual machine and the new disk partition is now available.