Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
How to Attach a Swap Partition to Linux
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Adding a swap partition to a Linux system can help improve its performance by providing extra memory when the RAM is running low. Here's how you can attach a swap partition to Linux: 1. Create a partition for swap: First, you need to create a partition for swap. You can do this using a disk partitioning tool such as fdisk or parted. Make sure the partition is formatted with the Linux swap file system (type 82). Note down the device name for the new swap partition (e.g. /dev/sda2). 2. Create a swap file system: Next, you need to create a swap file system on the new partition using the mkswap command. For example, if the new swap partition is /dev/sda2, you can create the swap file system using the following command: ``` sudo mkswap /dev/sda2 ``` 3. Activate the swap partition: After creating the swap file system, you need to activate the new swap partition using the swapon command. For example, if the new swap partition is /dev/sda2, you can activate it using the following command: ``` sudo swapon /dev/sda2 ``` 4. Make the changes permanent: To make sure that the new swap partition is activated every time the system boots, you need to add an entry to the /etc/fstab file. Open the file using a text editor and add the following line: ``` /dev/sda2 none swap sw 0 0 ``` Make sure to replace /dev/sda2 with the device name of your swap partition. That's it! You should now have a swap partition attached to your Linux system. You can check that the swap partition is being used by running the free command, which should show both the amount of RAM and swap memory available.
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)