Created
August 6, 2023 17:25
-
-
Save GamePlayer-8/ed5f701d669bbba797dbb4f401f55f31 to your computer and use it in GitHub Desktop.
Get RAM for tmpfs (safe) a.k.a. RamDrive
This file contains hidden or 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/sh | |
result=$(free -m | awk '/Mem/ {printf "%.0f\n", $7/1024}') | |
divided_value=$(awk "BEGIN { printf \"%.2f\n\", $result / 1.7 }") | |
final_value=$(awk "BEGIN { printf \"%.0f\n\", $divided_value }") | |
echo 'Allocating '$final_value' GB of RAM as RamDrive at /ramdrive...' | |
mkdir /ramdrive 2>/dev/null 3>&2 | |
umount -R /ramdrive 2>/dev/null 3>&2 | |
mount -t tmpfs -o size=${final_value}G tmpfs /ramdrive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment