Increase Disk Size
Increasing the Disk Size of Your Virtual Machine
CloudShare supports editing your virtual machine hardware and increasing the disk, RAM or number of CPUs. To access this functionality, bring up your environment and navigate to the ‘Edit hardware’ page:
Once you are in the edit hardware page, you can edit the available resources. Click on the Disk edit icon, then use the slider to reallocate more drive space. Use this cautiously and do this in small increments when you need the space as you can not shrink the volume once the changes are saved:
Then, click ‘Save changes’ and your environment will begin updating.
Remember: if you edit your disk size, you will have to partition your hard drive accordingly.
Extending Partition Size in Windows
Access the ‘Disk Management’ utility, either by searching for it in Windows search or running the following from 'Run' or CMD: diskmgmt.msc
Once in, Right-click on the main partition and select ‘Extend volume…’
Select the size you wish to allocate and click ‘Next’:
Finish the process and you will see the extra space assigned to your main partition.
Finally, take a snapshot to your CloudShare Environment ensure your new settings are saved.
Extending a Linux Disk
After increasing the disk size in CloudShare’s Edit Hardware page, you will also need to increase the disk size inside the operating system.
The following details how to extend a hardware drive in Linux.
Step 1: Get the partition table type.
- Retrieve the disks information:
sudo fdisk -l
- Search for Disklabel type under the disk that you want to increase.
- The disk name should be /dev/sda by default. You will either see ‘gpt’ or ‘dos’. For ‘gpt’ we will use the gdisk command, and for ‘dos’ we will use the fdisk command.
Step 2: Create a new disk partition for LVM.
For the ‘gpt’ partition table type, open the gdisk menu that allows you to change the disk partitions:
sudo gdisk /dev/sda
Follow this gdisk command sequence:
p (to view the current partition layout)
n (new partition)
Enter (to let it automatically choose the partition number. Take note of this number)
Enter (to let it automatically choose the first sector)
Enter (to let it automatically choose the last sector)
8E00 (the type code for the 'Linux LVM’)
p (to see the new partition. Verify that it has the correct size.)
w (to write the changes to the disk)
Y (to confirm)
For the ‘dos’ partition table type, open the fdisk menu that allows you to change the disk partitions:
sudo fdisk /dev/sda
Follow this fdisk command sequence:
p (to see the current partition layout)
n (new partition)
p (primary)
Enter (to let it automatically choose the partition number. Take note of this number)
Enter (to let it automatically choose the first sector)
Enter (to let it automatically choose the last sector)
p (to see the new partition. Verify that it has the correct size.)
t (to change the partition type)
Enter the partition number we just created.
8e (the code for the 'Linux LVM' type)
w (to write the changes to the disk).
Step 3: Increase the root partition with the new disk partition.
Inform the OS of the partition table changes:
sudo partprobe
Create the physical volume for the new partition we created. Replace X with the partition number you took note of previously:
sudo pvcreate /dev/sdaX
Take note of the Volume Group name:
sudo vgdisplay
Extend the Volume Group with the Physical Volume we created. Replace vg_name and X:
sudo vgextend <vg_name> /dev/sdaX
Take note of the Logical Volume path you want to extend (note that there is usually more than one):
sudo lvdisplay
Extend the Logical Volume with all of the free space that the Volume Group has (replace lv_path):
sudo lvextend <lv_path> -l +100%FREE
Get the file system type. (Look at the type column for the Logical Volume you extended):
df -T
For ext4:
Use the resize2fs command:
sudo resize2fs <lv_path>
For XFS:
Use the xfs_growfs command:
sudo xfs_growfs <lv_path>
Step 4: Verification
Run the df command to verify that the partition was extended successfully:
df -h
Tips:
1. Some commands support the Linux autocomplete feature. When you run them as the root user, you will be able to press the Tab key to autocomplete the parameters. For example, start typing 'vgextend' and then press the Tab key. This will autocomplete the VG name for you.
2. If you want to increase the Logical Volume by a certain size, and not by ‘100% free’ you can use the following syntax (Note the capital L):
sudo lvextend <lv_path> -L +10GB
Comments
7 comments
Trying to resize a partition in XP / 2003?
Switch to Console view
Reboot the system and watch closely for the VMWare splash screen when it reboots
The reboot screen is very brief, when you see the VMWare splash screen quickly press F8, then select Safe Mode with Networking
Once logged into Windows, install a great free tool: Dell's Extpart.
_After installing Extpart: _
From the Start Menu select Run.
Type 'cmd' and click OK to run the command line utility.
Change directories to c:\dell\ExtPart or the location the utility extpart.exe was extracted.
To extend the partition, your command in the CLI will look like the following: extpart [volume:] [size]
extpart is the command
[volume:] is the volume to extend. For example c:, f:, g:, etc (only basic volumes)
[size] is the size in megabytes by which to extend the volume.
Example: To extend the C: volume by 1 GB (1024 MB) use the following command:
*extpart g: 1024 *
What about resizing in Linux?
There are different options available for resizing a HDD in Linux. There is an excellent guide located here.
Consider the first step, 'How to expand disk capacity for vmware linux virtual machine' already completed when you add disk space from the CloudShare UI.
Alternatively, you can use Parted or a similar application.
Here are some instructions for modifying Linux partitions. First you must use the edit hardware option in the CloudShare Dashboard to increase the hard drive size as above.
Next you need to change the size available to the OS. The exact steps will vary depending on your system configuration (with or without LVM):
With LVM
1. Use fdisk to create new partition(s), make sure to mark them as LVM parititions (8e)
2. Format the partition(s) using mkfs
3. Run the LVM commands:
pvcreate /dev/<drive>
vgextend VolGroup00 /dev/<partition>
lvextend -L<size>G /dev/<path to logical volume>
** EXAMPLE **
Format the disk:
fdisk /dev/sdb
use n to create a new parition
use t (select 8e for LVM)
use w to write your new partition table
Now create a file system on this parition:
mkfs.ext3 /dev/sdb1
Use LVM to add this space:
pvcreate /dev/sdb1 (create physical volume)
vgextend VolGroup00 /dev/sdb1 (extend your volume group onto the new drive)
lvextend -L10G /dev/VolGroup00/LogVol01 (extend your logical volume by 10GB)
Without LVM
1. Create parition(s) using the fdisk command
2. Format the new parition(s) using mkfs.ext3 (or other filesystem type if required)
3. Mount the new filesystem
4. Save the mount settings to /etc/fstab
** EXAMPLE **
Format the disk:
fdisk /dev/sdb
use n to create a new parition
(the type should be linux ext3)
use w to write your new partition table
Now create a file system on this partition:
mkfs.ext3 /dev/sdb1
Now mount this filesystem:
mkdir /opt/new_space
mount /dev/sdb1 /opt/new_space
Finally edit /etc/fstab to automatically mount this when the system boots
vi /etc/fstab
add a line like:
/dev/sdb1 /opt/new_space ext3 defaults 1 1
Interested in learning more on LVM?
Hello Scott. What about the Windows Server 2012? Thanks.
-Constantin
Ah, the same command: discmgmt.msc. Sorry for disturbing.
Would you add a link on this page, perhaps under "Related Topics", to a page that describes how to ADD an additional disk to an environment, not just increase an EXISTING one? For example, how do I add an additional Windows disk, say as the D:\ drive, to an existing Windows Server?
@ Fred, here you go!
Nice article!
May I suggest to look at /etc/fstab to see the filesystems<->logical volume mapping and avoid messing with your VM ?
And don't forget to expand the filesystem as well, not only the logical volume.
You can add -r parameter at lvextend command : lvextend -r -L<size>G /dev/<path to logical volume>
If you already followed Peter's instructions but 'df -h' is not yet showing your filesystem expanded, you can run fsadm :
fsadm -l resize /dev/<path to logical volume>
Please sign in to leave a comment.