In this post we have a look at how to resize root disk partion on Ubuntu.
So I had to resize the root disk partition on one of my Ubuntu VM’s.
First I have expanded the .vmdk file as described in my previous post.
Now I had some un allocated Space available.
I thought I would find countless examples of how to do this via command line, but really there was not a lot that seemed to apply, since it was the root drive i needed to expand.
However one guy on askubuntu.com had the following answer which I did not test myself Possible way to expand Ubuntu root drive from command line
However what i did was to use a Tool called GParted.
(Always remember to backup your systems before perfoming operations like this)
- Download GParted live CD
- In my case i was running VMware so I mounted the ISO and booted on it
- Choose default settings (or customize if you need special language or other)
- In my case I ran with the GUI version
- Now take your swap partition and move it to the end of the drive
- Next expand your root drive.
- apply changes and Voila you are done, and your Ubuntu now has more Space available on root drive.
Of course your situation may vary from mine and the steps above needs to be changed in order to fit your environment.
Let us have a look at how to increase size of VMWare virtual disk.
Apparently there are several ways of increasing the disk size on a VMWare VMDK file, so below I will describe the way I have successfully done this in my virtual environment (vSphere 5.1).
(Note: This kind of operation can be harmful to your virtual machines and this information is provided without ANY warranty or responsibility for what happens when you do it! Make sure you have a proper backup before you engage in these activities)
First of all you need to have access to VMware ESXI Shell as described in my previous post.
After this we can start the work to expand our VMDK file.
Step 1 is to locate the VMDK file
- Log in to the VMware ESX/ESXi host as the root user.
- Run vim-cmd vmsvc/getallvms to list the location of the configuration files for the virtual machines registered on an ESXi host.
- Record the location of the .vmx file (configuration file) for the virtual machine that you are looking for. For example:/vmfs/volumes/46b2f3eb-ced4c7d8-c1d2-111122223333/vm1/vm1.vmx
- The results of step 4 list all virtual machine configuration files. Search the results for the name of a virtual machine file you are interested in locating. The results also list the path to the directory where these files are located.
- By viewing* the configuration file of a virtual machine, you can tell where all of its associated files, including .vmdk files, are located. If a file is not in the same directory as the configuration file the complete path is shown in the configuration file. For example, a second hard disk may have an entry such as the one shown below:scsi0:1.present = “true”
scsi0:1.fileName = “/vmfs/volumes/46b2f3ea-980a1c90-3333-00112233bb44/diskStore/secondHardDisk.vmdk”
- *Tip: Use the VI editor to view the content of the VMX file
This information is based on this article from vmware : http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1003751
Step 2 will be actually expanding the file.
Virtual disks can be expanded using this ESXi/ESX command line command vmkfstools -X:
vmkfstools -X <new size> <virtual disk>.vmdk
Here is an example, use this command to grow the virtual disk to 25GB in size:
vmkfstools -X 25g /vmfs/volumes/xxxx/vmname/vmname.vmdk
Changes are made to the disk and are almost instant.
Partitions residing within the virtual disks will not resize and there will be unallocated space at the end of the disk.Third-party partitioning tools are required at this point to resize the primary partition to take advantage of the additional space.
VMware Converter allows you to specify a new disk size in its conversion wizard. It will also take care of partition resizing for you.
You can read more details on this if you need it here http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002019