Last active
January 21, 2020 19:59
-
-
Save cirocosta/c2cf9a7b818dd8e88fb67209bb9debd1 to your computer and use it in GitHub Desktop.
overlay copy-on-write of overlay copy-on-write out of order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
main() { | |
case $1 in | |
run) | |
prepare_fs | |
empty | |
cow_cow # hehe | |
cow | |
;; | |
clean) | |
clean | |
;; | |
*) | |
echo "Usage: $0 (run|clean)" | |
exit 1 | |
;; | |
esac | |
} | |
prepare_fs () { | |
mkdir -p empty | |
mkdir -p cow/{upper,work,merged} | |
mkdir -p cow_cow/{upper,work,merged} | |
} | |
empty() { | |
echo "empty" > empty/file | |
} | |
cow() { | |
sudo mount -t overlay \ | |
cow \ | |
-o lowerdir=./empty,upperdir=./cow/upper,workdir=./cow/work \ | |
./cow/merged | |
} | |
cow_cow() { | |
sudo mount -t overlay \ | |
cow_cow \ | |
-o lowerdir=./cow/merged,upperdir=./cow_cow/upper,workdir=./cow_cow/work \ | |
./cow_cow/merged | |
} | |
clean() { | |
sudo umount ./cow/merged | |
sudo umount ./cow_cow/merged | |
sudo rm -rf ./{cow,cow_cow,empty} | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment