1. View current swap partition usage
[Email protected] ~]# swapon-s
Filename Type Size used priority
/DEV/SDA2 Partition 10485752 111296-1
2. Create a file to expand the swap partition
[[email protected] ~]# DD </dev/zero >/opt/swapfile1 bs=1m count=200
200+0 Records in
200+0 Records out
209715200 bytes (+ MB) copied, 0.492404 s, 426 MB/s
[Email protected] ~]#
3. Swap tags for files created in the second step, not formatted
[Email protected] ~]# Mkswap/opt/swapfile1
Setting up Swapspace version 1, size = 204796 KiB
No label, uuid=c6df54bc-d54b-4e54-a5d6-38d88adb512f --Used to create a boot auto mount, or you can use the full path
[Email protected] ~]#
4. Add file as swap partition, use now
[Email protected] ~]# Swapon/opt/swapfile1
5, check the current swap partition usage, found a more partition file
[Email protected] ~]# swapon-s
Filename Type Size used priority
/DEV/SDA2 Partition 10485752 111276-1
/opt/swapfile1 file 204792 0-2
[Email protected] ~]#
6, edit the/etc/fstab file, set the created swap partition file to boot automatically mount
[Email protected] ~]# Vim/etc/fstab
Add a row of red (according to the rules of the black line) as follows:
Uuid=51fb56d9-0986-4f8c-b61c-4fd3047ebafa swap swap defaults 0 0
uuid=c6df54bc-d54b-4e54-a5d6-38d88adb512f swap swap defaults 0 0
[[Email Protected]host ~]#
7. View current memory situation
[Email protected] ~]# free-m
Total used free shared buffers Cached
mem:1877 1780 97 0 14 884
-/+ buffers/cache:881 996
swap:10439 108 10331
The swap partition extension is complete.
Extending a swap partition for Linux