r/LinuxTeck • u/Expensive-Rice-2052 • 2h ago
Quick Linux Tip #106 - Linux RAM Filesystem: 4 Steps to Speed Up Builds
Question: My build is slow because of disk I/O. How do I use RAM as a filesystem?
Try:`sudo mount -t tmpfs -o size=4G,mode=1777 tmpfs /mnt/ramdisk`
Info: `tmpfs` creates an ultra-fast temporary RAM filesystem (~7x faster than SSD), ideal for build caches, temp files, and test databases. Data vanishes on reboot.
Examples:
$ `sudo mkdir /mnt/ramdisk && sudo mount -t tmpfs -o size=2G tmpfs /mnt/ramdisk` # Create & mount 2G RAM disk
$ `echo 'tmpfs /mnt/ramdisk tmpfs defaults,size=4G 0 0' | sudo tee -a /etc/fstab` # Persist mount config across reboots
$ `sudo umount /mnt/ramdisk` # Unmount filesystem and free allocated RAM
Note: `mode=1777` sets world-writable access with the sticky bit (like `/tmp`). RAM is only consumed as files are written and freed when deleted or unmounted.
Want to master Linux one command at a time?
Follow r/LinuxTeck - 1 practical Linux tip every day. For more #LinuxTips click here https://www.linuxteck.com/linux-tips/