How to extend the primary partition for Ubuntu Server running in VMWare Player

I ran out of space on a VM I use at home. It runs Ubuntu server and the existing space was 20G. I decided to increase it to 100G to ensure I have plenty of breathing room.

So I followed the instructions here : http://www.rootusers.com/use-gparted-to-increase-disk-size-of-a-linux-native-partition/

And everything went well until the final step. Attempting to grow the /dev/sda1/ partition size to 99G fails on the 3rd step: 'Check filesytem on /dev/sda1 for errors and (if possible) fix them.'

It looks like this step trys to run : e2fsck -f -y -v /dev/sda1

This throws an an error saying:

The superblock could not be read or does not describe a correct ext2 filesytem.

The partition in question is an ext3 partition but I'm not sure whether that matters.

The primary partition is still ok and Ubuntu still boots, so I think it's ok. Any ideas on what I need to do to make it bigger?

EDIT :

Output from fdisk -l when booted from gparted live disk.

Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16064 * 512 = 9225280 bytes

    Device Boot     Start       End      Blocks    Id  System
/dev/sda1    *          1      2481    19921920    83  Linux
/dev/sda2           12924     13054     1052275+    5 Extended
/dev/sda5           12925     13054     1044225    82 Linux swap / Solaris

EDIT 2 :

fdisk -l when booted in ubuntu server

Interestingly, the output is different when I run after booting the VM normally.

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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: 0x00044fd6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    39845887    19921920   83  Linux
/dev/sda2       207607995   209712509     1052257+   5  Extended
/dev/sda5       207624060   209712509     1044225   82  Linux swap / Solaris

EDIT 3: Output for mount | grep " / "

/dev/sda1 on / type ext4 (rw,errors=remount-ro)

Thanks for the fdisk and mount outputs.

  1. the difference between the two fdisk outputs is just in Units used, hence the numbers are different.
  2. The /dev/sda1 partition isn't yet resized, it's still ~20GB.

You will have to resize it first, best done when booted from the CD:

~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Command (m for help): p

Device Boot         Start         End      Blocks   Id  System
/dev/sda1            2048    39845887    19921920   83  Linux
/dev/sda2       207607995   209712509     1052257+   5  Extended
/dev/sda5       207611904   209712509     1050303   82  Linux swap / Solaris

If you don't see the output in these "long" number use the fdisk command u to change the units to sectors and then p to print it again.

Now delete /dev/sda1 and re-create with larger size. Deleting the partition only changes the partition table and doesn't remove any data, however I strongly recommend you take a snapshot of the VM first.

Command (m for help): d
Partition number (1,2,5, default 5): 1
Partition 1 is deleted

Now create a new one:

Command (m for help): n
Partition type:
   p   primary (0 primary, 1 extended, 3 free)
   l   logical (numbered from 5)
Select (default p): p
Partition number (1,3,4, default 1): 1
First sector (2048-209715199, default 2048):    <==== This MUST be the same as in the original partition table!
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-207607994, default 207607994):  <== Use the default, will be maximum it can do
Using default value 207607994
Partition 1 of type Linux and of size 99 GiB is set

Verify that it looks sane:

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   207607994   103802973+  83  Linux       <=== Note the new size
/dev/sda2       207607995   209712509     1052257+   5  Extended
/dev/sda5       207611904   209712509     1050303   82  Linux swap / Solaris

And write to the disk:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now check the filesystem for consistency and resize:

~# e2fsck -f /dev/sda1
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sda1: 11/1245184 files (0.0% non-contiguous), 122210/4980480 blocks

~# resize2fs /dev/sda1 
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/sda1 to 25950743 (4k) blocks.
The filesystem on /dev/sda1 is now 25950743 blocks long.

That should do the trick.