{"id":1099,"date":"2025-09-23T16:38:39","date_gmt":"2025-09-23T13:38:39","guid":{"rendered":"https:\/\/narhost.com\/destek\/?p=1099"},"modified":"2026-09-12T04:22:55","modified_gmt":"2026-09-12T01:22:55","slug":"swap-alani-nasil-olusturulur","status":"publish","type":"post","link":"https:\/\/narhost.com\/destek\/swap-alani-nasil-olusturulur\/","title":{"rendered":"Swap Alan\u0131 Nas\u0131l Olu\u015fturulur (VPS \u0130lk Kurulum 7\/10)"},"content":{"rendered":"<p class=\"kb-dogrulama\">Son g\u00f6zden ge\u00e7irme: Eyl\u00fcl 2026 \u00b7 AlmaLinux 9, Rocky 9 ve Ubuntu 22.04\/24.04 resm\u00ee dok\u00fcman\u0131na g\u00f6re<\/p>\n<div id=\"hizli-cozum\" class=\"ai-box ai-box--cozum\">\n<p class=\"ai-box-title\">H\u0131zl\u0131 \u00e7\u00f6z\u00fcm<\/p>\n<p><strong>Swap alan\u0131 nas\u0131l olu\u015fturulur<\/strong> sorusunun k\u0131sa cevab\u0131: <code>fallocate<\/code> (desteklenmiyorsa <code>dd<\/code>) ile bo\u015f bir dosya ay\u0131r\u0131r, <code>chmod 600<\/code> ile yaln\u0131zca root&#8217;un eri\u015febilece\u011fi h\u00e2le getirir, <code>mkswap<\/code> ile bi\u00e7imlendirir, <code>swapon<\/code> ile etkinle\u015ftirir ve <code>\/etc\/fstab<\/code>&#8216;a ekleyerek sunucu yeniden ba\u015flad\u0131\u011f\u0131nda da kal\u0131c\u0131 k\u0131lars\u0131n\u0131z.<\/p>\n<ol>\n<li><code>sudo fallocate -l 2G \/swapfile<\/code> ile dosyay\u0131 ay\u0131r\u0131n (boyutu RAM&#8217;inize g\u00f6re a\u015fa\u011f\u0131da belirleyin).<\/li>\n<li><code>sudo chmod 600 \/swapfile && sudo mkswap \/swapfile && sudo swapon \/swapfile<\/code> ile etkinle\u015ftirin.<\/li>\n<li><code>\/etc\/fstab<\/code>&#8216;a <code>\/swapfile none swap sw 0 0<\/code> sat\u0131r\u0131n\u0131 ekleyip <code>free -h<\/code> ile do\u011frulay\u0131n.<\/li>\n<\/ol>\n<\/div>\n<table class=\"kb-uyg\">\n<tr>\n<th>Panel<\/th>\n<td>Yok \u2014 VPS\/VDS y\u00f6netimsizdir; i\u015flem i\u015fletim sistemi \u00fczerinden yap\u0131l\u0131r<\/td>\n<\/tr>\n<tr>\n<th>Sistem<\/th>\n<td>AlmaLinux 9, Rocky 9 \u00b7 Ubuntu 22.04\/24.04, Debian 12<\/td>\n<\/tr>\n<tr>\n<th>Yetki<\/th>\n<td>Sunucunuzun root ya da sudo yetkili kullan\u0131c\u0131s\u0131<\/td>\n<\/tr>\n<tr>\n<th>Narhost \u00fcr\u00fcn\u00fc<\/th>\n<td><a href=\"https:\/\/narhost.com\/vps-sunucu\" title=\"Narhost VPS Sunucu paketleri\">VPS Sunucu<\/a>, VDS Sunucu<\/td>\n<\/tr>\n<\/table>\n<div class=\"kb-once\">\n<p class=\"label\">Ba\u015flamadan \u00f6nce<\/p>\n<ul>\n<li>Sunucunuzda root ya da sudo yetkiniz olsun.<\/li>\n<li>Diskte yeterli bo\u015f alan oldu\u011funu <code>df -h<\/code> ile kontrol edin; swap dosyas\u0131 bo\u015f alan\u0131n b\u00fcy\u00fck k\u0131sm\u0131n\u0131 doldurmas\u0131n.<\/li>\n<li>Sunucunuzun mevcut RAM miktar\u0131n\u0131 <code>free -h<\/code> ile \u00f6\u011frenin; swap boyutunu buna g\u00f6re belirleyeceksiniz.<\/li>\n<li>Konteyner tabanl\u0131 bir sa\u011flay\u0131c\u0131 ortam\u0131ndaysan\u0131z swap dosyas\u0131 olu\u015fturman\u0131n altyap\u0131 d\u00fczeyinde k\u0131s\u0131tlanabilece\u011fini unutmay\u0131n.<\/li>\n<\/ul>\n<\/div>\n<h2>Swap Alan\u0131 Nas\u0131l Olu\u015fturulur, Ne \u0130\u015fe Yarar<\/h2>\n<p>Swap, fiziksel RAM yetersiz kald\u0131\u011f\u0131nda devreye giren, disk \u00fczerinde ayr\u0131lan yedek bellek alan\u0131d\u0131r; \u00e7ekirdek az kullan\u0131lan bellek sayfalar\u0131n\u0131 buraya yazarak RAM&#8217;i etkin s\u00fcre\u00e7lere ay\u0131r\u0131r. D\u00fc\u015f\u00fck RAM&#8217;li VPS paketlerinde ani bellek dalgalanmalar\u0131 \u2014 toplu g\u00fcncelleme, yedekleme beti\u011fi, a\u011f\u0131r bir derleme \u2014 sunucuyu belle\u011fi t\u00fckenmi\u015f (OOM) duruma getirebilir; swap bu anlarda sunucunun \u00e7\u00f6kmesini geciktirir ya da tamamen \u00f6nler.<\/p>\n<p>Narhost&#8217;ta VPS ve VDS sunucular y\u00f6netimsizdir: Narhost altyap\u0131y\u0131 ve a\u011f\u0131 sa\u011flar, i\u015fletim sistemi i\u00e7indeki bellek ve swap ayarlar\u0131 sunucuyu teslim alan sizin sorumlulu\u011funuzdad\u0131r. Bu kartta swap alan\u0131 nas\u0131l olu\u015fturulur sorusunu d\u00fc\u015f\u00fck RAM&#8217;li paketlerde ad\u0131m ad\u0131m anlat\u0131yoruz.<\/p>\n<figure class=\"nh-sema\"><img src=\"https:\/\/narhost.com\/destek\/wp-content\/uploads\/2026\/09\/swap-alani-nasil-olusturulur-sema-narhost.webp\" alt=\"swap alan\u0131 nas\u0131l olu\u015fturulur ak\u0131\u015f \u015femas\u0131 \u2014 dosya olu\u015fturma, izin verme, etkinle\u015ftirme ve fstab&#x27;a ekleme ad\u0131mlar\u0131\" width=\"1200\" height=\"500\" loading=\"lazy\" decoding=\"async\"><figcaption>Swap alan\u0131 nas\u0131l olu\u015fturulur sorusu d\u00f6rt ad\u0131mda \u00f6zetlenir: dosya olu\u015fturma, izinleri k\u0131s\u0131tlama ve bi\u00e7imlendirme, etkinle\u015ftirme, fstab&#x27;a ekleyip swappiness ayarlama.<\/figcaption><\/figure>\n<h2>Ne Kadar Swap Gerekir<\/h2>\n<p>Kesin bir rakam yerine RAM&#8217;inize g\u00f6re pratik bir tahmin kullanabilirsiniz: 1 GB ve alt\u0131 RAM&#8217;de (tahmini) swap&#8217;\u0131 RAM&#8217;in iki kat\u0131na \u00e7\u0131kar\u0131n, 2-8 GB RAM&#8217;de (tahmini) RAM&#8217;e e\u015fit tutun, 8 GB \u00fczerinde ise 2-4 GB (tahmini) sabit swap genellikle yeterlidir; uygulaman\u0131z\u0131n bellek profiline g\u00f6re bu oran\u0131 b\u00fcy\u00fct\u00fcp k\u00fc\u00e7\u00fcltebilirsiniz.<\/p>\n<p>NVMe\/SSD disklerde swap performans kayb\u0131 yaratmadan \u00e7al\u0131\u015f\u0131r, ama s\u00fcrekli yo\u011fun swap kullan\u0131m\u0131 diskte gereksiz bir yazma d\u00f6ng\u00fcs\u00fc olu\u015fturur; <code>vm.swappiness<\/code> de\u011ferini d\u00fc\u015f\u00fck tutmak bu y\u00fck\u00fc de azalt\u0131r. Parametrenin ald\u0131\u011f\u0131 de\u011fer aral\u0131\u011f\u0131 ve etkisi <a href=\"https:\/\/docs.kernel.org\/admin-guide\/sysctl\/vm.html\" title=\"Linux \u00e7ekirde\u011fi vm.* sysctl parametreleri resmi dok\u00fcmantasyonu (swappiness)\" target=\"_blank\" rel=\"noopener\">Linux \u00e7ekirde\u011finin resmi sysctl dok\u00fcman\u0131nda<\/a> tan\u0131ml\u0131d\u0131r. Baz\u0131 konteyner tabanl\u0131 ortamlarda swap dosyas\u0131 olu\u015fturma \u00e7ekirdek d\u00fczeyinde k\u0131s\u0131tlanabilir; <code>swapon<\/code> &#8220;Operation not permitted&#8221; derse sa\u011flay\u0131c\u0131n\u0131za dan\u0131\u015f\u0131n.<\/p>\n<h2>Ad\u0131m Ad\u0131m Swap Dosyas\u0131 Olu\u015fturma<\/h2>\n<h3>1. Mevcut Swap Durumunu Kontrol Edin<\/h3>\n<ol class=\"kb-adimlar\">\n<li><strong>Sunucunuza SSH ile ba\u011flan\u0131n<\/strong> ve mevcut durumu g\u00f6r\u00fcnt\u00fcleyin:\n<pre><code class=\"language-bash\">swapon --showfree -h<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: <code>swapon --show<\/code> bo\u015f d\u00f6n\u00fcyorsa hi\u00e7 swap yok; <code>free -h<\/code> \u00e7\u0131kt\u0131s\u0131ndaki Swap sat\u0131r\u0131 0 g\u00f6sterir.<\/p>\n<\/li>\n<\/ol>\n<h3>2. Swap Dosyas\u0131n\u0131 Olu\u015fturun ve Etkinle\u015ftirin<\/h3>\n<ol class=\"kb-adimlar\">\n<li><strong>Bo\u015f bir dosya ay\u0131r\u0131n<\/strong> (a\u015fa\u011f\u0131da \u00f6rnek olarak 2 GB kullan\u0131lm\u0131\u015ft\u0131r, tahmini boyutu yukar\u0131daki \u00f6l\u00e7\u00fcye g\u00f6re siz belirleyin):\n<pre><code class=\"language-bash\">sudo fallocate -l 2G \/swapfile<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: komut hatas\u0131z biter; <code>fallocate<\/code> desteklenmiyorsa <code>sudo dd if=\/dev\/zero of=\/swapfile bs=1M count=2048 status=progress<\/code> kullan\u0131n.<\/p>\n<\/li>\n<li><strong>\u0130zinleri k\u0131s\u0131tlay\u0131n ve bi\u00e7imlendirin:<\/strong>\n<pre><code class=\"language-bash\">sudo chmod 600 \/swapfilesudo mkswap \/swapfile<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: <code>mkswap<\/code> &#8220;Setting up swapspace&#8221; mesaj\u0131yla biter.<\/p>\n<\/li>\n<div class=\"warn-box\">\n<p class=\"label\">Dikkat<\/p>\n<p>Dosya izinlerini <code>600<\/code> yapmadan swap&#8217;\u0131 etkinle\u015ftirmeyin; ba\u015fka kullan\u0131c\u0131lar\u0131n okuyabildi\u011fi bir swap dosyas\u0131 bellekte ge\u00e7ici olarak duran parola ve anahtar gibi verileri a\u00e7\u0131\u011fa \u00e7\u0131karabilir.<\/p>\n<\/div>\n<li><strong>Swap&#8217;\u0131 etkinle\u015ftirin:<\/strong>\n<pre><code class=\"language-bash\">sudo swapon \/swapfile<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: komut sessizce biter; <code>swapon --show<\/code> art\u0131k <code>\/swapfile<\/code> sat\u0131r\u0131n\u0131 listeler.<\/p>\n<\/li>\n<\/ol>\n<h3>3. Kal\u0131c\u0131 Hale Getirin ve Swappiness Ayarlay\u0131n<\/h3>\n<ol class=\"kb-adimlar\">\n<li><strong><code>\/etc\/fstab<\/code>&#8216;a ekleyin<\/strong> ki sunucu yeniden ba\u015flad\u0131\u011f\u0131nda swap otomatik etkinle\u015fsin:\n<pre><code class=\"language-bash\">echo '\/swapfile none swap sw 0 0' | sudo tee -a \/etc\/fstab<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: sat\u0131r dosyan\u0131n sonuna eklenir; <code>cat \/etc\/fstab<\/code> ile kontrol edin.<\/p>\n<\/li>\n<li><strong>Swappiness de\u011ferini ayarlay\u0131n<\/strong> (d\u00fc\u015f\u00fck de\u011fer swap&#8217;\u0131n yaln\u0131zca gerekti\u011finde kullan\u0131lmas\u0131n\u0131 sa\u011flar):\n<pre><code class=\"language-bash\">sudo sysctl vm.swappiness=10echo 'vm.swappiness=10' | sudo tee -a \/etc\/sysctl.conf<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: <code>cat \/proc\/sys\/vm\/swappiness<\/code> &#8220;10&#8221; de\u011ferini g\u00f6sterir; ikinci sat\u0131r ayar\u0131 kal\u0131c\u0131 yapar.<\/p>\n<\/li>\n<\/ol>\n<h3>4. Swap Alan\u0131n\u0131 Kald\u0131rma (\u0130ste\u011fe Ba\u011fl\u0131)<\/h3>\n<ol class=\"kb-adimlar\">\n<li><strong>Swap&#8217;\u0131 devre d\u0131\u015f\u0131 b\u0131rak\u0131n:<\/strong>\n<pre><code class=\"language-bash\">sudo swapoff \/swapfile<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: komut sessizce biter; <code>swapon --show<\/code> art\u0131k dosyay\u0131 listelemez.<\/p>\n<\/li>\n<li><strong><code>\/etc\/fstab<\/code>&#8216;daki sat\u0131r\u0131 silin<\/strong> ve dosyay\u0131 kald\u0131r\u0131n:\n<pre><code class=\"language-bash\">sudo sed -i '\/\\\/swapfile\/d' \/etc\/fstabsudo rm \/swapfile<\/code><\/pre>\n<p class=\"kb-cikti\">Beklenen sonu\u00e7: <code>free -h<\/code> Swap sat\u0131r\u0131nda tekrar 0 g\u00f6sterir.<\/p>\n<\/li>\n<\/ol>\n<h2>Do\u011frulama<\/h2>\n<div class=\"success-box\">\n<p class=\"label\">Sonu\u00e7<\/p>\n<p><code>free -h<\/code> \u00e7\u0131kt\u0131s\u0131ndaki Swap sat\u0131r\u0131 ayarlad\u0131\u011f\u0131n\u0131z boyutu g\u00f6steriyor ve <code>swapon --show<\/code><code>\/swapfile<\/code>&#8216;\u0131 listeliyorsa swap alan\u0131 \u00e7al\u0131\u015f\u0131yor demektir. Yo\u011fun bir i\u015flem s\u0131ras\u0131nda <code>free -h<\/code>&#8216;\u0131 tekrar \u00e7al\u0131\u015ft\u0131r\u0131p &#8220;used&#8221; de\u011ferinin artt\u0131\u011f\u0131n\u0131 g\u00f6rmek swap&#8217;\u0131n devrede oldu\u011funu do\u011frular.<\/p>\n<\/div>\n<h2>H\u00e2l\u00e2 \u00e7\u00f6z\u00fclmediyse<\/h2>\n<ul>\n<li><strong><code>fallocate<\/code> &#8220;Operation not supported&#8221; hatas\u0131 veriyor.<\/strong> Dosya sisteminiz bu \u00e7a\u011fr\u0131y\u0131 desteklemiyor olabilir; <code>dd<\/code> y\u00f6ntemine ge\u00e7in.<\/li>\n<li><strong><code>swapon<\/code> &#8220;Invalid argument&#8221; hatas\u0131 veriyor.<\/strong><code>mkswap<\/code> ad\u0131m\u0131n\u0131 atlam\u0131\u015f olabilirsiniz; komutu tekrar \u00e7al\u0131\u015ft\u0131r\u0131p yeniden deneyin.<\/li>\n<li><strong>Diskte yer kalmad\u0131.<\/strong> \u00d6nce <a href=\"https:\/\/narhost.com\/destek\/linux-sunucuda-disk-kullanimi-nasil-denetlenir\/\" title=\"Linux sunucuda disk kullan\u0131m\u0131 denetleme \u2014 Narhost Destek\">disk kullan\u0131m\u0131n\u0131 denetleme kart\u0131yla<\/a> yer a\u00e7\u0131n; disk k\u00fc\u00e7\u00fckse <a href=\"https:\/\/narhost.com\/destek\/ubuntu-xfs-disk-genisletme\/\" title=\"Ubuntu&#039;da XFS disk geni\u015fletme \u2014 Narhost Destek\">disk geni\u015fletme ad\u0131m\u0131na (8\/10)<\/a> ge\u00e7in.<\/li>\n<li><strong>Komutlar beklendi\u011fi gibi \u00e7al\u0131\u015fm\u0131yor.<\/strong> Sunucu paketleriniz g\u00fcncel olmayabilir; \u00f6nce <a href=\"https:\/\/narhost.com\/destek\/debian-guncelleme-nasil-yapilir\/\" title=\"Sunucu paketlerini g\u00fcncelleme \u2014 Narhost Destek\">paket g\u00fcncelleme ad\u0131m\u0131n\u0131 (6\/10)<\/a> tamamlay\u0131n.<\/li>\n<\/ul>\n<div class=\"cta-box\">\n<p class=\"label\">Narhost deste\u011fi<\/p>\n<p>Talebe \u015funlar\u0131 ekleyin: sunucu IP adresi, i\u015fletim sisteminiz, \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131n\u0131z komut ve ald\u0131\u011f\u0131n\u0131z tam hata mesaj\u0131.<\/p>\n<p><a class=\"cta-btn\" href=\"https:\/\/narhost.com\/submitticket.php\" title=\"Narhost destek talebi olu\u015ftur\">Destek talebi a\u00e7<\/a><\/div>\n<div class=\"kb-ilgili\">\n<p class=\"label\">VPS ilk kurulum serisi \u2014 7\/10<\/p>\n<ul>\n<li><a href=\"https:\/\/narhost.com\/destek\/vps-vds-ilk-kurulum-rehberi\/\" title=\"VPS VDS Sunucu \u0130lk Kurulum Rehberi \u2014 Narhost Destek\">VPS ilk kurulum rehberinin tamam\u0131<\/a><\/li>\n<li><a href=\"https:\/\/narhost.com\/destek\/debian-guncelleme-nasil-yapilir\/\" title=\"Sunucu paketlerini g\u00fcncelleme \u2014 Narhost Destek\">\u00d6nceki ad\u0131m: sunucu paketlerini g\u00fcncelleme (6\/10)<\/a><\/li>\n<li><a href=\"https:\/\/narhost.com\/destek\/ubuntu-xfs-disk-genisletme\/\" title=\"Ubuntu&#039;da XFS disk geni\u015fletme \u2014 Narhost Destek\">Sonraki ad\u0131m: Ubuntu&#8217;da XFS disk geni\u015fletme (8\/10)<\/a><\/li>\n<li><a href=\"https:\/\/narhost.com\/destek\/linux-sunucuda-disk-kullanimi-nasil-denetlenir\/\" title=\"Linux sunucuda disk kullan\u0131m\u0131 denetleme \u2014 Narhost Destek\">Disk kullan\u0131m\u0131n\u0131 denetleme (df, du)<\/a><\/li>\n<\/ul>\n<\/div>\n<div class=\"kb-faq\">\n<h2>S\u0131k\u00e7a sorulan sorular<\/h2>\n<h3>Swap alan\u0131 ne kadar olmal\u0131, RAM&#8217;in ka\u00e7 kat\u0131 yeterli?<\/h3>\n<p>Kesin bir rakam yoktur, genel bir tahmindir: d\u00fc\u015f\u00fck RAM&#8217;de (tahmini) iki kat\u0131, orta seviyede (tahmini) RAM&#8217;e e\u015fit, y\u00fcksek RAM&#8217;de sabit birka\u00e7 GB (tahmini) genellikle yeterlidir.<\/p>\n<h3>Swap dosyas\u0131 yerine ayr\u0131 bir swap b\u00f6l\u00fcm\u00fc (partition) kullanmam gerekir mi?<\/h3>\n<p>Hay\u0131r, performans fark\u0131 pratikte \u00f6nemsizdir; swap dosyas\u0131 daha esnektir \u00e7\u00fcnk\u00fc boyutunu sonradan de\u011fi\u015ftirebilir, b\u00f6l\u00fcm i\u00e7in ise disk yeniden yap\u0131land\u0131rman\u0131z gerekir.<\/p>\n<h3>Swappiness de\u011ferini neden d\u00fc\u015f\u00fcr\u00fcyoruz?<\/h3>\n<p>Varsay\u0131lan de\u011fer (genellikle 60) RAM bo\u015fken bile bir miktar swap kullan\u0131r; d\u00fc\u015f\u00fcrmek RAM doluluk oran\u0131 y\u00fcksek olana kadar swap&#8217;\u0131 ertelemesini sa\u011flar ve performans\u0131 korur.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Swap alan\u0131 nas\u0131l olu\u015fturulur: fallocate\/dd ile dosya olu\u015fturma, mkswap ve swapon ile etkinle\u015ftirme, \/etc\/fstab ile kal\u0131c\u0131 hale getirme, swappiness ayar\u0131 ve kald\u0131rma ad\u0131m\u0131.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[161],"class_list":["post-1099","post","type-post","status-publish","format-standard","hentry","category-vps-server","tag-swap"],"meta_box":[],"_links":{"self":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/1099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/comments?post=1099"}],"version-history":[{"count":4,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/1099\/revisions"}],"predecessor-version":[{"id":1453,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/1099\/revisions\/1453"}],"wp:attachment":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/media?parent=1099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/categories?post=1099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/tags?post=1099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}