Ubuntu – How to allocate more disk space to the ubuntu partition

hard drivepartitioning

I have installed Ubuntu 16.04 LTS recently on my main Laptop.
It already had Windows 10 pre-installed. At first I allocated 70 gigs of memory for the Ubuntu installation. 50 gigs for the /root and 20 gigs for the /home partition.
I would like to know how to increase the disk space allocated to Ubuntu.

I ran sudo fdisk -l in terminal and following is the output.

Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram3: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram4: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram5: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram6: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram7: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram8: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram9: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram10: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram11: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram12: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram13: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram14: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram15: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F2FDAD9A-3796-4517-929E-76BE3B882F60`

Device          Start        End   Sectors   Size Type
/dev/sda1        2048     923647    921600   450M Windows recovery environment
/dev/sda2      923648    1128447    204800   100M EFI System
/dev/sda3     1128448    1161215     32768    16M Microsoft reserved
/dev/sda4     1161216  512002047 510840832 243.6G Microsoft basic data
/dev/sda5   512002048  874942463 362940416 173.1G Microsoft basic data
/dev/sda6  1024002048 1536002047 512000000 244.1G Microsoft basic data
/dev/sda7  1536002048 1953523711 417521664 199.1G Microsoft basic data
/dev/sda8   874942464  984940543 109998080  52.5G Linux filesystem
/dev/sda9   984940544 1024002047  39061504  18.6G Linux filesystem

Partition table entries are not in disk order.

I have attached a screenshot from Gparted. Please help me increase the disk space for root and home directory.

Gparted ScreenShot Image

Best Answer

Without having much of a chance to discuss the final desired target configuration with Shanu, I'll move forward making some assumptions.

What we'll do is to delete sda6 and resize sda9. We'll keep sda7 as an NTFS partition which can be used to transfer files between Windows and Ubuntu, or to act as a common file space. We'll also add a swap partition. If that's not acceptable, stop now.

In gparted:

  • boot to a Ubuntu Live DVD or USB
  • right-click on partition sda6 and choose delete
  • right-click on partition sda9 and choose resize
    • in the window that pops up, in the graphic representation of the partition, hover the mouse pointer over the right side of the partition, and it'll turn into an arrow. Drag the arrow as far to the right leaving 16G of unallocated space between sda9 and sda7. Click OK.
  • create a new partition in the space between sda9 and sda7. Create it as a swap file system.
  • click the APPLY icon
  • reboot to Ubuntu

In Ubuntu:

If you were mounting sda6 and sda7 in Ubuntu, and edited /etc/fstab, you'll need to edit out the mount for sda6. Since sda6 no longer exists, the first boot may take a while as it looks for sda6 and times out. Worst case scenario is that Ubuntu may not boot at all, and we'll have to go into root access to edit /etc/fstab. I'll add that process later if I need to.

In the terminal application:

  • type sudo blkid and note the UUID for the swap partition that we created earlier
  • type gksudo gedit /etc/fstab
  • edit out, or comment out, the mount for sda6
  • add a mount for swap, it should look something like this:
    • UUID=071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b none swap sw 0 0
    • change the UUID to the one noted earlier
  • save and quit gedit
  • type swapon -a to enable swap
  • type swapon and observe the first line of memory status, and the second line as swap status
  • type df -h and observe the available free space in /home

In Windows:

  • open the Power control panel
  • click on change what the power buttons do
  • click on change options that are unavailable
  • uncheck fast start
  • close the Power control panel
  • open an administrative command prompt window
  • type powercfg /h off (turns off hibernation)
  • type chkdsk /f c: (change c: to the correct drive letter, if required)
  • approve that chkdsk runs at next boot time
  • reboot Windows