背景
- 我的 MBP 只有 500GB, 多年用下来多余空间已经不足, 时不时就只有几 GB
- 我买了个 2 TB 的 SSD 做外置硬盘(尿袋), 每天插着用
发现微信占用了将近 50 GB
今天用 DaisyDisk
分析磁盘使用时, 发现微信占用了快 50 GB.

决定把迁移到 SSD 上, 因为动了沙盒环境, 微信迁移稍微麻烦一点, 上代码
注意: 先停止微信
1 2 3 4 5 6 7 8 9 10 11
| cp /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents /Volumes/Store/local/wechat/Documents
mv /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents /Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents_backup
ln -s /Volumes/Store/local/wechat/Documents $HOME/Library/Containers/com.tencent.xinWeChat/Data
sudo codesign --sign - --force --deep /Applications/WeChat.app
|
这时候就可以启动 wechat 了, 无痛迁移, 无影响就可以把 Users/apple/Library/Containers/com.tencent.xinWeChat/Data/Documents_backup
删除了.
对了, 需要允许一下微信反问外置硬盘

我的微信版本

最后的最后
附上我目前使用的一个脚本, 将目前 macOS 常用缓存等文件夹搬家到 SSD 里
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| #!/bin/bash
TARGET_DIR="/Volumes/Store/local"
declare -A FOLDERS_TO_MOVE FOLDERS_TO_MOVE=( ["$HOME/.pyenv"]="" ["$HOME/.ollama"]="" ["$HOME/.npm"]="" ["$HOME/.m2"]="" ["$HOME/.gradle"]="" ["$HOME/.cargo"]="" ["$HOME/Downloads/images"]="" ["$HOME/Downloads/lark"]="" ["$HOME/Library/Containers/com.tencent.xinWeChat/Data/Documents"]="wechat/Documents" )
mkdir -p "$TARGET_DIR"
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" }
for folder in "${!FOLDERS_TO_MOVE[@]}"; do dest_name="${FOLDERS_TO_MOVE[$folder]}"
if [ -z "$dest_name" ]; then dest_name=$(basename "$folder") fi
target_path="$TARGET_DIR/$dest_name"
if [ ! -d "$folder" ]; then log "警告: 文件夹 $folder 不存在,跳过" continue fi
if [ -e "$target_path" ]; then log "警告: 目标位置 $target_path 已存在,跳过" continue fi
if [ -L "$folder" ]; then log "警告: $folder 已经是软链接,跳过" continue fi
mkdir -p "$(dirname "$target_path")"
log "移动 $folder 到 $target_path" mv "$folder" "$target_path"
if [ $? -ne 0 ]; then log "错误: 无法移动 $folder 到 $target_path" continue fi
log "创建从 $target_path 到 $folder 的软链接" ln -s "$target_path" "$folder"
if [ $? -ne 0 ]; then log "错误: 无法创建从 $target_path 到 $folder 的软链接" mv "$target_path" "$folder" log "已尝试恢复原始文件夹" else log "成功: $folder 已移动并创建软链接" fi done
log "操作完成"
|