Move /opt to a different, already existing drive
Solution 1:
You can simply link to it:
-
Move the
/opt
directory:sudo mv /opt /mnt/otherDisk/
-
Create a symlink to the new location:
sudo ln -s /mnt/OtherDisk/opt /
You will now have:
$ ls -ld /opt
lrwxrwxrwx 1 root root 5 Apr 6 14:23 /opt -> /mnt/OtherDisk/opt
As Rinzwind correctly pointed out in the comments, this can break your system if you move a directory containing files needed during boot. For example, you certainly don't want to do this for /bin
. /opt
should be fine though.
Solution 2:
I second moving /home, but it's possible to do what you want.
If I understand correctly, you have two drives, one with ubuntu (and possibly some windows stuff) and one with the windows user files. What you would need to do is shrink the windows partition (while I have done this successfully many times, resizing partitions may lead to data loss, so back up your data), and that will free up room on that drive. You can use a program like GParted to resize partitions. Once done, you can take the leftover space and make a new partition (also done with GParted). Then you'll need to copy the contents of /usr/local and /opt over to the new partition (I usually do this part by inserting a live cd and mounting everything and copying). Finally, you'll need to edit /etc/fstab and tell it where to mount /usr/local and /opt.
The link given above on the steps to move /home are the same, so you can follow that guide for moving /usr/local and /opt. What you will need to do is resize the windows partition first.