0% found this document useful (0 votes)
61 views15 pages

Practice Swap

Swap space is used in Linux when physical memory is full. Inactive memory pages are moved to swap space on the hard drive to free up RAM. Additional swap space can be added by creating a swap partition or swap file. Creating a swap partition involves using Parted to make a partition and mkswap, while a swap file uses dd and mkswap. Swap space is removed using swapoff and removing its entry in fstab.

Uploaded by

m3onh0x84
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views15 pages

Practice Swap

Swap space is used in Linux when physical memory is full. Inactive memory pages are moved to swap space on the hard drive to free up RAM. Additional swap space can be added by creating a swap partition or swap file. Creating a swap partition involves using Parted to make a partition and mkswap, while a swap file uses dd and mkswap. Swap space is removed using swapoff and removing its entry in fstab.

Uploaded by

m3onh0x84
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

PRACTICE SWAP SPACE

SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
What is Swap Space?

•Swap space in Linux is used when the amount of


physical memory (RAM) is full
•inactive pages in memory are moved to the swap
space
•Swap space is located on hard drives, which have a
slower access time than physical memory.
•Swap space can be a dedicated swap partition
(recommended), a swap file, or a combination of
swap partitions and swap files.

SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
Adding Swap Space

•Sometimes it is necessary to add more swap space


after installation
•Two options: add a swap partition or add a swap
file

SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
Step by step create swap on /dev/hdb
1. unmount partitions and turn off all the swap space on the hard
drive with the swapoff command
2. Create the swap partition using parted
– parted /dev/hdb
– >print
– >mkpartfs 2 linux-swap start end
– >quit
3. Now that you have created the swap partition
– mkswap /dev/hdb2
4. Enable the swap partition immediately
– swapon /dev/hdb2
5. Enable it at boot time, edit /etc/fstab to include
/dev/hdb2 swap swap defaults 0 0
6. Check for command cat /proc/swaps or free.
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
Step by step create swap file

1. Determine the size of the new swap file in megabytes and


multiple by 1024 to determine the block size.
2. Use dd create a file
#dd if=/dev/zero of=/swapfile bs=1024 count=65536
3. Setup the swap file
#mkswap /swapfile
4. enable the swap file immediately
#swapon /swapfile
5. enable it at boot time, edit /etc/fstab to include
/swapfile swap swap defaults 0 0
6. Check for command cat /proc/swaps or free
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
Removing Swap Space

1. Swap partion
#swapoff /dev/hdb2
2. Swap file
#swapoff /swapfile
3. Remove entry in /etc/fstab

SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102
SAIGONLAB 83 Nguyễn Thị Nhỏ, P9, Q.Tân Bình, Tp. HCM LPI 102

You might also like