Last Updated: Dec 15th, 2025
Introduction
This guide explains how to resize a tmpfs filesystem on a Crusoe Virtual Machine. tmpfs is a temporary file storage system that resides in volatile memory (RAM), offering high-speed I/O operations for temporary files. You may need to resize tmpfs when applications require more temporary storage space or when the default allocation is insufficient for your workload requirements.
Prerequisites
Before starting this task, ensure you have:
- Access to a Crusoe VM with
sudoor root privileges - Understanding of your application's memory (RAM) requirements to avoid performance degradation
- Knowledge of which
tmpfsmount points need resizing - Sufficient available RAM on your system to accommodate the increased
tmpfssize
Step-by-Step Instructions
1. Verify Current tmpfs Usage
Before making any changes, check the current size and usage of your tmpfs mounts to identify which ones may need resizing.
df -hT | grep tmpfs
Example Output:
tmpfs tmpfs 6.8G 1.2M 6.8G 1% /dev/shm tmpfs tmpfs 2.8G 8.0K 2.8G 1% /tmp tmpfs tmpfs 1.4G 1.1M 1.4G 1% /run
- Review the output to identify mount points that are approaching capacity
- Note the current sizes and usage percentages
- Common
tmpfsmount points include/tmp,/run,/dev/shm, and/run/lock
2. Resize tmpfs Temporarily
Resize the tmpfs mount temporarily for immediate relief. This change will only persist until the next reboot.
sudo mount -o remount,size=<NEW_SIZE>G tmpfs <MOUNT_POINT>
Example (resizing /tmp to 8GB):
sudo mount -o remount,size=8G tmpfs /tmp
- Replace
<NEW_SIZE>Gwith your desired size (e.g.,8Gfor 8 gigabytes) - Replace
<MOUNT_POINT>with the specific tmpfs mount point you want to resize - Verify the change by running
df -hT | grep tmpfsagain
3. Make Resizing Persistent
To ensure the new size persists across reboots, add or update the corresponding entry in the /etc/fstab file.
First, create a backup of your current /etc/fstab:
sudo cp /etc/fstab /etc/fstab.backup
Then edit the /etc/fstab file:
sudo nano /etc/fstab
Example (setting /tmp to 8GB permanently): Add or modify the following line in /etc/fstab:
tmpfs /tmp tmpfs defaults,size=8G 0 0
- If an entry for the mount point already exists, update the
sizeparameter - If no entry exists, add a new line with the format shown above
- Save and exit the editor
4. Test the Configuration
Test your /etc/fstab configuration without rebooting:
sudo mount -a
If there are no errors, verify the changes:
df -hT | grep tmpfs
Example
Scenario: A development server running build processes requires more space in /tmp for compilation artifacts.
Current State:
tmpfs tmpfs 2.8G 2.5G 300M 90% /tmp
Action Taken:
-
Temporarily resize
/tmpto 8GB:sudo mount -o remount,size=8G tmpfs /tmp
-
Add permanent configuration to
/etc/fstab:tmpfs /tmp tmpfs defaults,size=8G 0 0
Result:
tmpfs tmpfs 8.0G 2.5G 5.5G 32% /tmp
The /tmp filesystem now has sufficient space for build processes, and the configuration will persist across reboots.
Troubleshooting
Issue: Mount command fails with "device or resource busy" error
-
Resolution: Some processes may be using files in the tmpfs. Use
lsof /tmpto identify processes and safely stop them before remounting.
Issue: System becomes slow or unresponsive after resizing
- Resolution: The tmpfs size may be too large for available RAM. Reduce the size and ensure you have adequate free memory.
Issue: Changes don't persist after reboot despite updating /etc/fstab
- Resolution: Some tmpfs mounts are managed by systemd. Check if systemd is overriding your configuration and may require additional systemd tmpfiles configuration.
Issue: Permission denied when editing /etc/fstab
-
Resolution: Ensure you're using
sudowhen editing system configuration files.
Important Cautions
-
Volatile Storage:
tmpfsuses the system's RAM. Increasing its size reduces memory available for other processes and applications. Ensure sufficient free RAM to avoid system performance issues. -
Data Persistence: All data stored in a
tmpfsfilesystem is lost when the virtual machine is rebooted or shut down. For persistent storage, use disk-based directories like/var/tmp. -
Systemd Interaction: Some
tmpfsmounts (e.g.,/run/lock) may be managed bysystemd. Changes made directly in/etc/fstabmight be overridden, requiring additional systemd configuration. -
Safe Temporary File Handling: Since directories like
/tmpare often world-writable, always use secure methods for creating temporary files to avoid conflicts or security vulnerabilities.