Skip to content

Instantly share code, notes, and snippets.

@brianlechthaler
Created November 25, 2020 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianlechthaler/d903cabdd1e4445188407927d276e821 to your computer and use it in GitHub Desktop.
Save brianlechthaler/d903cabdd1e4445188407927d276e821 to your computer and use it in GitHub Desktop.
Easily create a ramdisk on any Linux system. Example: ./mkramdisk.sh 1g /mnt/ramdisk
#!/bin/sh
export invokingUser=$(whoami)
echo "Usage: ./mkramdisk.sh <disk_size_bytes> <ramdisk_mountpoint>"
echo "Example: ./mkramdisk.sh 1G /mnt/ramdisk"
sudo mkdir -p $2
sudo chown -R $invokingUser:$invokingUser $2
sudo mount -t tmpfs -o size=$1 tmpfs $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment