Quick Linux Tip #106:
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.
Leave a Reply