Managing Kernel Memory Swap with swap
The swap
command in the ChromeOS Shell provides tools to manage compressed swap (zram) settings and control memory management parameters. This command is intended for advanced users and experimental purposes.
Usage
swap [ enable <size (MB)> | disable | start | stop | status ]
Options
enable <size (MB)>
: Enable compressed swap with a specified size in megabytes. If no size is provided, the factory default is used.disable
: Disable compressed swap persistently, effective after the next reboot.start
: Immediately enable swap without altering persistent settings.stop
: Immediately disable swap without altering persistent settings.status
: Display the current swap configuration and usage statistics.
Examples
1. Enable Compressed Swap with Default Size
swap enable
This enables compressed swap using the factory default size.
2. Enable Compressed Swap with Custom Size
swap enable 1024
This enables compressed swap with a size of 1024 MB.
3. Disable Compressed Swap
swap disable
This disables swap persistently, taking effect after a reboot.
4. Start Swap Immediately
swap start
This enables swap immediately for the current session without modifying persistent settings.
5. Check Swap Status
swap status
This displays the current swap settings and usage statistics.
Additional Information
- Purpose: Swap provides a way to extend memory by using compressed storage, improving performance during high memory usage.
- Temporary vs. Persistent: Use
start
orstop
for temporary changes andenable
ordisable
for persistent configurations. - Impact: Enabling or disabling swap may affect system performance, especially during memory-intensive tasks.
Best Practices
- Use Default Sizes for Stability
Start with the factory default swap size to avoid unexpected behavior.
Monitor Memory Usage
Use
swap status
to assess whether swap is being used effectively and adjust configurations accordingly.Avoid Disabling Swap in Use
- Stopping or disabling swap when in use can cause the system to hang while memory is freed.
The swap
command is a powerful tool for memory management, providing flexibility for advanced users to optimize system performance.