Skip to content

Instantly share code, notes, and snippets.

@GamePlayer-8
Created August 6, 2023 17:25
Show Gist options
  • Save GamePlayer-8/ed5f701d669bbba797dbb4f401f55f31 to your computer and use it in GitHub Desktop.
Save GamePlayer-8/ed5f701d669bbba797dbb4f401f55f31 to your computer and use it in GitHub Desktop.
Get RAM for tmpfs (safe) a.k.a. RamDrive
#!/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