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

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.