{"id":1834,"date":"2018-10-27T08:20:18","date_gmt":"2018-10-27T08:20:18","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1834"},"modified":"2018-10-28T05:56:15","modified_gmt":"2018-10-28T05:56:15","slug":"using-parted-to-create-a-new-swap-disk","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/27\/using-parted-to-create-a-new-swap-disk\/","title":{"rendered":"Using Parted To Create A New Swap Disk"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxadmin.io\/wp-content\/uploads\/2017\/05\/parted.png\" alt=\"Using parted to create swap\" width=\"667\" height=\"137\" \/><\/p>\n<h2>What is Parted?<\/h2>\n<p>Parted is a software package used to manipulate paritition tables. It is useful for formatting new disks, reorganinzing disks, and removing disk data<\/p>\n<p>First select the disk you would like to use, if you are unsure you you can use fdisk to list all of the disks available to you<\/p>\n<p>fdisk -l<\/p>\n<p>Once you have located the correct disk you would like to use we will use it to enter the command prompt. In this case, we are creating a swap disk on a <a href=\"https:\/\/linuxadmin.io\/install-configure-kvm-on-centos\/\">KVM virtual machine<\/a>.<\/p>\n<p># parted \/dev\/vdb<br \/>\nGNU Parted 3.1<br \/>\nUsing \/dev\/vdb<br \/>\nWelcome to GNU Parted! Type &#8216;help&#8217; to view a list of commands.<br \/>\n(parted)<\/p>\n<p>Replacing \/dev\/vdb with the disk you want to use<\/p>\n<h3>Label The Disk<\/h3>\n<p>We will first need to make the label, at the prompt type mklabel<\/p>\n<p>(parted) mklabel<br \/>\nNew disk label type? msdos<\/p>\n<p>It will warn you before erase the disk, go ahead type Yes as long as you are certain this is the correct disk<\/p>\n<p>Warning: The existing disk label on \/dev\/vdb will be destroyed and all data on this disk will be lost. Do you want to continue?<br \/>\nYes\/No? Yes<br \/>\n(parted)<\/p>\n<h3>Setting the size and type of the disk<\/h3>\n<p>Next you are going to format the disk, to do this type the following<\/p>\n<p>(parted) mkpart<br \/>\nPartition type? primary\/extended? primary<br \/>\nFile system type? [ext2]? linux-swap<br \/>\nStart? 0%<br \/>\nEnd? 100%<\/p>\n<p>We indicated this was going to be a primary partition, it was going to be linux-swap, that it was going to start at 0% of the disk and end at 100%. To verify what you have crated going ahead and type print to review it looks correct:<\/p>\n<p>(parted) print<br \/>\nModel: Virtio Block Device (virtblk)<br \/>\nDisk \/dev\/vdb: 1074MB<br \/>\nSector size (logical\/physical): 512B\/512B<br \/>\nPartition Table: msdos<br \/>\nDisk Flags:<\/p>\n<p>Number Start End Size Type File system Flags<br \/>\n1 1049kB 1074MB 1073MB primary<\/p>\n<p>You can now exit out of parted:<\/p>\n<p>(parted) quit<br \/>\nInformation: You may need to update \/etc\/fstab.<\/p>\n<h3>Creating the swap file<\/h3>\n<p>You will then want tell the operating system to make the newly created partition into a swap file:<\/p>\n<p>mkswap \/dev\/vdb1<\/p>\n<p>And then enable swapping by entering the following<\/p>\n<p>swapon \/dev\/vdb1<\/p>\n<p>You can then finally add it to \/etc\/fstab to ensure it starts on boot<\/p>\n<p>\/dev\/vdb1 swap swap defaults<\/p>\n<p><a href=\"https:\/\/linuxadmin.io\/using-parted-create-new-swap-disk\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Parted? Parted is a software package used to manipulate paritition tables. It is useful for formatting new disks, reorganinzing disks, and removing disk data First select the disk you would like to use, if you are unsure you you can use fdisk to list all of the disks available to you fdisk -l &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/27\/using-parted-to-create-a-new-swap-disk\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using Parted To Create A New Swap Disk&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1834","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1834"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1834\/revisions"}],"predecessor-version":[{"id":1865,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1834\/revisions\/1865"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}