Solution adapted from:
http://unix.stackexchange.com/questions/67095/how-can-i-expand-ext4-partition-size-on-debian
I have a single 500GB drive. My main partition is SDA3 and it only has 5GB drive space. I want to reduce SDA4 and Expand SDA3. I do not want to have to boot from a LiveCD. The following instructions were adapted from above link and hopefully simplified for you enjoyment.
fdisk -u /dev/sda
p
- to print out the partition table (take note of the number, start, end)
Device Start End Sectors Size Type
/dev/sda1 34 19531 19498 9.5M BIOS boot
/dev/sda2 19584 8006783 7987200 3.8G Linux swap
/dev/sda3 8006784 19530879 11524096 5.5G Linux filesystem
/dev/sda4 19530880 981467071 961936192 458.7G Linux filesystem
Delete it: d
Partition number (1-4, default 4): 4
Select the partition number 4
(I need to remove the bigger partition first else the partition I want to increase will overlap and the system will prevent it)
Partition 4 has been deleted.
Now to recreate partition 4 with new values (taking into account how big I want partition 3 to be)
Command (m for help): n
Partition number (4-128, default 4): 4
First sector (19532-981467102, default 19531776): 519530880
(Notice I just added a 5 in-front of sda4 Start sector )
Last sector, +sectors or +size{K,M,G,T,P} (519530880-981467102, default 981467102): 981467071
(Even though the system wants to default a higher number, I still use what was printed out for the sda4 End sector )
Created a new partition 4 of type 'Linux filesystem' and of size 220.3 GiB.
Now to delete partition 3 (the partition I want to expand)
Command (m for help): d
Partition number (1-4, default 4): 3
Partition 3 has been deleted.
Now we create a new 3rd partition:
Command (m for help): n
Partition number (3,5-128, default 3): 3
First sector (19532-981467102, default 8007680): 8006784
(Remember to make sure you use the same Start sector from original partition list* )
Last sector, +sectors or +size{K,M,G,T,P} (8006784-519530879, default 519530879): 519530879
(Notice I just added a 5 in-front of sda3 End sector, which matches up to the Start of sda4 )
Created a new partition 3 of type 'Linux filesystem' and of size 243.9 GiB.
The complete we write our changes to the partition table
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot
or after you run partprobe(8) or kpartx(8).
We cannot complete the process because our main partition is mounted.
So we reboot the server.
sudo reboot -f
Once the server is back up we can resize the filesystem so it spreads to the extent of the enlarged partition:
sudo resize2fs /dev/sda3
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 16
The filesystem on /dev/sda3 is now 63940512 (4k) blocks long.
Now we check to see our new partition table and verify changes were made
df -h
Filesystem Size Used Avail Use% Mounted on
udev 5.9G 0 5.9G 0% /dev
tmpfs 1.2G 8.7M 1.2G 1% /run
/dev/sda3 240G 4.6G 226G 2% /
tmpfs 5.9G 4.0K 5.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 5.9G 0 5.9G 0% /sys/fs/cgroup
tmpfs 1.2G 0 1.2G 0% /run/user/1000
As you can see my /dev/sda3 partition increases from 5GB to 226GB
Best of all - No Data Loss XD
I solved my own question. May Mod/Admin please mark as solved?