Kalkulator Tuning Swap, Swappiness & Inode Disk Linux
Hitung ukuran swap optimal Linux, parameter sysctl vm.swappiness, vm.vfs_cache_pressure, estimasi jumlah inode ext4, dan generator skrip /swapfile.
Parameter Input
Hasil Perhitungan
- Rekomendasi Ukuran Swap
- 4 GB
- Nilai Kernel vm.swappiness Optimal
- 20
- Nilai Kernel vm.vfs_cache_pressure
- 75
- Batas Sinkronisasi Memori Kotor (vm.dirty_ratio)
- 20 %
- Batas Flush Latar Belakang (vm.dirty_background_ratio)
- 10 %
- Estimasi Jumlah Inode Partisi ext4
- 13.107.200 Inode
- Rasio Alokasi Byte per Inode
- 16.384 Byte
- Rekomendasi Kapasitas Kompresi zram
- 8 GB
Uji aturan firewall dan skrip cron pada lingkungan staging terlebih dahulu, dan simpan backup konfigurasi di Git.
| Profil Beban Kerja | Rekomendasi Ukuran Swap | vm.swappiness | vm.vfs_cache_pressure |
|---|---|---|---|
| Database / Proxmox Hypervisor | 4 GB | 1 | 50 |
| Web / Container Server (Docker/K8s) | 4 GB | 20 | 75 |
| Desktop / Workstation + Hibernation | 20 GB | 60 | 100 |
| Low-RAM Cloud VPS (1–4 GB) | 32 GB | 60 | 100 |
# /etc/sysctl.d/99-infracalc-memory.conf # Profil: web_container | RAM: 16 GB | Disk: nvme_ssd vm.swappiness = 20 vm.vfs_cache_pressure = 75 vm.dirty_ratio = 20 vm.dirty_background_ratio = 10 # Terapkan dengan: sudo sysctl --system
# Buat dan aktifkan /swapfile di Linux sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Cara Menggunakan Alat Ini
- Masukkan kapasitas RAM fisik server (GB), pilih profil beban kerja (Database/Hypervisor, Web/Container, Desktop Hibernasi, atau VPS RAM kecil), dan jenis disk.
- Masukkan ukuran partisi penyimpanan ext4 (GB) untuk menghitung estimasi alokasi jumlah inode default.
- Tinjau rekomendasi ukuran swap, nilai vm.swappiness, vm.vfs_cache_pressure, lalu salin skrip /etc/sysctl.d/ dan perintah fallocate pembuatan swapfile.
Contoh Perhitungan Nyata: Server Web & Docker (16 GB RAM, 200 GB NVMe)
Contoh terhitung: Server dengan RAM 16 GB, profil Web/Container pada NVMe SSD, dan partisi 200 GB menghasilkan rekomendasi Swap 4 GB, vm.swappiness = 20, vm.vfs_cache_pressure = 75, serta sekitar 13.107.200 inode ext4.
- Kapasitas RAM Fisik Server (GB)
- 16 GB
- Profil Beban Kerja Server (Workload)
- Web / Container Server (Docker, Kubernetes, Nginx)
- Jenis Media Penyimpanan Disk
- NVMe SSD Enterprise / Cloud Block
- Ukuran Partisi Penyimpanan ext4 (GB)
- 200 GB
- Rekomendasi Ukuran Swap
- 4 GB
- Nilai Kernel vm.swappiness Optimal
- 20
- Nilai Kernel vm.vfs_cache_pressure
- 75
- Batas Sinkronisasi Memori Kotor (vm.dirty_ratio)
- 20 %
- Batas Flush Latar Belakang (vm.dirty_background_ratio)
- 10 %
- Estimasi Jumlah Inode Partisi ext4
- 13.107.200 Inode
- Rasio Alokasi Byte per Inode
- 16.384 Byte
- Rekomendasi Kapasitas Kompresi zram
- 8 GB
- Konfigurasi Tuning Kernel (/etc/sysctl.d/99-infracalc-memory.conf)
- # /etc/sysctl.d/99-infracalc-memory.conf # Profil: web_container | RAM: 16 GB | Disk: nvme_ssd vm.swappiness = 20 vm.vfs_cache_pressure = 75 vm.dirty_ratio = 20 vm.dirty_background_ratio = 10 # Terapkan dengan: sudo sysctl --system
- Skrip Pembuatan & Aktivasi /swapfile
- # Buat dan aktifkan /swapfile di Linux sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
| Profil Beban Kerja | Rekomendasi Ukuran Swap | vm.swappiness | vm.vfs_cache_pressure |
|---|---|---|---|
| Database / Proxmox Hypervisor | 4 GB | 1 | 50 |
| Web / Container Server (Docker/K8s) | 4 GB | 20 | 75 |
| Desktop / Workstation + Hibernation | 20 GB | 60 | 100 |
| Low-RAM Cloud VPS (1–4 GB) | 32 GB | 60 | 100 |
Konsep Dasar & Catatan Teknis
Cara Perhitungan (Rumus & Langkah)
Rumus Matematika
- Ukuran Swap Standar (8–64 GB RAM tanpa hibernasi) = max(4 GB, round(√RAM_GB))
- Ukuran Swap dengan Hibernasi = ceil(RAM_GB + √RAM_GB)
- Estimasi Jumlah Inode Default ext4 = floor((Ukuran_Partisi_GB × 1024^3) ÷ 16.384 byte)
Langkah Substitusi
- RAM Fisik = 16 GB, Profil Beban Kerja = web_container, Jenis Disk = nvme_ssd.
- Rekomendasi Swap = 4 GB (berdasarkan pedoman RHEL/Ubuntu √RAM dan kebutuhan non-hibernasi).
- Parameter Kernel: vm.swappiness = 20, vm.vfs_cache_pressure = 75, vm.dirty_ratio = 20%.
- Estimasi Inode ext4 untuk partisi 200 GB (rasio 16.384 byte/inode) = (200 × 1024³) / 16384 = 13,107,200 inode.
Pertanyaan yang Sering Diajukan (FAQ)
Mengapa vm.swappiness=1 lebih disarankan daripada vm.swappiness=0 pada server database?
Pada kernel Linux modern, nilai 0 menonaktifkan swapping halaman anonim hampir sepenuhnya hingga batas memori bebas kritis, yang dapat memicu OOM Killer mematikan proses database secara tiba-tiba. Nilai 1 meminimalkan swap namun tetap menjaga perlindungan darurat.
Apa fungsi parameter vm.vfs_cache_pressure?
Parameter ini mengatur kecenderungan kernel merebut kembali memori yang digunakan untuk menyimpan cache objek direktori (dentry) dan inode. Menurunkannya ke 50–75 membantu mempercepat operasi pencarian file pada server web dan file server.
Bagaimana cara memeriksa penggunaan inode pada partisi Linux saat ini?
Jalankan perintah 'df -i' di terminal. Output tersebut menampilkan jumlah total Inodes, IUsed (terpakai), IFree (tersisa), dan persentase penggunaan IUse% untuk setiap mount point.
Apakah jumlah inode ext4 dapat diubah setelah partisi diformat?
Rasio byte-per-inode pada ext4 bersifat tetap setelah pembuatan filesystem dan hanya bertambah secara proporsional jika partisi diperbesar (resize2fs). Untuk mengubah rasio (misal -i 4096), partisi harus diformat ulang dengan mkfs.ext4.
Alat Kalkulator Terkait
Lihat Semua Kalkulator Linux & DevOps →Konversi izin file Linux chmod oktal (755, 644, 4750) dan simbolik (-rwxr-xr-x), kalkulasi umask, analisis keamanan 777, dan tabel hak akses.
Generator ekspresi cron POSIX 5 kolom, baris crontab siap pakai, jadwal 5 eksekusi berikutnya, dan konversi unit systemd timer.
Generate skrip hardening firewall server Linux untuk UFW, iptables, dan /etc/nftables.conf lengkap dengan proteksi rate-limit SSH dan whitelist subnet.
Rencanakan jadwal jendela maintenance server lintas zona waktu WIB, WITA, WIT, SGT, dan UTC dengan deteksi benturan cron backup otomatis.
Referensi Standar & Catatan
- The Linux Kernel Documentation — Documentation for /proc/sys/vm/ (swappiness & vfs_cache_pressure)
- Red Hat Enterprise Linux Recommended System Swap Space Guidelines
Catatan: Hasil di atas merupakan estimasi berdasarkan rumus standar. Selalu verifikasi dengan dokumentasi resmi vendor dan kondisi lapangan sebelum implementasi pada lingkungan produksi.