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
- Shutdown the VM
- Right click the VM and select Edit Settings
- Select the hard disk you would like to extend
- On the right side, make the provisioned size as large as you need it
- Click OK
- Power on the VM
- Connect to the command line of the Linux VM via the console or putty session
- Log in as root
- 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
- The response should say something like Disk /dev/sda : xxGB. (See Figure A)
- At the command prompt type fdisk /dev/sda. (if dev/sda is what was returned after step 10 as shown in Figure A)
- Type p to print the partition table and press Enter (also shown in Figure A)
- Type n to add a new partition
- Type p again to make it a primary partition
- Type: 3 (partition number)
- Type: t (type)
- 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.
- Type 3 (partition Number)
- Type: 8e (set type to LVM)
- Type w to save these changes
- reboot
- Log back in as root
- At the command prompt type fdisk -l. You’ll notice another partition is present. In Figure B it is listed as sdaX.
- Type: pvcreate /dev/sdaX (where X i the number you see on step 23. to initialize this new partition as a physical volume s
- 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
- Type: lvextend -l +100%FREE /dev/VolGroup00/LogVol00 to Extend the logical volume
- Type: resize2fs -p /dev/mapper/VolGroup00-LogVol00 to expand the ext3 file system in the logical volume
- 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
Note: These steps only apply to EXT3 file systems.
-
Power off the virtual machine.
-
Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
-
Power on the virtual machine.
-
Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:
# fdisk -l -
Create a new primary partition:
- Run the command:
# fdisk /dev/sda (depending the results of the step 4) - Press p to print the partition table to identify the number of partitions. By default, there are 2: sda1 and sda2.
- Press n to create a new primary partition.
- Press p for primary.
- Press 3 for the partition number, depending on the output of the partition table print.
- Press Enter two times.
- Press t to change the system's partition ID.
- Press 3 to select the newly creation partition.
- Type 8e to change the Hex Code of the partition for Linux LVM.
- Press w to write the changes to the partition table.
- Run the command:
- Restart the virtual machine.
-
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 -
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 -
Run this command to extend the physical volume:
# vgextend VolGroup00 /dev/sda3Note: To determine which volume group to extend, use the command vgdisplay.
-
Run this command to verify how many physical extents are available to the Volume Group:
# vgdisplay VolGroup00 | grep "Free" -
Run the following command to extend the Logical Volume:
# lvextend -L+#G /dev/VolGroup00/LogVol00Where # 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.
-
Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:
# ext2online /dev/VolGroup00/LogVol00Notes:
- 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.
- Run the following command to verify that the / filesystem has the new space available:
# df -h /
No Comments