forked from TheLastBen/fast-stable-diffusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmounts.sh
More file actions
29 lines (27 loc) · 1.72 KB
/
mounts.sh
File metadata and controls
29 lines (27 loc) · 1.72 KB
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
#set -x
dir1=/content/gdrive/MyDrive/sd/stable-diffusion-webui
dir2=/content/gdrive2/MyDrive/sd/stable-diffusion-webui
for a in extensions models embeddings outputs config.json ui-config.json; do umount $dir1/$a; done
# rename any that weren't bind-mounted (don't delete anything, I learned this the hard way...delete from inside drive if I do something weird.)
for a in extensions models embeddings config.json ui-config.json; do mv $dir1/$a $dir1/$a.bak; done
# make new empty directories
for a in extensions models embeddings outputs; do mkdir -p $dir1/$a; done > /dev/null
# bind-mount drive directories to them
for a in extensions models embeddings; do mount --bind $(realpath $dir2/$a) $dir1/$a; done
# bind-mount output directory to unshared drive folder (also make sure it exists)
mkdir -p /content/gdrive2/MyDrive/outputs; mount --bind $(realpath /content/gdrive2/MyDrive/outputs) $dir1/outputs;
# bind-mount configs (http://www.mardy.it/blog/2018/10/how-to-bind-mount-single-file.html)
# but only if they already exist...if they don't exist, I think they get autogenerated, in which case you'll want to copy them over.
for a in config.json ui-config.json params.txt; do [ -e "$dir2/$a" ] && touch "$dir1/$a" && mount -o rw,bind "$dir2/$a" "$dir1/$a"; done
# lastly, delete that annoyingly distracting sample data directory
rm -rf /content/sample_data
cd /content
ln -s /content/gdrive2/MyDrive/sd
ln -s $dir2
ln -s $dir2/models
ln -s $dir2/models/Lora
ln -s $dir2/models/Stable-diffusion
ln -s $dir2/models/hypernetworks
ln -s $dir2/models/LoCon
#set +x
# I tried checking for a file (`touch ~/.bindmounts`, `[ -e ~/.bindmounts ]`), then found a typo where it moved files outside of drive on another account...that was a mess to clean up from 😢