Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to extend the disk on a Ubuntu server running as a vmware esxi guest. I have extended the disk in the settings of the guest in esx. How do I go about extending the disk to allow more free space for the os/user data? I have been searching for the answer on this and have read many posts, but none seem to address my actual needs. I am pretty new to linux/ubuntu but am catching on, so please dont beat me up too badly here. Thanks.

share|improve this question

2 Answers 2

If you are willing to risk your live data, you can edit the partition table online with fdisk. However, as you have more than one partition, you need to first delete your second partition to get it out of the way. Once this is done, you can resize the original partition, reboot, resize the filesystem, reboot again, and then have more space. A quick example would look like this (everything must be done as root, use sudo -i to get a root terminal):

Step 0: BACK UP ALL YOUR DATA. This is very risky. If you don't know what you're doing you will probably destroy all your data. Continue at your own risk.

Step 1: unmount your second partition, which appears to be just swap

swapoff /dev/sda5

Step 2: Modify the partition table, deleting the swap and extended partition

fdisk /dev/sda
d
5
d
2
w

Step 3: Find which block your first partition starts on, this needs to be exact

fdisk -l /dev/sda

Output looks like:

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003301e

   Device Boot      Start         End      Blocks   Id  System
  /dev/sda1   *        2048    39845887    19921920   83  Linux

Step 4: Delete and recreate your primary partition

fdisk /dev/sda
d
1
n
p
1
2048
[however large you want the filesystem to be]
w

Step 5: Recreate your swap partition

fdisk /dev/sda
n
p
2
[default option, beginning of free space]
[default option, end of free space]
t
2
82
w

Step 6: Reboot. Your server might not come back online. You may have ruined everything. This is why you took that backup.

Step 7: Resize the filesystem. For ext2/3/4, use resize2fs.

resize2fs /dev/sda1

Step 8: Reboot again.

After the last reboot, you should have all the space you added. You will need to edit your fstab to update the UUID on the swap partition.

share|improve this answer

I don't know about vmware specifically, but the general technique probably is the same as when you get a new, bigger hard disk and transfer your old disk's image to it. What you need to do is "grow" the partition and the filesystem to fill up the new, larger physical (or in your case, virtual, but it's still the same from Ubuntu's point of view).

The bad news is that in order to resize the filesystem, it cannot be mounted; meaning it cannot resize "itself". The good news is that it's easy to do with a Ubuntu desktop ISO. Just set vmware up so that it boots from a recent Ubuntu desktop ISO image. When it prompts you, ask to "try Ubuntu". When it boots up, look for "gparted", which is a graphical partition manager. You can ask it to enlarge the partition to fit all available device space.

See here for a nice tutorial with lots of detail:

http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/

share|improve this answer
    
Thanks for the link. I had already tried that one. When I extend my disk, it shows up in gparted as /dev/sda2 with a file system of extended. Under that are file systems of unallocated and linux-swap. When I highlight /dev/sda and then click on resize/move, I am only shown the space on /dev/sda which is already 100% used. –  Scott Nov 27 '12 at 13:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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