Originally I had a 50GB disk where the root / was mounted to a 6 GB partition on it. The partition was running out of room so I created a second partition with the rest of the free space (44 GB). Here's what it looked like originally
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvda 202:0 0 50G 0 disk └─xvda1 202:1 0 6G 0 part / $ df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 6.0G 6.0G 20K 100% / devtmpfs 30G 0 30G 0% /dev tmpfs 30G 0 30G 0% /dev/shm tmpfs 30G 121M 30G 1% /run tmpfs 30G 0 30G 0% /sys/fs/cgroup
Within the root file system I had a directory /opt which used 3.4 GB of space and is where I am doing much of my work so /opt will continue to grow. After backing up all of my files, I mounted the second partition onto /opt
mount /dev/xvda2 /opt
After doing this, the new /opt is 0 GB and the partition 1 is still 6 GB with no way for me to access the 3.4 GB that was originally in /opt.
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 6.0G 6.0G 20K 100% / devtmpfs 30G 6.1G 24G 21% /dev tmpfs 30G 0 30G 0% /dev/shm tmpfs 30G 129M 30G 1% /run tmpfs 30G 0 30G 0% /sys/fs/cgroup /dev/xvda2 44G 0 44G 0% /opt
I have recovered the files from my backup but how can I delete the 3.4 GB that is not being used in partition 1? For future reference, what is the correct way to mount a new partition to a directory that is currently inside of another partition?