3

I'm running CentOS on my VMware server console, and I want to know how to make a second virtual hard disk on which I can expand the size of the primary logical volume

AND

and a third to hold two other file systems

# fdisk -l

Disk /dev/sda: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1566    12474472+  8e  Linux LVM
  • Once you've exported the space to the VM, you just use vgadd to add it to the volume group, then lvresize and lvcreate... I'd add an answer, but I'm not sure how you do the export part. – derobert Feb 27 '14 at 17:11
  • 1
    You don't need to add another virtual disk, simply expand/grow the virtual one you already have. There are multiple ways to do this. Here's one such method dealing with KVM and it's disks that I posted a while ago on serverfault: serverfault.com/questions/324281/…, also some of what you want is here: kb.vmware.com/selfservice/microsites/… – slm Feb 27 '14 at 17:13
  • I use vmware and I usually grow disks. clone it before hand. then just write a bigger number on the disk and find a tutorial to expand the filesystem. boot the vm with a knoppix cd and expand it – Rui F Ribeiro Feb 20 '16 at 8:01
1

Here is a walk-through from an ESXi 5.1 U2 client perspective. "MyESXi" is the ESXi host and "MyServer" is the VM instance. This is taken from some notes that written while doing it for myself. Obviously some of the details are specific to the implementation (device names, sizes, etc.)

The original VM had only /dev/sda, then I did something like this in the ESXi client:

MyESXi
  Configuration
    View
      Datastores
        Add Storage...

Add Storage
  Select Storage Type
    Disk/LUN
      (o) Disk/LUN
      [Next]

      Select Disk/LUN
        Name, Identifier, Path ID, LUN, Capacity, Expandable or VMFS label
          contains: [ ]
        Local DELL Disk (...) vmhba1:C2:T3:L0 0 Non-SSD 512.00 GB
        [Next]

      File System Version
        (o) VMFS-5
        [Next]

      Current Disk Layout
        The hard disk is blank.
        [Next]

      Properties
        Enter a datastore name
          datastoreN
        [Next]

      Formatting
        Capacity
          (o) Maximum available space
          [Next]

      Ready to Complete
        [Finish]

Local DELL Disk (...) Manage Paths
   Path Selection:
     Fixed (VMware)

   Storage Array Type:
     VMW_SATP_LOCAL

   vmhba1:C2:T3:L0
   [Close]

datastore4 Properties
   [Close]

MyESXi
   MyServer
     Summary
       Edit Settings

MyServer - Virtual Machine Properties

a. Hardware
   [Add...]

b. Add Hardware
   i.    Device Type
         Hard Disk
         [Next]

   ii.   Select a Disk
         Disk
           (o) Create a new virtual disk
         [Next]

   iii.  Create a Disk

         Capacity
           510 GB

         Disk Provisioning
           (o) Thick Provision Lazy Zeroed

         Location
           (o) Specify a datastore or datastore cluster:
                 datastoreN

         [Next]

   iv.   Advanced Options
         Virtual Device Node
           SCSI (0:1)

         Mode
           [ ] Independent

         [Next]

   v.    Ready to Complete
         [Finish]

c. [OK]

After doing the above, the VM can see /dev/sdb...

1
  • First run sudo lsblk

  • This will list out the disks attached to the system

  • Only is the second disk is available you will be able to format it, assign a FS and further use it.

Here is a small output:

root@snowden:/# lsblk    
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT    
sda      8:0    0   149G  0 disk     
├─sda2   8:2    0     1K  0 part     
├─sda5   8:5    0    14G  0 part [SWAP]    
├─sda1   8:1    0 130.4G  0 part /    
└─sda6   8:6    0   4.7G  0 part /boot
  • As you can see my harddisk is sda and it has 4 partition - sda1,2,5,6.
  • So if you navigate to /dev you will be able to see these partition.
  • For the second drive that you add you will see a new label as sdb or sdc from lsblk command.
  • Now to partition this you need to use fdisk command as below:
  • fdisk /dev/sdb
  • From there everything is interactive. Type m from keyboard to see more options.
  • Type n from keyboard to add a new partition.

Since its interactive mode everything is well documented on what the switch will perform.

Now, if you want to create virtual or logical volumes you will have to use the pv,lg,lv,pvcreate,vgcreate,lvcreate commands. Best way to know more about these command are to read the manual pages first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.