Any better way to move app library path to external drive than using symbolic link

hard drivessdsymlink

I am running MacOS 10.14.5. I used symbolic links a lot to free up my internal drive. My internal drive is almost full and I need to free up some spaces again. Normally, the symbolic links solution work very well even for many apps. But there is one app which can not recognize the symbolic link I created. So I am wondering how to workaround this issue? I have to move this app's library directory to external ssd drive, it uses 50% of my internal drive.

Btw, the path I plan to move is at ~/Library/Containers/xxxx.

Thanks a lot.

PS: I am wondering if I can create a .sparseimage file and then put it at external drive. And add it somehow to /etc/fstab to mount it at a specific location. Not sure if this will work. I am checking this way now.

Best Answer

OK, finally I solved this problem. My solution:

  1. Use Disk Utility.app to create a new blank image with sparseimage type and save it at the external ssd drive.
  2. Then mount the sparse image at the target location, such as hdiutil attach /Volumes/<externalssd>/file.sparseimage -mountpoint ~/Library/Containers/<target_path>
  3. move all the original files to the mounted point.

That's all. By the way, you need to quit the app first and rename the target directory to something else before mounting the image obviously.

One more tip: you should make sure the target directory you want to move will not have any broken symbolic links after this workaround by running find . -type l -ls command.