#基于磁盘的
# Convert partition to swap partition #1, format swap partition [Mkswap][[email protected]/]# mkswap/dev/Sda5 Setting up Swapspace version1, size =106889Kb[[email protected]/]# FreeTotal used Freeshared buffers Cachedmem:1026816 577392 449424 0 29772 343960-/+ Buffers/cache:203660 823156Swap:2064344 0 2064344#2, activating the swap partition [Swapon][[email protected]/]# swapon/dev/SDA5 [[email protected]/]# FreeTotal used Freeshared buffers Cachedmem:1026816 577448 449368 0 29792 343960-/+ Buffers/cache:203696 823120Swap:2168724 0 2168724[[Email protected]/]##3, close swap partition [Swapoff][[email protected]~]# swapoff/dev/sda5# Set Disk vol [[email protected] auto]# E2label/dev/sda5 sky# View Vol [[email protected] auto]# E2label/dev/sda5sky# View Hard disk According to vol [[email protected] auto]# Findfs LABEL=skyfindfs:unable To resolve'Label=sky'
#基于文件的创建一个分区添加交换文件 #mkdir-p/opt/temp#DD-if=/dev/zero Of=/opt/temp/swap bs=1024x768Count=2048000then: Create Swap space #mkswap/opt/temp/swap launches the newly added 2G swap space #swapon/opt/temp/swap# Free-m view you can already see the new space. Swap-3Modify/etc/Fstab, so that the newly added 2G swap space automatically takes effect after the system restarts #Echo "/opt/temp/swap Swap swap defaults 0 0">>/etc/fstab
Reference: http://blog.csdn.net/robertkun/article/details/8522889
Http://www.syscto.com/2014/07/448.html
Linux Creating Swap Partitions