forked from apache/cassandra
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathmount-tmpfs
executable file
·43 lines (33 loc) · 1.39 KB
/
mount-tmpfs
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
#!/bin/bash
# This script simply mounts a tmpfs filesystem at build/test/cassandra
# If there is already a tmpfs mounted at that location, it will be unmounted first
# The size of the tmpfs is 1GB
# The script is expected to work on both Linux and MacOS
# Run the script from the root of your project. In most cases it should improve performance of running unit tests.
# Do not run it using sudo, it will ask for sudo password if needed.
# The script does not expect any arguments.
(grep "apache-cassandra" build.xml || grep "dse-db" build.xml) 1> /dev/null
os="$(uname | tr '[:upper:]' '[:lower:]')"
if [[ "$os" == "darwin" ]]; then
existing="$(diskutil list | grep CassandraBuildTmp || true)"
if [[ -n "$existing" ]]; then
diskname="$(hdiutil | grep CassandraBuildTmp | cut -f 1)"
diskutil unmount CassandraBuildTmp
hdiutil detach "$diskname"
fi
rm -rf build/test/cassandra
mkdir -p build/test/cassandra
diskutil erasevolume HFS+ CassandraBuildTmp "$(hdiutil attach -nomount ram://2097152)"
diskutil mount -mountPoint "$(pwd)/build/test/cassandra" CassandraBuildTmp
elif [[ "$os" == "linux" ]]; then
mount | grep tmpfs | grep /build/test/cassandra | cut -f 3 -d ' ' | while read -r line;
do
sudo umount "$line"
done
rm -rf build/test/cassandra
mkdir -p build/test/cassandra
sudo mount -t tmpfs -o size=1024M tmpfs "$(pwd)/build/test/cassandra"
else
echo "Unrecognized OS: $os" 1>&2
exit 1
fi