{"id":1683,"date":"2018-11-02T16:37:15","date_gmt":"2018-11-02T23:37:15","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=1683"},"modified":"2018-11-02T16:37:15","modified_gmt":"2018-11-02T23:37:15","slug":"centos-create-a-swap-file","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1683","title":{"rendered":"CentOS &#8211; create a swap file."},"content":{"rendered":"<p>I have done a few times before but don&#8217;t have to do it very often, just noting it here.<\/p>\n<p>Create an empty file.  The following will create a 1GB file.:<\/p>\n<blockquote><p># dd if=\/dev\/zero of=\/var\/swapfile bs=1024 count=1024000<br \/>\n1024000+0 records in<br \/>\n1024000+0 records out<br \/>\n1048576000 bytes (1.0 GB) copied, 10.9243 s, 96.0 MB\/s<\/p><\/blockquote>\n<p>Change the permission:<\/p>\n<blockquote><p># chmod 0600 \/var\/swapfile <\/p><\/blockquote>\n<p>Create the swap area:<\/p>\n<blockquote><p># mkswap \/var\/swapfile<br \/>\nSetting up swapspace version 1, size = 1023996 KiB<br \/>\nno label, UUID=957c2a0c-30f9-4dd7-89ed-d88b9f471294<\/p><\/blockquote>\n<p>Enable the swap area:<\/p>\n<blockquote><p># swapon \/var\/swapfile <\/p><\/blockquote>\n<p>Enable the swap area at boot by adding it to the \/etc\/fstab:<\/p>\n<blockquote><p># vi \/etc\/fstab<br \/>\n&#8230;<br \/>\n\/var\/swapfile   swap    swap    defaults 0 0<br \/>\n&#8230;<\/p><\/blockquote>\n<p>Disable the swap area:<\/p>\n<blockquote><p># swapoff \/var\/swapfile <\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I have done a few times before but don&#8217;t have to do it very often, just noting it here. Create an empty file. The following will create a 1GB file.: # dd if=\/dev\/zero of=\/var\/swapfile bs=1024 count=1024000 1024000+0 records in 1024000+0 records out 1048576000 bytes (1.0 GB) copied, 10.9243 s, 96.0 MB\/s Change the permission: # [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[48,91],"class_list":["post-1683","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-linux","tag-swap"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1683"}],"version-history":[{"count":2,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1683\/revisions"}],"predecessor-version":[{"id":1685,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1683\/revisions\/1685"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}