{"id":3772,"date":"2022-12-20T17:20:01","date_gmt":"2022-12-20T20:20:01","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/mkswap-man8\/"},"modified":"2022-12-20T17:20:01","modified_gmt":"2022-12-20T20:20:01","slug":"mkswap-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/mkswap-man8\/","title":{"rendered":"MKSWAP (man8)"},"content":{"rendered":"<h1 align=\"center\">MKSWAP<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#WARNING\">WARNING<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#ENVIRONMENT\">ENVIRONMENT<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">mkswap \u2212 set up a Linux swap area<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mkswap<\/b> [options] <i>device<\/i> [<i>size<\/i>]<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mkswap<\/b> sets up a Linux swap area on a device or in a file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>device<\/i> argument will usually be a disk partition (something like <i>\/dev\/sdb7<\/i>) but can also be a file. The Linux kernel does not look at partition IDs, but many installation scripts will assume that partitions of hex type 82 (LINUX_SWAP) are meant to be swap partitions. (<b>Warning: Solaris also uses this type. Be careful not to kill your Solaris partitions.<\/b>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>size<\/i> parameter is superfluous but retained for backwards compatibility. (It specifies the desired size of the swap area in 1024-byte blocks. <b>mkswap<\/b> will use the entire partition or file if it is omitted. Specifying it is unwise \u2013 a typo may destroy your disk.)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">After creating the swap area, you need the <b>swapon<\/b> command to start using it. Usually swap areas are listed in <i>\/etc\/fstab<\/i> so that they can be taken into use at boot time by a <b>swapon \u2212a<\/b> command in some boot script.<\/p>\n<h2>WARNING <a name=\"WARNING\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The swap header does not touch the first block. A boot loader or disk label can be there, but it is not a recommended setup. The recommended setup is to use a separate partition for a Linux swap area.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mkswap<\/b>, like many others mkfs-like utils, <b>erases the first partition block to make any previous filesystem invisible.<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">However, <b>mkswap<\/b> refuses to erase the first block on a device with a disk label (SUN, BSD, &#8230;).<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>\u2212c<\/b>, <b>\u2212\u2212check<\/b><\/p>\n<p style=\"margin-left:22%;\">Check the device (if it is a block device) for bad blocks before creating the swap area. If any bad blocks are found, the count is printed.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212f<\/b>, <b>\u2212\u2212force<\/b><\/p>\n<p style=\"margin-left:22%;\">Go ahead even if the command is stupid. This allows the creation of a swap area larger than the file or partition it resides on.<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">Also, without this option, <b>mkswap<\/b> will refuse to erase the first block on a device with a partition table.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212L<\/b>, <b>\u2212\u2212label<\/b> <i>label<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify a <i>label<\/i> for the device, to allow <b>swapon<\/b> by label.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212\u2212lock<\/b>[=<i>mode<\/i>]<\/p>\n<p style=\"margin-left:22%;\">Use exclusive BSD lock for device or file it operates. The optional argument <i>mode<\/i> can be <b>yes<\/b>, <b>no<\/b> (or 1 and 0) or <b>nonblock<\/b>. If the <i>mode<\/i> argument is omitted, it defaults to <b>&#8220;yes&#8221;<\/b>. This option overwrites environment variable <b>$LOCK_BLOCK_DEVICE<\/b>. The default is not to use any lock at all, but it\u2019s recommended to avoid collisions with udevd or other tools.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212p<\/b>, <b>\u2212\u2212pagesize<\/b> <i>size<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify the page <i>size<\/i> (in bytes) to use. This option is usually unnecessary; <b>mkswap<\/b> reads the size from the kernel.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212U<\/b>, <b>\u2212\u2212uuid<\/b> <i>UUID<\/i><\/p>\n<p style=\"margin-left:22%;\">Specify the <i>UUID<\/i> to use. The default is to generate a UUID.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212v<\/b>, <b>\u2212\u2212swapversion 1<\/b><\/p>\n<p style=\"margin-left:22%;\">Specify the swap-space version. (This option is currently pointless, as the old <b>\u2212v 0<\/b> option has become obsolete and now only <b>\u2212v 1<\/b> is supported. The kernel has not supported v0 swap-space format since 2.5.22 (June 2002). The new version v1 is supported since 2.1.117 (August 1998).)<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212h<\/b>, <b>\u2212\u2212help<\/b><\/p>\n<p style=\"margin-left:22%;\">Display help text and exit.<\/p>\n<p style=\"margin-left:11%;\"><b>\u2212V<\/b>, <b>\u2212\u2212version<\/b><\/p>\n<p style=\"margin-left:22%;\">Display version information and exit.<\/p>\n<h2>ENVIRONMENT <a name=\"ENVIRONMENT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">LIBBLKID_DEBUG=all<\/p>\n<p style=\"margin-left:22%;\">enables libblkid debug output.<\/p>\n<p style=\"margin-left:11%;\">LOCK_BLOCK_DEVICE=<mode><\/p>\n<p style=\"margin-left:22%;\">use exclusive BSD lock. The mode is &#8220;1&#8221; or &#8220;0&#8221;. See <b>\u2212\u2212lock<\/b> for more details.<\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The maximum useful size of a swap area depends on the architecture and the kernel version.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The maximum number of the pages that is possible to address by swap area header is 4294967295 (32-bit unsigned int). The remaining space on the swap device is ignored.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Presently, Linux allows 32 swap areas. The areas in use can be seen in the file <i>\/proc\/swaps<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>mkswap<\/b> refuses areas smaller than 10 pages.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If you don\u2019t know the page size that your machine uses, you may be able to look it up with &#8220;cat \/proc\/cpuinfo&#8221; (or you may not \u2013 the contents of this file depend on architecture and kernel version).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To set up a swap file, it is necessary to create that file before initializing it with <b>mkswap<\/b>, e.g. using a command like<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"># dd if=\/dev\/zero of=swapfile bs=1MiB count=$((8*1024))<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">to create 8GiB swapfile.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Please read notes from <b>swapon<\/b>(8) about <b>the swap file use restrictions<\/b> (holes, preallocation and copy-on-write issues).<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>fdisk<\/b>(8), <b>swapon<\/b>(8)<\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The mkswap command is part of the util-linux package and is available from https:\/\/www.kernel.org\/pub\/linux\/utils\/util-linux\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  mkswap \u2212 set up a Linux swap area <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,4,874],"class_list":["post-3772","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-man8","tag-mkswap"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3772"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3772\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}