This new method can be done and doesn't require any reboots.
sudo remount
echo "- +" | sudo sfdisk -N2 --force /dev/mmcblk0
sudo resize2fs /dev/mmcblk0p2
sudo partprobe
df -h
Thats it! Verify on screen that mmcblk0p2 has increased in size.
From the command line or a terminal window enter the following
sudo remount
sudo systemctl daemon-reload
sudo fdisk /dev/mmcblk0
Then type p to list the partition table
There should be two partitions. if you look in the last column labeled Type you should have...
- W95 FAT32
- Linux
This will be needed later. It will likely still be on the screen (just in case).
Type d to delete a partition.
Type 2 to select the Linux partition
Now you can resize the main partition.
Type n to create a new partition.
This new partition needs to be a primary partition so type p.
Next enter 2 when prompted for a partition number.
You will now be prompted for the first sector for the new partition.
Next you will be prompted for the last sector you can just hit enter to accept the default which will utilize the remaining disk space.
When asked to delete the existing ext4 signature, press n
Type w to save the changes you have made.
Next reboot the system with the following command:
sudo reboot
once the system has reboot and you are back at the commandline enter the following command:
sudo remount
sudo systemctl daemon-reload
sudo resize2fs /dev/mmcblk0p2
Note: this can take a long time (depending on the card size and speed) be patient and let it finish so you do not mess up the file system and have to start from scratch.
Once it is done reboot the system with the following command:
sudo reboot
You can now verify that the system is using the full capacity of the SD Card by entering the following command:
df -h