{"id":284,"date":"2024-10-19T21:34:04","date_gmt":"2024-10-19T12:34:04","guid":{"rendered":"https:\/\/bokumin45.server-on.net\/blog\/?p=284"},"modified":"2025-10-30T12:32:13","modified_gmt":"2025-10-30T03:32:13","slug":"btrfs%e3%81%a7%e3%81%ae%e3%82%b9%e3%83%af%e3%83%83%e3%83%97%e4%bd%9c%e6%88%90%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.bokumin.org\/blog\/2024\/10\/19\/btrfs%e3%81%a7%e3%81%ae%e3%82%b9%e3%83%af%e3%83%83%e3%83%97%e4%bd%9c%e6%88%90%e6%96%b9%e6%b3%95\/","title":{"rendered":"Btrfs\u3067\u306e\u30b9\u30ef\u30c3\u30d7\u4f5c\u6210\u65b9\u6cd5"},"content":{"rendered":"\n<p class=\"has-medium-font-size\">How to create swap with btrfs<\/p>\n\n\n\n<p class=\"has-large-font-size\"><strong>\u4e8b\u306e\u767a\u7aef<\/strong><\/p>\n\n\n\n<p>OpenSUSE Tumbleweed\u3067\u3001\u8ffd\u52a0\u306e\u30b9\u30ef\u30c3\u30d7\u7a7a\u9593\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306b\u30b9\u30ef\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p class=\"has-base-color has-contrast-background-color has-text-color has-background has-link-color wp-elements-118cdd43d24ea4a28e6b79598e74cf6b\">sudo swapon \/swapfile<br>swapon: \/swapfile: swapon failed: Invalid argument<\/p>\n\n\n\n<p class=\"has-large-font-size\"><strong>\u539f\u56e0\u7279\u5b9a<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5c5e\u6027\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u78ba\u8a8d<\/li>\n\n\n\n<li>\u30ab\u30fc\u30cd\u30eb\u30ed\u30b0\u78ba\u8a8d<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>ls -lf \/swapfile\n-rw------- 1 root root 16G Oct 19 20:12 \/swapfile<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">ls<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-lf<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">-rw-------<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">root<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">root<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">16<\/span><span style=\"color: #C3E88D\">G<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">Oct<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">19<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">20<\/span><span style=\"color: #C3E88D\">:12<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6307\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3067\u6a29\u9650\u3082600\u306b\u306a\u3063\u3066\u3044\u305f<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>sudo lsattr \/swapfile\n---------------------- \/swapfile<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">lsattr<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">----------------------<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u7279\u5225\u306a\u5c5e\u6027\u3082\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u6b63\u5e38\u306b\u307f\u3048\u308b\u3051\u3069\u7406\u7531\u308f\u304b\u3089\u305a<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>df -Th \n\/dev\/sda2      btrfs     112G   30G   81G  27% \/<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">df<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-Th<\/span><span style=\"color: #BABED8\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">\/dev\/sda2<\/span><span style=\"color: #BABED8\">      <\/span><span style=\"color: #C3E88D\">btrfs<\/span><span style=\"color: #BABED8\">     <\/span><span style=\"color: #F78C6C\">112<\/span><span style=\"color: #C3E88D\">G<\/span><span style=\"color: #BABED8\">   <\/span><span style=\"color: #F78C6C\">30<\/span><span style=\"color: #C3E88D\">G<\/span><span style=\"color: #BABED8\">   <\/span><span style=\"color: #F78C6C\">81<\/span><span style=\"color: #C3E88D\">G<\/span><span style=\"color: #BABED8\">  <\/span><span style=\"color: #F78C6C\">27<\/span><span style=\"color: #C3E88D\">%<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Btfrs\u3067\u30b9\u30ef\u30c3\u30d7\u3092\u4f5c\u3063\u305f\u90e8\u5206\u304c\u95a2\u4fc2\u3057\u3066\u3044\u308b\u304b\u3082\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>sudo dmesg | grep -i swap\n&#91; 0.114128&#93; &#91; T0&#93; Spectre V1 : Mitigation: usercopy\/swapgs barriers and __user pointer sanitization\n&#91; 1.388004&#93; &#91; T1&#93; systemd&#91;1&#93;: Reached target Swaps.\n&#91; 8.764858&#93; &#91; T798&#93; Adding 2097148k swap on \/dev\/sdb1. Priority:-2 extents:1 across:2097148k\n&#91;107772.672920&#93; &#91; T143757&#93; BTRFS warning (device sda2): swapfile must not be copy-on-write<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">dmesg<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">grep<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-i<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">swap<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">0.114128<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> T0<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> Spectre V1 <\/span><span style=\"color: #82AAFF\">:<\/span><span style=\"color: #BABED8\"> Mitigation: usercopy\/swapgs barriers and __user pointer sanitization<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">1.388004<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> T1<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> systemd<\/span><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\">: Reached target Swaps.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">8.764858<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> T798<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> Adding 2097148k swap on \/dev\/sdb1. Priority:-2 extents:1 across:2097148k<\/span><\/span>\n<span class=\"line\"><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #F78C6C\">107772.672920<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#91;<\/span><span style=\"color: #BABED8\"> T143757<\/span><span style=\"color: #89DDFF\">&#93;<\/span><span style=\"color: #BABED8\"> BTRFS warning <\/span><span style=\"color: #89DDFF\">(<\/span><span style=\"color: #FFCB6B\">device<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">sda2<\/span><span style=\"color: #89DDFF\">)<\/span><span style=\"color: #BABED8\">: swapfile must not be copy-on-write<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6700\u5f8c\u306e\u884c\u306e&#8221;swapfile must not be copy-on-write&#8221;(\u30b9\u30ef\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u306fCoW\u3067\u3042\u3063\u3066\u306f\u3044\u3051\u306a\u3044)\u3067\u539f\u56e0\u304c\u308f\u304b\u308a\u307e\u3057\u305f\u3002<br>Btrfs\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067CoW\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u30b9\u30ef\u30c3\u30d7\u306e\u6b63\u5e38\u306a\u6a5f\u80fd\u3092\u59a8\u3052\u3066\u3044\u305f\u307f\u305f\u3044\u3067\u3059\u3002Btrfs\u3067\u30b9\u30ef\u30c3\u30d7\u3092\u4f5c\u308b\u306b\u306f<strong>CoW\u3092\u7121\u52b9\u306b\u3059\u308b<\/strong>\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u306b\u6c17\u3065\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u89e3\u6c7a\u65b9\u6cd5<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#babed8;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#babed8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>#\u7a7a\u3067\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\nsudo truncate -s 0 \/swapfile\n\n#\u30d5\u30a1\u30a4\u30eb\u306eCoW\u5c5e\u6027\u7121\u52b9\nsudo chattr +C \/swapfile\n\n#btrfs\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5727\u7e2e\u3092\u7121\u52b9\u306b\u6307\u5b9a\nsudo btrfs property set \/swapfile compression none\n\n#\u30b9\u30ef\u30c3\u30d7\u4f5c\u6210\nsudo dd if=\/dev\/zero of=\/swapfile bs=1M count=16384\n\n#\u6a29\u9650\u5909\u66f4\u30fb\u30b9\u30ef\u30c3\u30d7\u3092\u6709\u52b9\u306b\u3059\u308b\nsudo chmod 600 \/swapfile\nsudo mkswap \/swapfile\nsudo swapon \/swapfile\n\n#\u6c38\u7d9a\u7684\u306b\u6709\u52b9\u306b\u3059\u308b\necho '\/swapfile none swap sw 0 0' | sudo tee -a \/etc\/fstab\n\n#\u8a8d\u8b58\u78ba\u8a8d\nsudo swapon --show<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-ocean\" style=\"background-color: #0F111A\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u7a7a\u3067\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">truncate<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-s<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">0<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u30d5\u30a1\u30a4\u30eb\u306eCoW\u5c5e\u6027\u7121\u52b9<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">chattr<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">+C<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#btrfs\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5727\u7e2e\u3092\u7121\u52b9\u306b\u6307\u5b9a<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">btrfs<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">property<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">set<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">compression<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">none<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u30b9\u30ef\u30c3\u30d7\u4f5c\u6210<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">dd<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">if=\/dev\/zero<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">of=\/swapfile<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">bs=<\/span><span style=\"color: #F78C6C\">1<\/span><span style=\"color: #C3E88D\">M<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">count=<\/span><span style=\"color: #F78C6C\">16384<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u6a29\u9650\u5909\u66f4\u30fb\u30b9\u30ef\u30c3\u30d7\u3092\u6709\u52b9\u306b\u3059\u308b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">chmod<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #F78C6C\">600<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">mkswap<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">swapon<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/swapfile<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u6c38\u7d9a\u7684\u306b\u6709\u52b9\u306b\u3059\u308b<\/span><\/span>\n<span class=\"line\"><span style=\"color: #82AAFF\">echo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #C3E88D\">\/swapfile none swap sw 0 0<\/span><span style=\"color: #89DDFF\">&#39;<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">tee<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">-a<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">\/etc\/fstab<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #464B5D; font-style: italic\">#\u8a8d\u8b58\u78ba\u8a8d<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FFCB6B\">sudo<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">swapon<\/span><span style=\"color: #BABED8\"> <\/span><span style=\"color: #C3E88D\">--show<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u53c2\u8003\uff1a<br><a href=\"https:\/\/superuser.com\/questions\/1067150\/how-to-create-swapfile-on-ssd-disk-with-btrfs\">https:\/\/superuser.com\/questions\/1067150\/how-to-create-swapfile-on-ssd-disk-with-btrfs<\/a><br><a href=\"https:\/\/btrfs.readthedocs.io\/en\/latest\/Swapfile.html\">https:\/\/btrfs.readthedocs.io\/en\/latest\/Swapfile.html<\/a><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u307e\u3068\u3081<\/strong><\/p>\n\n\n\n<p>Btrfs\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u6a5f\u80fd\u3084\u5236\u9650\u3092\u3061\u3083\u3093\u3068\u5b66\u3093\u3067\u304a\u3053\u3046\u3068\u601d\u3063\u305f\u4eca\u65e5\u3053\u306e\u9803\u3067\u3057\u305f\u3002<br>\u304a\u308f\u308a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create swap with btrfs \u4e8b\u306e\u767a\u7aef OpenSUSE Tumbleweed\u3067\u3001\u8ffd\u52a0\u306e\u30b9\u30ef\u30c3\u30d7\u7a7a\u9593\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306b\u30b9\u30ef\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u306b\u906d\u9047\u3057\u307e\u3057\u305f\u3002 s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"yes","footnotes":""},"categories":[24,153,19],"tags":[37,36],"class_list":["post-284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-btrfs","category-linux","category-opensuse","tag-btrfs","tag-swap"],"_links":{"self":[{"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/comments?post=284"}],"version-history":[{"count":10,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/posts\/284\/revisions"}],"predecessor-version":[{"id":1863,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/posts\/284\/revisions\/1863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/media\/558"}],"wp:attachment":[{"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/media?parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/categories?post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bokumin.org\/blog\/wp-json\/wp\/v2\/tags?post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}