# dd if=\/dev\/zero of=SWAP-LOCATION bs=1M count=COUNT-SIZE status=progress<\/code><\/pre>\n\n\n\nWhere SWAP-LOCATION is the location of the swap file and COUNT-SIZE determines the size of the file.<\/p>\n\n\n\n
Size of the file = bs x COUNT-SIZE<\/p>\n\n\n\n
So, if bs=1M and COUNT-SIZE=15000, the swap file will be of 15000M i.e. 15GB approximately. <\/p>\n\n\n\n
Just like swap partition, a recommended size will be at least 1.5 times your RAM.<\/p>\n\n\n\n
A good example of the above command would be:<\/p>\n\n\n\n
# dd if=\/dev\/zero of=\/swapfile bs=1M count=15000 status=progress<\/code><\/pre>\n\n\n\n2: Modify the read and write permissions of the file using the chmod command<\/strong><\/p>\n\n\n\n# chmod 600 \/swapfile<\/code><\/pre>\n\n\n\nNow only the owner user (i.e. the root) will have read and write access to the file.<\/p>\n\n\n\n
3: Just like Swap Partition, make this file into a swap file using mkswap<\/strong><\/strong>:<\/p>\n\n\n\n# mkswap \/swapfile<\/code><\/pre>\n\n\n\n4: Enable the file using swapon<\/strong><\/strong>:<\/p>\n\n\n\n# swapon \/swapfile<\/code><\/pre>\n\n\n\n5: Create a fstab entry to automatically mount the swap file:<\/strong><\/p>\n\n\n\n~$ nano \/etc\/fstab<\/code><\/pre>\n\n\n\n\/swapfile none swap defaults 0 0<\/code><\/pre>\n\n\n\nHow to Delete Swap File?<\/h2>\n\n\n\n 1<\/strong>. <\/strong>Deactivate it using swapoff<\/strong>:<\/p>\n\n\n\n# swapoff \/swapfile<\/code><\/pre>\n\n\n\n2.<\/strong> Remove the fstab line \/swapfile none swap defaults 0 0<\/code> from \/etc\/fstab<\/strong><\/p>\n\n\n\n# nano \/etc\/fstab<\/code><\/pre>\n\n\n\n3<\/strong>. Finally, remove the swapfile:<\/p>\n\n\n\n# rm \/swapfile<\/code><\/pre>\n\n\n\nThat’s All<\/h2>\n\n\n\n That’s all folks. If there are some mistakes in the article or you would like to suggest something, feel free to point them out in the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"
This article is all about swap memory – swap partition and swap file, what are they, and how to activate and deactivate them.<\/p>\n","protected":false},"author":2,"featured_media":1605,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[48],"tags":[25,26],"class_list":["post-1594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-desktop-tools","tag-arch-linux-installation","tag-installation"],"yoast_head":"\n
What Is Swap Memory in Linux and How to Manage It? | SmartTech101<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n\t \n\t \n\t \n