Expanding the Size of Disk Volume on a Hyper-V / VMware Linux Guest.

http://oneit.hubpages.com/hub/Expanding-the-Disk-Volume-on-a-Hyper-V-Linux-Guest#

open up your Hyper-V manager and click on Edit Disk on the right hand side under Actions. On the Welcome screen just click next then click the Browse button and find your VHD file for your Linux Guest. Click next again and choose Expand from the 3 options and click next. Now you want to enter the new size that you would like to make the hard disk. Click next when you are done and confirm the summary details are correct and click finish.

cfdisk /dev/hda
or
cfdisk /dev/sda
Depending on your Linux Distribution.

You will then be presented with a screen similar to the image above.
You should see the space that you just added to the VHD file as Free Space at the end of your Disk. Now what we want to do is add a new
Logical Partition to the HDA/SDA disk. So use the cursor to highlight the Free Space at the bottom of the list and choose New from the bottom menu. Next choose Logical for the partition type and enter the size you would like to make it then press enter. This will create a new logical partition with the File System type of Linux, next we need to change this to a Linux LVM File System Type. So choose Type from the bottom menu, press enter to continue, then enter 8e as the Filesystem Type. Next we just need to write the new Partition Table out, so choose Write from the Menu and confirm.

 Reboot

 fdisk /dev/sda à choose p then q

pvcreate /dev/sda?

 Lvdisplay à display the VG

vgextend VGNAME /dev/sda? (? is whatever number you created using the CFDISK tool)

 Lvdisplay

  --- Logical volume ---

  LV Name                /dev/HG-UBUNTU1/root

  VG Name                HG-UBUNTU1

 

  --- Logical volume ---

  LV Name                /dev/HG-UBUNTU1/swap_1

  VG Name                HG-UBUNTU1


root@HG-WEB01:~# pvcreate /dev/sda6

  Physical volume "/dev/sda6" successfully created

root@HG-WEB01:~# vgextend HG-UBUNTU1 /dev/sda6

  Volume group "HG-UBUNTU1" successfully extended


Next we need to add the new partition space to the
Logical Volume:

lvresize -l +100%FREE /dev/HG-UBUNTU1/root

 (where /dev/HG-UBUNTU1/root is the LV Name of the volume you want to increase)

 

type the following command to perform the online resize:

resize2fs /dev/HG-UBUNTU1/root

(where /dev/HG-UBUNTU1/root is your LV Name from the previous section)

run DF -H command to view your new free space (see the image above)

 


Complete Guide] How to Increase space on Linux VMWare

  1. Shutdown the VM
  2. Right click the VM and select Edit Settings
  3. Select the hard disk you would like to extend
  4. On the right side, make the provisioned size as large as you need it
  5. Click OK
  6. Power on the VM
  7. Connect to the command line of the Linux VM via the console or putty session
  8. Log in as root
  9. The fdisk command provides disk partitioning functions and using it with the -l switch lists information about your disk partitions.  At the command prompt type fdisk -l
  10. The response should say something like Disk /dev/sda : xxGB. (See Figure A)
  11. At the command prompt type fdisk /dev/sda. (if dev/sda is what was returned after step 10 as shown in Figure A)
  12. Type p to print the partition table and press Enter (also shown in Figure A)
  13. Type n to add a new partition
  14. Type p again to make it a primary partition
  15. Type: 3 (partition number)
  16. Type: t (type)
  17. Type the default numbers you see on the line. in other words select default first available cylinder to the default last cylinder. In Figure A the default last is 2610 so you type 2611 in that case.
  18. Type 3 (partition Number)
  19. Type: 8e (set type to LVM)
  20. Type w to save these changes
  21. reboot
  22. Log back in as root
  23. At the command prompt type fdisk -l. You’ll notice another partition is present.  In Figure B it is listed as sdaX.
  24. Type: pvcreate /dev/sdaX (where X i the number you see on step 23. to initialize this new partition as a physical volume s
  25. Now you’ll add the physical volume to the existing volume group using the vgextend command. First type df -h to find the name of the volume group.  In Figure C, the name of the volume group is vg_root (for me it was: . Now type vgextend [volume group] /dev/sdaX. (ex: vgextend vg_root /dev/sda4). in my case it was something like: vgextend VolGroup00 /dev/sda3
  26. Type: lvextend -l +100%FREE /dev/VolGroup00/LogVol00 to Extend the logical volume
  27. Type: resize2fs -p /dev/mapper/VolGroup00-LogVol00 to expand the ext3 file system in the logical volume
  28. You can now run the df command to verify that you have more space–df -h

Extending a logical volume in a virtual machine running Red Hat or Cent OS

Resolution

To extend the logical volume:

Note: These steps only apply to EXT3 file systems.

 
Caution: VMware recommends to take a complete backup of the virtual machine prior to making these changes.
  1. Power off the virtual machine.
  2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
  3. Power on the virtual machine.
  4. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:
    # fdisk -l

  5. Create a new primary partition:
    1. Run the command:
      # fdisk /dev/sda (depending the results of the step 4)
    2. Press p to print the partition table to identify the number of partitions. By default, there are 2: sda1 and sda2.
    3. Press n to create a new primary partition.
    4. Press p for primary.
    5. Press 3 for the partition number, depending on the output of the partition table print.
    6. Press Enter two times.
    7. Press t to change the system's partition ID.
    8. Press 3 to select the newly creation partition.
    9. Type 8e to change the Hex Code of the partition for Linux LVM.
    10. Press w to write the changes to the partition table.
  6. Restart the virtual machine.
  7. Run this command to verify that the changes were saved to the partition table and that the new partition has an 8e type:
    # fdisk -l

  8. Run this command to convert the new partition to a physical volume:

    Note: The number for the sda can change depending on system setup. Use the sda number that was created in step 5.
    # pvcreate /dev/sda3

  9. Run this command to extend the physical volume:
    # vgextend VolGroup00 /dev/sda3

    Note: To determine which volume group to extend, use the command vgdisplay.

  10. Run this command to verify how many physical extents are available to the Volume Group:
    # vgdisplay VolGroup00 | grep "Free"

  11. Run the following command to extend the Logical Volume:
    # lvextend -L+#G /dev/VolGroup00/LogVol00

    Where # is the number of Free space in GB available as per the previous command. Use the full number output from Step 10 including any decimals.

    Note: To determine which logical volume to extend, use the command lvdisplay.

  12. Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:
    # ext2online /dev/VolGroup00/LogVol00

    Notes:

    • Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
    • By default, Red Hat and CentOS 7 use the XFS file system you can grow the file system by running the xfs_growfs command.
  13. Run the following command to verify that the / filesystem has the new space available:
    # df -h /

 

 

No Comments

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *