{"id":408,"date":"2026-06-28T07:39:29","date_gmt":"2026-06-27T22:39:29","guid":{"rendered":"https:\/\/www.marchboy.xyz\/wordpress\/?p=408"},"modified":"2026-06-28T07:43:52","modified_gmt":"2026-06-27T22:43:52","slug":"swappiness%e3%81%a8%e3%81%af%e4%bd%95%e3%81%8b","status":"publish","type":"post","link":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/408","title":{"rendered":"Swappiness\u3068\u306f\u4f55\u304b"},"content":{"rendered":"<article>\n<h1>Swappiness\u8a2d\u5b9a<\/h1>\n<p>Ubuntu 26.04\u3067\u306f\u3001\u30e1\u30e2\u30ea\u5727\u8feb\u6642\u306b\u30b9\u30ef\u30c3\u30d7\u9818\u57df\u3078\u30c7\u30fc\u30bf\u3092\u79fb\u3059\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u5236\u5fa1\u3059\u308b <code>swappiness<\/code> \u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u4f9d\u7136\u3068\u3057\u3066\u91cd\u8981\u3067\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f <code>60<\/code> \u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u74b0\u5883\u3084\u30b5\u30fc\u30d0\u30fc\u7528\u9014\u306b\u5408\u308f\u305b\u3066\u6700\u9069\u5316\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3068\u30b9\u30e0\u30fc\u30ba\u306a\u64cd\u4f5c\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u76ee\u6b21<\/h2>\n<ul>\n<li><a href=\"#what-is\">Swappiness\u3068\u306f\u4f55\u304b<\/a><\/li>\n<li><a href=\"#check\">\u73fe\u5728\u306eSwappiness\u5024\u306e\u78ba\u8a8d\u65b9\u6cd5<\/a><\/li>\n<li><a href=\"#temp\">\u4e00\u6642\u7684\u306b\u5909\u66f4\u3059\u308b\u624b\u9806<\/a><\/li>\n<li><a href=\"#persist\">\u6c38\u7d9a\u7684\u306b\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3059\u308b\u65b9\u6cd5<\/a><\/li>\n<li><a href=\"#recommend\">\u7528\u9014\u5225\u304a\u3059\u3059\u3081\u8a2d\u5b9a\u5024<\/a><\/li>\n<li><a href=\"#troubleshoot\">\u8a2d\u5b9a\u5909\u66f4\u6642\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a><\/li>\n<\/ul>\n<h2 id=\"what-is\">Swappiness\u3068\u306f\u4f55\u304b<\/h2>\n<p>Linux \u30ab\u30fc\u30cd\u30eb\u306f\u3001\u7269\u7406\u30e1\u30e2\u30ea\u304c\u4e00\u5b9a\u306e\u95be\u5024\u3092\u4e0b\u56de\u3063\u305f\u3068\u304d\u306b\u30b9\u30ef\u30c3\u30d7\u9818\u57df\u3078\u30da\u30fc\u30b8\u3092\u66f8\u304d\u51fa\u3057\u307e\u3059\u3002\u305d\u306e\u95be\u5024\u3092\u6570\u5024\u3067\u8868\u3057\u305f\u3082\u306e\u304c <strong>swappiness<\/strong> \u3067\u3059\u3002<\/p>\n<ul>\n<li><strong>0<\/strong> \u202f\u2192\u202f \u53ef\u80fd\u306a\u9650\u308a\u7269\u7406\u30e1\u30e2\u30ea\u3092\u4f7f\u3044\u7d9a\u3051\u3001\u30b9\u30ef\u30c3\u30d7\u306f\u307b\u307c\u4f7f\u7528\u3057\u306a\u3044\u3002<\/li>\n<li><strong>100<\/strong>\u202f\u2192\u202f \u30e1\u30e2\u30ea\u304c\u591a\u5c11\u6b8b\u3063\u3066\u3044\u3066\u3082\u3059\u3050\u306b\u30b9\u30ef\u30c3\u30d7\u3078\u30c7\u30fc\u30bf\u3092\u79fb\u3059\u3002<\/li>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u306e <strong>60<\/strong> \u306f\u3001\u30d0\u30e9\u30f3\u30b9\u306e\u53d6\u308c\u305f\u4e2d\u9593\u5024\u3067\u3059\u3002<\/li>\n<\/ul>\n<p>\u30b9\u30ef\u30c3\u30d7\u306f\u30c7\u30a3\u30b9\u30af I\/O \u3092\u4f34\u3046\u305f\u3081\u3001\u983b\u7e41\u306b\u4f7f\u7528\u3059\u308b\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u4f4e\u4e0b\u3057\u307e\u3059\u3002\u4e00\u65b9\u3001\u30e1\u30e2\u30ea\u4e0d\u8db3\u3067\u30da\u30fc\u30b8\u30f3\u30b0\u304c\u983b\u7e41\u306b\u8d77\u304d\u308b\u3068\u3001\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u304c\u9045\u304f\u306a\u308a\u307e\u3059\u3002\u9069\u5207\u306a <code>swappiness<\/code> \u8a2d\u5b9a\u306f\u3001\u3053\u308c\u3089\u306e\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3092\u6700\u9069\u5316\u3057\u307e\u3059\u3002<\/p>\n<h2 id=\"check\">\u73fe\u5728\u306eSwappiness\u5024\u306e\u78ba\u8a8d\u65b9\u6cd5<\/h2>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><code>cat \/proc\/sys\/vm\/swappiness<\/code><\/pre>\n<p>\u4f8b\uff1a<\/p>\n<pre><code>$ cat \/proc\/sys\/vm\/swappiness\n60<\/code><\/pre>\n<h2 id=\"temp\">\u4e00\u6642\u7684\u306b\u5909\u66f4\u3059\u308b\u624b\u9806<\/h2>\n<p>\u30b7\u30b9\u30c6\u30e0\u3092\u518d\u8d77\u52d5\u305b\u305a\u306b\u5373\u5ea7\u306b\u5024\u3092\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u3001<code>sysctl<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre><code># \u4f8b: 10 \u306b\u8a2d\u5b9a\uff08\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u5411\u304d\uff09\nsudo sysctl vm.swappiness=10\n\n# \u8a2d\u5b9a\u304c\u53cd\u6620\u3055\u308c\u305f\u304b\u78ba\u8a8d\ncat \/proc\/sys\/vm\/swappiness<\/code><\/pre>\n<p>\u3053\u306e\u5909\u66f4\u306f\u30e9\u30f3\u30bf\u30a4\u30e0\u30e1\u30e2\u30ea\u4e0a\u306b\u306e\u307f\u6b8b\u308a\u3001\u6b21\u56de\u8d77\u52d5\u6642\u306b\u5143\u306b\u623b\u308a\u307e\u3059\u3002<\/p>\n<h2 id=\"persist\">\u6c38\u7d9a\u7684\u306b\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>\u518d\u8d77\u52d5\u5f8c\u3082\u8a2d\u5b9a\u3092\u4fdd\u6301\u3057\u305f\u3044\u5834\u5408\u306f\u30012 \u3064\u306e\u65b9\u6cd5\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n<h3>1. \/etc\/sysctl.d\/ \u306b\u30ab\u30b9\u30bf\u30e0\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210<\/h3>\n<pre><code># \/etc\/sysctl.d\/99-custom-swappiness.conf\nvm.swappiness = 10<\/code><\/pre>\n<p>\u4f5c\u6210\u5f8c\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u76f4\u3061\u306b\u53cd\u6620\u3055\u305b\u307e\u3059\u3002<\/p>\n<pre><code>sudo sysctl --system<\/code><\/pre>\n<h3>2. \/etc\/sysctl.conf \u306b\u8ffd\u8a18<\/h3>\n<pre><code># \/etc\/sysctl.conf \u306e\u6700\u5f8c\u306b\u8ffd\u52a0\nvm.swappiness = 10<\/code><\/pre>\n<p>\u3069\u3061\u3089\u306e\u65b9\u6cd5\u3067\u3082\u540c\u69d8\u306b\u6a5f\u80fd\u3057\u307e\u3059\u304c\u3001<code>\/etc\/sysctl.d\/<\/code> \u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u3084\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u304c\u4e0a\u66f8\u304d\u3057\u306b\u304f\u3044\u70b9\u3067\u63a8\u5968\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2 id=\"recommend\">\u7528\u9014\u5225\u304a\u3059\u3059\u3081\u8a2d\u5b9a\u5024<\/h2>\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n<thead>\n<tr>\n<th>\u5229\u7528\u30b7\u30fc\u30f3<\/th>\n<th>\u63a8\u5968 Swappiness \u5024<\/th>\n<th>\u30dd\u30a4\u30f3\u30c8<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u4e00\u822c\u7684\u306a\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\uff08Web\u95b2\u89a7\u30fb\u6587\u66f8\u4f5c\u6210\uff09<\/td>\n<td>10\u301c15<\/td>\n<td>\u30b9\u30ef\u30c3\u30d7\u3092\u6975\u529b\u4f7f\u308f\u305a\u3001\u30c7\u30a3\u30b9\u30afI\/O\u3092\u6e1b\u3089\u3059\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u958b\u767a\u74b0\u5883\uff08IDE\u30fb\u30b3\u30f3\u30c6\u30ca\u30fbVM \u3092\u591a\u7528\uff09<\/td>\n<td>20\u301c30<\/td>\n<td>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u304c\u5909\u52d5\u3057\u3084\u3059\u3044\u306e\u3067\u3001\u9069\u5ea6\u306b\u30b9\u30ef\u30c3\u30d7\u3092\u8a31\u5bb9\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u30b5\u30fc\u30d0\u30fc\uff08\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fbWeb\u30b5\u30fc\u30d0\u30fc\uff09<\/td>\n<td>60\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\uff09<\/td>\n<td>\u5b89\u5b9a\u7a3c\u50cd\u304c\u6700\u512a\u5148\u3002\u30e1\u30e2\u30ea\u4e0d\u8db3\u6642\u306b\u30b9\u30ef\u30c3\u30d7\u3067\u30af\u30e9\u30c3\u30b7\u30e5\u56de\u907f\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u9ad8\u8ca0\u8377\u8a08\u7b97\u30fb\u79d1\u5b66\u6280\u8853\u8a08\u7b97\uff08HPC\uff09<\/td>\n<td>0\u301c5<\/td>\n<td>\u30b9\u30ef\u30c3\u30d7\u306f\u81f4\u547d\u7684\u306a\u9045\u5ef6\u306b\u306a\u308b\u305f\u3081\u3001\u7269\u7406\u30e1\u30e2\u30ea\u304c\u5341\u5206\u306b\u3042\u308b\u524d\u63d0\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"troubleshoot\">\u8a2d\u5b9a\u5909\u66f4\u6642\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<div class=\"warning\"><strong>\u6ce8\u610f:<\/strong> Swappiness \u306e\u904e\u5ea6\u306a\u4f4e\u6e1b\u306f\u3001\u30b7\u30b9\u30c6\u30e0\u304c\u30e1\u30e2\u30ea\u4e0d\u8db3\u306b\u306a\u308b\u3068 OOM\uff08Out Of Memory\uff09\u30ad\u30e9\u30fc\u304c\u30d7\u30ed\u30bb\u30b9\u3092\u5f37\u5236\u7d42\u4e86\u3055\u305b\u308b\u30ea\u30b9\u30af\u304c\u3042\u308a\u307e\u3059\u3002\u7279\u306b\u30b5\u30fc\u30d0\u30fc\u74b0\u5883\u3067\u306f\u614e\u91cd\u306b\u30c6\u30b9\u30c8\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/div>\n<ul>\n<li><strong>\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u3066\u3044\u306a\u3044<\/strong>\n<ul>\n<li>\u30d5\u30a1\u30a4\u30eb\u306e\u66f8\u5f0f\u304c\u6b63\u3057\u3044\u304b\u78ba\u8a8d\uff08<code>vm.swappiness = 10<\/code> \u306e\u30b9\u30da\u30fc\u30b9\u3084\u300c=\u300d\u306e\u524d\u5f8c\u306b\u4e0d\u8981\u306a\u6587\u5b57\u304c\u7121\u3044\u304b\uff09<\/li>\n<li><code>sudo sysctl --system<\/code> \u5b9f\u884c\u5f8c\u306b <code>cat \/proc\/sys\/vm\/swappiness<\/code> \u3067\u518d\u78ba\u8a8d<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u30b9\u30ef\u30c3\u30d7\u304c\u983b\u7e41\u306b\u4f7f\u7528\u3055\u308c\u308b<\/strong>\n<ul>\n<li>\u7269\u7406\u30e1\u30e2\u30ea\u304c\u8db3\u308a\u3066\u3044\u308b\u304b <code>free -h<\/code> \u3067\u30c1\u30a7\u30c3\u30af<\/li>\n<li>\u4e0d\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u3084\u30c7\u30fc\u30e2\u30f3\u3092\u505c\u6b62\u3057\u3001\u30e1\u30e2\u30ea\u30d5\u30c3\u30c8\u30d7\u30ea\u30f3\u30c8\u3092\u524a\u6e1b<\/li>\n<li>\u5fc5\u8981\u306a\u3089 SSD \u30d9\u30fc\u30b9\u306e\u30b9\u30ef\u30c3\u30d7\u9818\u57df\u3092\u62e1\u5f35\uff08\u6027\u80fd\u5411\u4e0a\uff09<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u30b7\u30b9\u30c6\u30e0\u304c\u9045\u304f\u306a\u308b\uff0f\u30d5\u30ea\u30fc\u30ba\u3059\u308b<\/strong>\n<ul>\n<li>Swappiness \u3092\u4f4e\u3081\u3059\u304e\u305f\u7d50\u679c\u3001OOM \u30ad\u30e9\u30fc\u304c\u4f5c\u52d5\u3057\u3066\u3044\u306a\u3044\u304b <code>dmesg | grep -i kill<\/code> \u3067\u78ba\u8a8d<\/li>\n<li>\u4e00\u6642\u7684\u306b <code>vm.swappiness<\/code> \u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u623b\u3057\u3001\u8ca0\u8377\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u518d\u8a55\u4fa1<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Ubuntu 26.04 \u3067\u3082 <code>swappiness<\/code> \u306e\u30c1\u30e5\u30fc\u30cb\u30f3\u30b0\u306f\u30b7\u30b9\u30c6\u30e0\u30ec\u30b9\u30dd\u30f3\u30b9\u5411\u4e0a\u306e\u9375\u3067\u3059\u3002\u307e\u305a\u306f\u73fe\u5728\u5024\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306a\u3089 10\u301c15\u3001\u30b5\u30fc\u30d0\u30fc\u306a\u3089\u30c7\u30d5\u30a9\u30eb\u30c8\u306e 60 \u3068\u3044\u3046\u3088\u3046\u306b\u3001\u5b9f\u969b\u306e\u4f7f\u7528\u30b7\u30fc\u30f3\u306b\u5408\u308f\u305b\u3066\u8abf\u6574\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u8a2d\u5b9a\u306f <code>\/etc\/sysctl.d\/<\/code> \u306b\u6c38\u7d9a\u5316\u3059\u308b\u3060\u3051\u3067\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>\u672c\u8a18\u4e8b\u3092\u53c2\u8003\u306b\u3001\u5feb\u9069\u306a Ubuntu \u4f53\u9a13\u3092\u624b\u306b\u5165\u308c\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n<\/article>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swappiness\u8a2d\u5b9a Ubuntu 26.04\u3067\u306f\u3001\u30e1\u30e2\u30ea\u5727\u8feb\u6642\u306b\u30b9\u30ef\u30c3\u30d7\u9818\u57df\u3078\u30c7\u30fc\u30bf\u3092\u79fb\u3059\u30bf\u30a4\u30df\u30f3\u30b0\u3092\u5236\u5fa1\u3059\u308b swappiness \u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u4f9d\u7136\u3068\u3057\u3066\u91cd\u8981\u3067\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f 60 \u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u30c7\u30b9\u30af [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-408","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":3,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":412,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/408\/revisions\/412"}],"wp:attachment":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}